Skip to content

Commit

Permalink
Fix linking on Debian Stretch
Browse files Browse the repository at this point in the history
Provide cc-option. Use that to check if -no-pie is available and
append it when necessary.

Signed-off-by: Wei Liu <[email protected]>
  • Loading branch information
Wei Liu committed Jun 8, 2017
1 parent c7f2f01 commit 35d8119
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
3 changes: 3 additions & 0 deletions global.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ INSTALLDIR= ${RROBJ}/dest.stage
else
INSTALLDIR= ${RRDEST}
endif

cc-option = $(shell if [ -z "`echo 'int p=1;' | $(CC) $(1) -S -o /dev/null -x c - 2>&1`" ]; \
then echo y; else echo n; fi)
6 changes: 5 additions & 1 deletion platform/hw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ SRCS+= intr.c clock_subr.c kernel.c multiboot.c undefs.c
include ../Makefile.inc
include arch/${ARCHDIR}/Makefile.inc

# Disable PIE, but need to check if compiler supports it
LDFLAGS-$(call cc-option,-no-pie) += -no-pie
LDFLAGS += $(LDFLAGS-y)

OBJS:= $(patsubst %.c,${RROBJ}/platform/%.o,${SRCS}) \
$(patsubst %.S,${RROBJ}/platform/%.o,${ASMS})

Expand All @@ -54,7 +58,7 @@ ${RROBJ}/platform/%.o: %.S
${CC} -D_LOCORE ${CPPFLAGS} ${CFLAGS} -c $< -o $@

${MAINOBJ}: ${OBJS} platformlibs
${CC} -nostdlib ${CFLAGS} -Wl,-r ${OBJS} -o $@ \
${CC} -nostdlib ${CFLAGS} ${LDFLAGS} -Wl,-r ${OBJS} -o $@ \
-L${RROBJLIB}/libbmk_core -L${RROBJLIB}/libbmk_rumpuser \
-Wl,--whole-archive -lbmk_rumpuser -lbmk_core -Wl,--no-whole-archive
${OBJCOPY} -w -G bmk_* -G rumpuser_* -G jsmn_* \
Expand Down
4 changes: 4 additions & 0 deletions platform/xen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ default: prepare links mini-os ${MAINOBJ} ${TARGETS}
CPPFLAGS+= -isystem xen/include
CPPFLAGS+= -no-integrated-cpp

# Disable PIE, but need to check if compiler supports it
LDFLAGS-$(call cc-option,-no-pie) += -no-pie
LDFLAGS += $(LDFLAGS-y)

CFLAGS += -fno-builtin

rump-src-y += rumphyper_bio.c
Expand Down
4 changes: 3 additions & 1 deletion platform/xen/xen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ LDARCHLIB := -l$(ARCH_LIB_NAME)
LDSCRIPT := $(TARGET_ARCH_DIR)/minios-$(XEN_TARGET_ARCH).lds
LDFLAGS_FINAL := -T $(LDSCRIPT)

LDFLAGS := -L$(abspath $(OBJ_DIR)/$(TARGET_ARCH_DIR))
# Disable PIE, but need to check if compiler supports it
LDFLAGS-$(call cc-option,-no-pie) += -no-pie
LDFLAGS := -L$(abspath $(OBJ_DIR)/$(TARGET_ARCH_DIR)) $(LDFLAGS-y)

# Prefixes for global API names. All other symbols in mini-os are localised
# before linking with rumprun applications.
Expand Down
5 changes: 3 additions & 2 deletions platform/xen/xen/minios.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ debug = y
# Define some default flags.
# NB. '-Wcast-qual' is nasty, so I omitted it.
DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format -Wno-redundant-decls
DEF_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
DEF_CFLAGS += $(call cc-option,$(CC),-fgnu89-inline)
DEF_CFLAGS-$(call cc-option,-fno-stack-protector) += -fno-stack-protector
DEF_CFLAGS-$(call cc-option,-fgnu89-inline) += -fgnu89-inline
DEF_CFLAGS += $(DEF_CFLAGS-y)
DEF_CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline
DEF_CPPFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)

Expand Down

0 comments on commit 35d8119

Please sign in to comment.