[U-Boot] [RFC] [PATCH V2] arm: arm926ejs: use ELF relocations
Heiko Schocher
hs at denx.de
Tue Oct 5 09:40:21 CEST 2010
Hello Albert,
Albert Aribaud wrote:
> HISTORY:
>
> V1 Initial patch
> V2 Rebased on latest mainline master
>
> This patch is *not* a submission for master!
>
> It is a proof of concept of ELF relocations for ARM, hastily done
> in a day's work time for people on the list to try and to comment.
> All comments are welcome, as several suggestions have been made
> today on the list that I did not have time to incorporate, such as
> rewriting the elf table fixup code in C.
>
> The basic idea of this patch is to replace the -fPIC compile-time
> option with the -pie link-time option. This removes the GOT but adds
> the .rel.dyn and .dynsym tables, which together allow fixing up code
> more completely than with -fPIC and the GOT; for instance, all pointers
> inside structures are fixed up with -pie, whereas they are not with GOT.
>
> Note that references to linker-file-generated symbols were also made
> relative to _start rather than absolute. This is not needed as such,
> but it will be useful when optimizing the relocation tables. Actually
> I should have separated this from the ELF relocation support per se.
>
> The edminiv2.h config file is there for reference only; this is the
> one I used for tests. Latest numbers are:
>
> With GOT relocs:
>
> text data bss dec hex filename .bin size
> 141376 4388 16640 162404 27a64 ./u-boot 145764
>
> With ELF relocs:
>
> text data bss dec hex filename .bin size
> 149677 3727 16636 170040 29838 ./u-boot 153408
>
> The size difference is essentially due to .rel.dyn not being optimal.
> As discussed, an added build step should allow reducing it by half and
> making ELF sizes roughly similar to GOT ones.
>
> Tests and comments not only welcome but also heartily called for.
Tested based on your patch on the magnesium board (ARM926ejs and
boots from NOR Flash). U-Boot works, with the following patch:
! I had to set TEXT_BASE to 0xc0000000 as u-boot starts from there,
a TEXT_BASE = 0 didn;t work for me!
diff --git a/board/logicpd/imx27lite/config.mk b/board/logicpd/imx27lite/config.mk
index 2f9c4e6..af1c82b 100644
--- a/board/logicpd/imx27lite/config.mk
+++ b/board/logicpd/imx27lite/config.mk
@@ -1 +1,4 @@
+# with relocation TEXT_BASE can be anything, and making it 0
+# makes relative and absolute relocation fixups interchangeable.
+#TEXT_BASE = 0
TEXT_BASE = 0xc0000000
diff --git a/include/configs/imx27lite-common.h b/include/configs/imx27lite-common.h
index 812e5f2..58f3c49 100644
--- a/include/configs/imx27lite-common.h
+++ b/include/configs/imx27lite-common.h
@@ -236,7 +236,8 @@
"mtdparts=" MTDPARTS_DEFAULT "\0" \
/* additions for new relocation code, must added to all boards */
-#undef CONFIG_SYS_ARM_WITHOUT_RELOC /* This board is tested with relocation support */
+#define CONFIG_RELOC_FIXUP_WORKS
+#undef CONFIG_SYS_ARM_WITHOUT_RELOC
#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x1000 - /* Fix this */ \
CONFIG_SYS_GBL_DATA_SIZE)
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
More information about the U-Boot
mailing list