From d2f7c7bec4f996276401b40ac714dfc717dc140c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Wed, 21 Aug 2013 17:03:46 +0200 Subject: [PATCH] os: reenable -fPIC and fix policy linkerscript As it turns out using -fPIC was not the issue but discarding certain sections. The policy_module_table is now located in .data.rel which needs to be at the beginning of the binary. Fixes #849. --- os/src/lib/trace/policy/policy.inc | 5 +++-- os/src/lib/trace/policy/policy.ld | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/os/src/lib/trace/policy/policy.inc b/os/src/lib/trace/policy/policy.inc index 2b7eea212..6a13af09b 100644 --- a/os/src/lib/trace/policy/policy.inc +++ b/os/src/lib/trace/policy/policy.inc @@ -4,7 +4,7 @@ # \date 2013-08-12 # -CXX_OPT = -g -ffreestanding -fno-exceptions -fno-rtti -nostdinc -nostdlib +CXX_OPT = -g -ffreestanding -fPIC -fno-exceptions -fno-rtti -nostdinc -nostdlib -MMD LD_SCRIPT= $(PRG_DIR)/../policy.ld @@ -23,7 +23,8 @@ policy.o: policy.cc $(TARGET_POLICY).elf: table.o policy.o $(MSG_LINK)$@ - $(VERBOSE)$(LD) $(LD_MARCH) -T $(LD_SCRIPT) -Ttext=0 $^ -o $@ + $(VERBOSE)$(LD) $(LD_MARCH) -T $(LD_SCRIPT) -Ttext=0 \ + $^ $(shell $(CXX) $(CC_MARCH) -print-libgcc-file-name) -o $@ $(INSTALL_DIR)/$(TARGET_POLICY): $(TARGET_POLICY).elf $(VERBOSE)$(OBJCOPY) -O binary $< $@ diff --git a/os/src/lib/trace/policy/policy.ld b/os/src/lib/trace/policy/policy.ld index 1ff5d776c..db66c4b33 100644 --- a/os/src/lib/trace/policy/policy.ld +++ b/os/src/lib/trace/policy/policy.ld @@ -2,9 +2,12 @@ PHDRS { rw PT_LOAD; } SECTIONS { .text : { - *(.data) /* must be first because it contains policy module header */ + *(.data.rel) /* must be first because it contains policy module header */ + *(.data) + *(.rodata .rodata.*) *(.text .text.*) *(.bss) + *(.got.plt) } : rw /DISCARD/ : { *(.*) }