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.
This commit is contained in:
Josef Söntgen 2013-08-21 17:03:46 +02:00 committed by Norman Feske
parent 5afb5fcc12
commit d2f7c7bec4
2 changed files with 7 additions and 3 deletions

View File

@ -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 $< $@

View File

@ -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/ : { *(.*) }