]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Merge branch 'elf_reloc'
authorWolfgang Denk <wd@denx.de>
Tue, 19 Oct 2010 19:07:52 +0000 (21:07 +0200)
committerWolfgang Denk <wd@denx.de>
Tue, 19 Oct 2010 19:07:52 +0000 (21:07 +0200)
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 <wd@denx.de>
1  2 
arch/arm/cpu/arm1136/start.S
arch/arm/cpu/arm926ejs/start.S
arch/arm/cpu/armv7/start.S
arch/arm/include/asm/config.h
arch/arm/lib/board.c
board/LaCie/edminiv2/config.mk
board/karo/tx25/config.mk
board/logicpd/imx27lite/config.mk
doc/README.arm-relocation

index 5008ac6e9e2f1a139d306e75122f3c8a91a021e6,a86114b81bbccff645dddb269c3dca6dd63d4656..29ed065c011f8d3c972d2ad6ed8733c89de85c27
@@@ -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) */
index 8cbe3e74663c8c459b864d825c1f98be1de03456,e882487c25a86d62eba748807b953e786b309142..863de3ba0fc64cea888911ed1c49208749993aa2
@@@ -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) */
Simple merge
index d8e33fc5135d6f74fedb89ca574396d9ea95f2bc,8d3eb10789792c3fe1fbd37481c9227b6177185c..4124f0a9922e25d0d919e871107648bf859fd4fd
  #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
Simple merge
index d07642f5cf70a57ea01e6d20266bb539586b696b,bf3581def241e35f0430ed24f422a2b73fe6efdc..2ffd1250af5b7244ff9ddbf21c9f83ad22968017
@@@ -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 = 0xfff90000
+ # TEXT_BASE must equal the intended FLASH location of u-boot.
++CONFIG_SYS_TEXT_BASE = 0xfff90000
index 4283c3e344ed09d8b9227b6cda9d248c1a91ce2b,8be6466b5a873eca85a70cd6affe031dbf45bda6..18b288392cf606a65008d693b545428fb9e32b06
@@@ -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
index 7f22154c618d9fd80fa985926849ebbffbf8d0a3,af1c82b6c282fe1d87e5160477fb59ce3adbb5a8..018d9207e0f04bfe1a2f3a89cf282767d4516698
@@@ -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
index 4ab3c7c0bd6be1feed94285534c750e02d48c542,b46347bb5b16679ca9f19ba12742defa611a94c9..8d328e09f9108c93c82f263f286f84322c4037ae
@@@ -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