From: Wolfgang Denk Date: Tue, 19 Oct 2010 19:07:52 +0000 (+0200) Subject: Merge branch 'elf_reloc' X-Git-Tag: v2010.12-rc1~72^2~26 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6d8d4ef994a7c46e34b5fe53b1af7aa4f78192bf;p=u-boot Merge branch 'elf_reloc' Conflicts: arch/arm/include/asm/config.h board/LaCie/edminiv2/config.mk board/karo/tx25/config.mk board/logicpd/imx27lite/config.mk doc/README.arm-relocation Signed-off-by: Wolfgang Denk --- 6d8d4ef994a7c46e34b5fe53b1af7aa4f78192bf diff --cc arch/arm/cpu/arm1136/start.S index 5008ac6e9e,a86114b81b..29ed065c01 --- a/arch/arm/cpu/arm1136/start.S +++ b/arch/arm/cpu/arm1136/start.S @@@ -87,50 -87,37 +87,37 @@@ _end_vect .globl _TEXT_BASE _TEXT_BASE: - .word TEXT_BASE + .word CONFIG_SYS_TEXT_BASE - #if defined(CONFIG_SYS_ARM_WITHOUT_RELOC) - .globl _armboot_start - _armboot_start: - .word _start - #endif - /* * These are defined in the board-specific linker script. + * Subtracting _start from them lets the linker put their + * relative position in the executable instead of leaving + * them null. */ - .globl _bss_start - _bss_start: - .word __bss_start - - .globl _bss_end - _bss_end: - .word _end - - #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) - .globl _datarel_start - _datarel_start: - .word __datarel_start + .globl _bss_start_ofs + _bss_start_ofs: + .word __bss_start - _start - .globl _datarelrolocal_start - _datarelrolocal_start: - .word __datarelrolocal_start + .globl _bss_end_ofs + _bss_end_ofs: + .word _end - _start - .globl _datarellocal_start - _datarellocal_start: - .word __datarellocal_start + .globl _datarel_start_ofs + _datarel_start_ofs: + .word __datarel_start - _start - .globl _datarelro_start - _datarelro_start: - .word __datarelro_start + .globl _datarelrolocal_start_ofs + _datarelrolocal_start_ofs: + .word __datarelrolocal_start - _start - .globl _got_start - _got_start: - .word __got_start + .globl _datarellocal_start_ofs + _datarellocal_start_ofs: + .word __datarellocal_start - _start - .globl _got_end - _got_end: - .word __got_end - #endif + .globl _datarelro_start_ofs + _datarelro_start_ofs: + .word __datarelro_start - _start #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ diff --cc arch/arm/cpu/arm926ejs/start.S index 8cbe3e7466,e882487c25..863de3ba0f --- a/arch/arm/cpu/arm926ejs/start.S +++ b/arch/arm/cpu/arm926ejs/start.S @@@ -116,24 -117,21 +117,21 @@@ _fiq .globl _TEXT_BASE _TEXT_BASE: - .word TEXT_BASE + .word CONFIG_SYS_TEXT_BASE - #if defined(CONFIG_SYS_ARM_WITHOUT_RELOC) - .globl _armboot_start - _armboot_start: - .word _start - #endif - /* * These are defined in the board-specific linker script. + * Subtracting _start from them lets the linker put their + * relative position in the executable instead of leaving + * them null. */ - .globl _bss_start - _bss_start: - .word __bss_start + .globl _bss_start_ofs + _bss_start_ofs: + .word __bss_start - _start - .globl _bss_end - _bss_end: - .word _end + .globl _bss_end_ofs + _bss_end_ofs: + .word _end - _start #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ diff --cc arch/arm/include/asm/config.h index d8e33fc513,8d3eb10789..4124f0a992 --- a/arch/arm/include/asm/config.h +++ b/arch/arm/include/asm/config.h @@@ -21,10 -21,6 +21,9 @@@ #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 ++ +#define CONFIG_LMB +#define CONFIG_SYS_BOOT_RAMDISK_HIGH #endif diff --cc board/LaCie/edminiv2/config.mk index d07642f5cf,bf3581def2..2ffd1250af --- a/board/LaCie/edminiv2/config.mk +++ b/board/LaCie/edminiv2/config.mk @@@ -23,5 -23,5 +23,6 @@@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301 USA # + - CONFIG_SYS_TEXT_BASE = 0x00100000 + # TEXT_BASE must equal the intended FLASH location of u-boot. -TEXT_BASE = 0xfff90000 ++CONFIG_SYS_TEXT_BASE = 0xfff90000 diff --cc board/karo/tx25/config.mk index 4283c3e344,8be6466b5a..18b288392c --- a/board/karo/tx25/config.mk +++ b/board/karo/tx25/config.mk @@@ -1,5 -1,5 +1,5 @@@ ifdef CONFIG_NAND_SPL -TEXT_BASE = 0x810c0000 +CONFIG_SYS_TEXT_BASE = 0x810c0000 else - CONFIG_SYS_TEXT_BASE = 0x81fc0000 -TEXT_BASE = 0x81200000 ++CONFIG_SYS_TEXT_BASE = 0x81200000 endif diff --cc board/logicpd/imx27lite/config.mk index 7f22154c61,af1c82b6c2..018d9207e0 --- a/board/logicpd/imx27lite/config.mk +++ b/board/logicpd/imx27lite/config.mk @@@ -1,1 -1,4 +1,5 @@@ -# with relocation TEXT_BASE can be anything, and making it 0 ++# with relocation CONFIG_SYS_TEXT_BASE can be anything, and making it 0 + # makes relative and absolute relocation fixups interchangeable. -#TEXT_BASE = 0 -TEXT_BASE = 0xc0000000 ++#CONFIG_SYS_TEXT_BASE = 0 ++ +CONFIG_SYS_TEXT_BASE = 0xc0000000 diff --cc doc/README.arm-relocation index 4ab3c7c0bd,b46347bb5b..8d328e09f9 --- a/doc/README.arm-relocation +++ b/doc/README.arm-relocation @@@ -1,50 -1,55 +1,55 @@@ To make relocation on arm working, the following changes are done: - Add new compilerflag: + At arch level: add linker flag -pie - -fPIC + This causes the linker to generate fixup tables .rel.dyn and .dynsym, + which must be applied to the relocated image before transferring + control to it. - -> compiler generates position independent code + These fixups are described in the ARM ELF documentation as type 23 + (program-base-relative) and 2 (symbol-relative) - changes in board code: + At cpu level: modify linker file and add a relocation and fixup loop - - dram_init: - - bd pointer is now at this point not accessible, so only - detect the real dramsize, and store it in gd->ram_size. - best detected with get_ram_size(); - ToDo: move there also the dram initialization on boards where - it is possible. - - setup the bd_t dram bank info in the new function - dram_init_banksize(). + the linker file must be modified to include the .rel.dyn and .dynsym + tables in the binary image, and to provide symbols for the relocation + code to access these tables - - board.c code is adapted from ppc code + The relocation and fixup loop must be executed after executing + board_init_f at initial location and before executing board_init_r + at final location. - - undef CONFIG_RELOC_FIXUP_WORKS + At board level: - -> cmdtabl, and subcommand table must be handled from "hand" - collected in section "__datarellocal_start". + dram_init(): bd pointer is now at this point not accessible, so only + detect the real dramsize, and store it in gd->ram_size. Bst detected + with get_ram_size(). - - How To fixup the sections: + TODO: move also dram initialization there on boards where it is possible. - __datarel_start, __datarelrolocal_start, __datarellocal_start and - __datarelro_start + Setup of the the bd_t dram bank info is done in the new function + dram_init_banksize() called after bd is accessible. - automatically? Then it should be possible to define again - CONFIG_RELOC_FIXUP_WORKS + At lib level: - - irq stack setup is now not longer on a fix position, instead it is - calculated in board_init_f, and stored in gd->irq_sp + Board.c code is adapted from ppc code - ------------------------------------------------------------------------------------- + At config level: - To compile a board without relocation, define CONFIG_SYS_ARM_WITHOUT_RELOC - This possibility will removed!! So please fix your board to compile without - CONFIG_SYS_ARM_WITHOUT_RELOC defined!!! + Define CONFIG_RELOC_FIXUP_WORKS. + Undefine CONFIG_SYS_ARM_WITHOUT_RELOC - ------------------------------------------------------------------------------------- + * WARNING ** WARNING ** WARNING ** WARNING ** WARNING ** WARNING ** WARNING * + + Boards which are not fixed to support relocation will be REMOVED! + + Eventually, CONFIG_SYS_ARM_WITHOUT_RELOC and CONFIG_RELOC_FIXUP_WORKS will + disappear and boards which have to migrated to relocation will disappear too. - For boards which boot from nand_spl, it is possible to save a copy + ----------------------------------------------------------------------------- + + For boards which boot from nand_spl, it is possible to save one copy -if TEXT_BASE == relocation address! This prevents that uboot code +if CONFIG_SYS_TEXT_BASE == relocation address! This prevents that uboot code is copied again in relocate_code(). example for the tx25 board: @@@ -61,12 -66,12 +66,12 @@@ e) there it copy u-boot to CONFIG_SYS_N f) u-boot code steps through board_init_f() and calculates the relocation address and copy itself to it -If TEXT_BASE == relocation address, the copying of u-boot +If CONFIG_SYS_TEXT_BASE == relocation address, the copying of u-boot in f) could be saved. - ------------------------------------------------------------------------------------- + ----------------------------------------------------------------------------- - ToDo: + TODO - fill in bd_t infos (check) - adapt all boards