]> xenbits.xensource.com Git - osstest/rumprun.git/commitdiff
Fix linking on Debian Stretch
authorWei Liu <wei.liu2@citrix.com>
Wed, 7 Jun 2017 15:30:00 +0000 (16:30 +0100)
committerWei Liu <wei.liu2@citrix.com>
Thu, 8 Jun 2017 11:32:17 +0000 (12:32 +0100)
Provide cc-option. Use that to check if -no-pie is available and
append it when necessary.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
global.mk
platform/hw/Makefile
platform/xen/Makefile
platform/xen/xen/Makefile
platform/xen/xen/minios.mk

index 5995507053c417c30c49795a5355b812af95605f..1e0ebd8cf3862c6a19581ed8ffad4864219fa097 100644 (file)
--- a/global.mk
+++ b/global.mk
@@ -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)
index 387440bdeb833aa47767db43ecb58b6d4b432a6d..20bb297d666472d2653010dba3fbf19ef51c1a3b 100644 (file)
@@ -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})
 
@@ -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_* \
index 4f074f784ff030902fc9182c381d422261ee87a4..28ba4c5e57a42a144bb071dba8bf1ac9c23540f9 100644 (file)
@@ -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
index 95a8ecd48f4ae8a065a52701faa18979472fafc8..e42d3bbb66e4554e3118bc2c3fb00e1979b7a470 100644 (file)
@@ -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.
index e6db96dce29ee2aa52439af28849e735e6a2b83e..a9b59a86a95b544572347975cb8a287399225a1a 100644 (file)
@@ -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)