arm: implement ELF relocations
PATCH v3 1/2 arm: implement ELF relocations
ELF relocation tables generated with linker option -pie can be used to fixup code and data in a single loop at relocation, removing the need for manual fixups anywhere else in the code.
---
This patch set is intended for the ELF relocation branch, not for master or next!
V1 Initial submission after RFC
V2 Removed useless datarel references and sections
Defined CONFIG_RELOC_FIXUP_WORKS for all ARMs Removed useless define of CONFIG_RELOC_FIXUP_WORKS and undefine of CONFIG_SYS_ARM_WITHOUT_RELOC from edminiv2 board
V3 Fixed missing end-of-line
arch/arm/config.mk | 10 +- arch/arm/cpu/arm926ejs/start.S | 164 ++++++++++++++------------- arch/arm/cpu/arm926ejs/u-boot.lds | 26 +++-- arch/arm/include/asm/config.h | 2 - arch/arm/include/asm/u-boot-arm.h | 14 +- arch/arm/lib/board.c | 8 +- doc/README.arm-relocation | 222 +++++++------------------------------ 7 files changed, 156 insertions(+), 290 deletions(-)
arch/arm/config.mk +5 -5
@@ -33,11 +33,6 @@ STANDALONE_LOAD_ADDR = 0xc100000 endif endif -ifndef CONFIG_SYS_ARM_WITHOUT_RELOC -# needed for relocation -PLATFORM_RELFLAGS += -fPIC -endif - ifdef CONFIG_SYS_ARM_WITHOUT_RELOC PLATFORM_CPPFLAGS += -DCONFIG_SYS_ARM_WITHOUT_RELOC endif
@@ -72,3 +67,8 @@ PLATFORM_LIBS += $(OBJTREE)/arch/arm/lib/eabi_compat.o endif endif LDSCRIPT := $(SRCTREE)/$(CPUDIR)/u-boot.lds + +ifndef CONFIG_SYS_ARM_WITHOUT_RELOC +# needed for relocation +PLATFORM_LDFLAGS += -pie +endif
arch/arm/cpu/arm926ejs/start.S +84 -80
256 lines not on this page · raw message
arch/arm/cpu/arm926ejs/u-boot.lds +15 -11
@@ -41,21 +41,19 @@ SECTIONS . = ALIGN(4); .data : { *(.data) - __datarel_start = .; - *(.data.rel) - __datarelrolocal_start = .; - *(.data.rel.ro.local) - __datarellocal_start = .; - *(.data.rel.local) - __datarelro_start = .; - *(.data.rel.ro) } - __got_start = .; . = ALIGN(4); - .got : { *(.got) } - __got_end = .; + __rel_dyn_start = .; + .rel.dyn : { *(.rel.dyn) } + __rel_dyn_end = .; + + __dynsym_start = .; + .dynsym : { *(.dynsym) } + + . = ALIGN(4); + . = .; __u_boot_cmd_start = .; .u_boot_cmd : { *(.u_boot_cmd) }
@@ -65,4 +63,10 @@ SECTIONS __bss_start = .; .bss (NOLOAD) : { *(.bss) . = ALIGN(4); } _end = .; + + /DISCARD/ : { *(.dynstr*) } + /DISCARD/ : { *(.dynamic*) } + /DISCARD/ : { *(.plt*) } + /DISCARD/ : { *(.interp*) } + /DISCARD/ : { *(.gnu*) } }
arch/arm/include/asm/config.h +0 -2
@@ -21,8 +21,6 @@#ifndef _ASM_CONFIG_H_#define _ASM_CONFIG_H_ -#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC )/* Relocation to SDRAM works on all ARM boards */ #define CONFIG_RELOC_FIXUP_WORKS #endif -#endif
arch/arm/include/asm/u-boot-arm.h +7 -7
@@ -30,18 +30,18 @@#define _U_BOOT_ARM_H_ 1/* for the following variables, see start.S */ -extern ulong _bss_start;/* code + data end == BSS start */ -extern ulong _bss_end;/* BSS end */ +extern ulong _bss_start_ofs;/* BSS start relative to _start */ +extern ulong _bss_end_ofs;/* BSS end relative to _start */ extern ulong IRQ_STACK_START ;/* top of IRQ stack */ extern ulong FIQ_STACK_START ;/* top of FIQ stack */ #if defined(CONFIG_SYS_ARM_WITHOUT_RELOC ) -extern ulong _armboot_start;/* code start */ +extern ulong _armboot_start_ofs;/* code start */ #else extern ulong _TEXT_BASE;/* code start */ -extern ulong _datarel_start; -extern ulong _datarelrolocal_start; -extern ulong _datarellocal_start; -extern ulong _datarelro_start; +extern ulong _datarel_start_ofs; +extern ulong _datarelrolocal_start_ofs; +extern ulong _datarellocal_start_ofs; +extern ulong _datarelro_start_ofs;extern ulong IRQ_STACK_START_IN ;/* 8 bytes in IRQ stack */ #endif
arch/arm/lib/board.c +5 -3
@@ -147,7 +147,7 @@ static int display_banner (void)#else _armboot_start, #endif - _bss_start, _bss_end); + _bss_start_ofs+_TEXT_BASE, _bss_end_ofs+_TEXT_BASE);#ifdef CONFIG_MODEM_SUPPORT debug ("Modem Support enabled\n" );#endif
@@ -517,7 +517,7 @@ void board_init_f (ulong bootflag)memset ((void *)gd,0 ,sizeof (gd_t)); - gd->mon_len = _bss_end - _TEXT_BASE; + gd->mon_len = _bss_end_ofs;for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {if ((*init_fnc_ptr)() !=0 ) {
@@ -679,6 +679,7 @@ static char *failed = "*** failed ***\n";* ************************************************************************ */ +void board_init_r (gd_t *id,ulong dest_addr) {char *s;
@@ -702,7 +703,7 @@ void board_init_r (gd_t *id, ulong dest_addr) gd->flags |=GD_FLG_RELOC ;/* tell others: relocation done */ - monitor_flash_len = _bss_start - _TEXT_BASE; + monitor_flash_len = _bss_start_ofs;debug ("monitor flash len: %08lX\n" , monitor_flash_len);board_init ();/* Setup chipselects */
@@ -914,6 +915,7 @@ extern void davinci_eth_set_mac_addr (const u_int8_t *addr); /* NOTREACHED - no way out of command loop except booting */ } +#endif /* defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */ void hang (void )
doc/README.arm-relocation +40 -182
263 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v3 2/2 edminiv2: add support for ELF relocations
--- board/LaCie/edminiv2/config.mk | 4 ++-- include/configs/edminiv2.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)
board/LaCie/edminiv2/config.mk +2 -2
@@ -23,5 +23,5 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301 USA # - -TEXT_BASE = 0x00100000 +# TEXT_BASE must equal the intended FLASH location of u-boot. +TEXT_BASE = 0xfff90000
include/configs/edminiv2.h +5 -0
@@ -223,4 +223,9 @@#define CONFIG_SYS_RESET_ADDRESS 0xffff0000#define CONFIG_SYS_MAXARGS 16 +/* additions for new relocation code, must be added to all boards */ +#define CONFIG_SYS_SDRAM_BASE 0 +#define CONFIG_SYS_INIT_SP_ADDR \ + (CONFIG_SYS_SDRAM_BASE + 0x1000 - CONFIG_SYS_GBL_DATA_SIZE) +#endif /* _CONFIG_EDMINIV2_H */
Signature · 1 line
1.7.1
PATCH v3 2/2 edminiv2: add support for ELF relocations
Dear Albert Aribaud,
Quoted 6 lines · In message <[email protected]> you wrote:
Signed-off-by Albert Aribaud <[email protected]>--- board/LaCie/edminiv2/config.mk | 4 ++-- include/configs/edminiv2.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)
Applied to "u-boot-arm" repository, "elf_reloc" branch.
Thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "Just Say No." - Nancy Reagan "No." - Ronald Reagan
PATCH v3 1/2 arm: implement ELF relocations
In reply to Albert AribaudDear Albert Aribaud,
Quoted 17 lines · In message <[email protected]> you wrote:
ELF relocation tables generated with linker option -pie can be used to fixup code and data in a single loop at relocation, removing the need for manual fixups anywhere else in the code.
Signed-off-by Albert Aribaud <[email protected]>---
This patch set is intended for the ELF relocation branch, not for master or next!V1 Initial submission after RFC
V2 Removed useless datarel references and sections
DefinedCONFIG_RELOC_FIXUP_WORKSfor all ARMs Removed useless define ofCONFIG_RELOC_FIXUP_WORKSand undefine ofCONFIG_SYS_ARM_WITHOUT_RELOCfrom edminiv2 board
V3 Fixed missing end-of-line
Quoted 8 lines
arch/arm/config.mk | 10 +- arch/arm/cpu/arm926ejs/start.S | 164 ++++++++++++++------------- arch/arm/cpu/arm926ejs/u-boot.lds | 26 +++-- arch/arm/include/asm/config.h | 2 - arch/arm/include/asm/u-boot-arm.h | 14 +- arch/arm/lib/board.c | 8 +- doc/README.arm-relocation | 222 +++++++------------------------------ 7 files changed, 156 insertions(+), 290 deletions(-)
Applied to "u-boot-arm" repository, "elf_reloc" branch.
Thanks.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de ######## This message was made from 100% recycled electrons. ########