Hardening compilation support for 64bit Linux

Without this patch the compilation failed with:

/usr/bin/ld: main.o: relocation R_X86_64_32S against
`vtable for Genode::Dataspace' can not be used when making a shared object;
recompile with -fPIC
main.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[6]: *** [init] Error 1

For this patch the use of the hardening tool chain must be indicated
using the "hardening_tool_chain" SPECS entry within the file
<build>/etc/specs.conf

Fixes #79
This commit is contained in:
Torsten Hilbrich 2012-06-19 11:05:16 +02:00 committed by Norman Feske
parent df6a2f1365
commit ae41acec27
3 changed files with 15 additions and 0 deletions

View File

@ -77,10 +77,17 @@ endif
#
# Use the host's startup codes, linker script, and dynamic linker
#
ifneq ($(filter hardening_tool_chain, $(SPECS)),)
EXT_OBJECTS += $(shell cc $(CC_MARCH) -print-file-name=Scrt1.o)
EXT_OBJECTS += $(shell cc $(CC_MARCH) -print-file-name=crti.o)
EXT_OBJECTS += $(shell cc $(CC_MARCH) -print-file-name=crtbeginS.o)
EXT_OBJECTS += $(shell cc $(CC_MARCH) -print-file-name=crtendS.o)
else
EXT_OBJECTS += $(shell cc $(CC_MARCH) -print-file-name=crt1.o)
EXT_OBJECTS += $(shell cc $(CC_MARCH) -print-file-name=crti.o)
EXT_OBJECTS += $(shell cc $(CC_MARCH) -print-file-name=crtbegin.o)
EXT_OBJECTS += $(shell cc $(CC_MARCH) -print-file-name=crtend.o)
endif
EXT_OBJECTS += $(shell cc $(CC_MARCH) -print-file-name=crtn.o)
EXT_OBJECTS += -lgcc -lgcc_s -lsupc++ -lc
EXT_OBJECTS += -lpthread

View File

@ -15,3 +15,7 @@ LD_SCRIPT_STATIC = $(call select_from_repositories,src/platform/genode.ld) \
else
LD_SCRIPT_STATIC =
endif
ifneq ($(filter hardening_tool_chain, $(SPECS)),)
CC_OPT += -fPIC
endif

View File

@ -18,4 +18,8 @@ INC_DIR += $(shell echo "int main() {return 0;}" |\
#
# Link libstdc++ that comes with the tool chain
#
ifneq ($(filter hardening_tool_chain, $(SPECS)),)
EXT_OBJECTS += $(shell $(CUSTOM_CXX_LIB) $(CC_MARCH) -print-file-name=libstdc++.so)
else
EXT_OBJECTS += $(shell $(CUSTOM_CXX_LIB) $(CC_MARCH) -print-file-name=libstdc++.a)
endif