sh: generate position independent code for all platforms
authorVladimir Zapolskiy <vz@mleia.com>
Sun, 27 Nov 2016 22:15:35 +0000 (00:15 +0200)
committerTom Rini <trini@konsulko.com>
Sat, 3 Dec 2016 02:32:54 +0000 (21:32 -0500)
Finally add fpic compilation option to produce relocatable code.
Note that this requires to define CONFIG_NEEDS_MANUAL_RELOC for all
board files, also relocation support still has some limitations
(e.g. a developer should care not to overwrite the executing code or
memset() with zeroes not yet relocated data on malloc init etc.),
which may be fixed while switching to PIE.

Due to short investigation the architecture code is not ready for PIE
linking, this will require some manipulations with .dyn* sections.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
arch/sh/config.mk
arch/sh/cpu/u-boot.lds

index 673ed8dfa48a63350ec4682d7b46df7661f33f23..71540c8bb2909d06e4e4b6710da6c681e7f65919 100644 (file)
@@ -15,5 +15,6 @@ CONFIG_STANDALONE_LOAD_ADDR += -EB
 endif
 
 PLATFORM_CPPFLAGS += -DCONFIG_SH -D__SH__
+PLATFORM_RELFLAGS += -fpic
 LDFLAGS_FINAL = --gc-sections
 PLATFORM_RELFLAGS += -ffixed-r13
index f2e48c6eca2ab0db2fece1f1fd5f4c92b0474b10..bbf9ff485f3ae0b2c8c85c77d957b173e3f34894 100644 (file)
@@ -60,7 +60,7 @@ SECTIONS
        PROVIDE (_fgot = .);
        .got :
        {
-               *(.got)
+               *(.got.plt) *(.got)
                . = ALIGN(4);
        } >ram
        PROVIDE (_egot = .);