Message ID | 1445749348-22106-1-git-send-email-prabhakar@freescale.com |
---|---|
State | Accepted |
Delegated to: | Tom Rini |
Headers | show |
On 10/24/2015 10:02 PM, Prabhakar Kushwaha wrote: > From: Zhenhua Luo <zhenhua.luo@freescale.com> > > In binutils-2.25, the _GLOBAL_OFFSET_TABLE_ symbols defined by PROVIDE in > u-boot.lds overrides the linker built-in symbols > (https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff; > h=b893397a4b1316610f49819344817715e4305de9), > so the linker is treating _GLOBAL_OFFSET_TABLE_ as a definition into the > .reloc section. > > To align with the change of binutils-2.25, the _GLOBAL_OFFSET_TABLE_ symbol > should not be defined in sections, and the symbols in linker generated .got > section should be used(https://sourceware.org/ml/binutils/2008-09/ > msg00122.html) > > Fixed the following build errors with binutils-2.25: > | powerpc-poky-linux-gnuspe-ld.bfd: _GLOBAL_OFFSET_TABLE_ not defined in > linker created .got > > Signed-off-by: Zhenhua Luo <zhenhua.luo@freescale.com> > Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com> > --- > Changes for v2: Updated Subject > Prabhakar/Zhenghua, Have you addressed Tom's comment (on rev 1 patch)? Quote, "What happens when we use older binutils? I'd like some run-time testing too please". York
On Fri, 2015-10-30 at 10:12 -0700, York Sun wrote: > > On 10/24/2015 10:02 PM, Prabhakar Kushwaha wrote: > > From: Zhenhua Luo <zhenhua.luo@freescale.com> > > > > In binutils-2.25, the _GLOBAL_OFFSET_TABLE_ symbols defined by PROVIDE in > > u-boot.lds overrides the linker built-in symbols > > (https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff; > > h=b893397a4b1316610f49819344817715e4305de9), hmm, what was the reson for this change in binutils? As I recall, PROVIDE should only add a symbol when there is none and now binutils just ignores this, strange. > > so the linker is treating _GLOBAL_OFFSET_TABLE_ as a definition into the > > .reloc section. Yes, where do you want it instead? what is the difference with/without PROVIDE? > > > > To align with the change of binutils-2.25, the _GLOBAL_OFFSET_TABLE_ symbol > > should not be defined in sections, and the symbols in linker generated .got > > section should be used(https://sourceware.org/ml/binutils/2008-09/ > > msg00122.html) > > Fixed the following build errors with binutils-2.25: > > > powerpc-poky-linux-gnuspe-ld.bfd: _GLOBAL_OFFSET_TABLE_ not defined in > > linker created .got > > > > Signed-off-by: Zhenhua Luo <zhenhua.luo@freescale.com> > > Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com> > > --- > > Changes for v2: Updated Subject > > > > Prabhakar/Zhenghua, > > Have you addressed Tom's comment (on rev 1 patch)? Quote, "What happens when we > use older binutils? I'd like some run-time testing too please". > > York > > _______________________________________________ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot
[Resending with old email address] I want to add why PROVIDE was added in the first place: In theory it is possible to build an u-boot without ld defining _GLOBAL_OFFSET_TABLE_, in that case we create _GLOBAL_OFFSET_TABLE_ ourself. Should we start using -fPIC* one day this will we will be close to an u-boot without _GLOBAL_OFFSET_TABLE_ and the __got2_entries calculation will fail. *older gcc's will automatically promote -fpic to -fPIC when used with -mrelocatable I wrote a small patch in 2010 to fix this: https://gcc.gnu.org/ml/gcc-patches/2010-10/msg02301.html Cannot remember what gcc version(4.6?) that went into. About the same time support for -msingle-pic-base was added to powerpc gcc This would reduce code size further, possibly interesting for SPL? I sent som patches for that but there were something holding them back. On Mon, 2015-11-02 at 17:17 +0100, Joakim Tjernlund wrote: > On Fri, 2015-10-30 at 10:12 -0700, York Sun wrote: > > > > On 10/24/2015 10:02 PM, Prabhakar Kushwaha wrote: > > > From: Zhenhua Luo <zhenhua.luo@freescale.com> > > > > > > In binutils-2.25, the _GLOBAL_OFFSET_TABLE_ symbols defined by PROVIDE in > > > u-boot.lds overrides the linker built-in symbols > > > (https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff; > > > h=b893397a4b1316610f49819344817715e4305de9), > > hmm, what was the reson for this change in binutils? As I recall, PROVIDE should > only add a symbol when there is none and now binutils just ignores this, strange. > > > > so the linker is treating _GLOBAL_OFFSET_TABLE_ as a definition into the > > > .reloc section. > > Yes, where do you want it instead? what is the difference with/without PROVIDE? > > > > > > > To align with the change of binutils-2.25, the _GLOBAL_OFFSET_TABLE_ symbol > > > should not be defined in sections, and the symbols in linker generated .got > > > section should be used(https://sourceware.org/ml/binutils/2008-09/ > > > msg00122.html) > > > Fixed the following build errors with binutils-2.25: > > > > powerpc-poky-linux-gnuspe-ld.bfd: _GLOBAL_OFFSET_TABLE_ not defined in > > > linker created .got > > > > > > Signed-off-by: Zhenhua Luo <zhenhua.luo@freescale.com> > > > Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com> > > > --- > > > Changes for v2: Updated Subject > > > > > > > Prabhakar/Zhenghua, > > > > Have you addressed Tom's comment (on rev 1 patch)? Quote, "What happens when we > > use older binutils? I'd like some run-time testing too please". > > > > York > > > > _______________________________________________ > > U-Boot mailing list > > U-Boot@lists.denx.de > > http://lists.denx.de/mailman/listinfo/u-boot
On Sun, Oct 25, 2015 at 10:32:28AM +0530, Prabhakar Kushwaha wrote: > From: Zhenhua Luo <zhenhua.luo@freescale.com> > > In binutils-2.25, the _GLOBAL_OFFSET_TABLE_ symbols defined by PROVIDE in > u-boot.lds overrides the linker built-in symbols > (https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff; > h=b893397a4b1316610f49819344817715e4305de9), > so the linker is treating _GLOBAL_OFFSET_TABLE_ as a definition into the > .reloc section. > > To align with the change of binutils-2.25, the _GLOBAL_OFFSET_TABLE_ symbol > should not be defined in sections, and the symbols in linker generated .got > section should be used(https://sourceware.org/ml/binutils/2008-09/ > msg00122.html) > > Fixed the following build errors with binutils-2.25: > | powerpc-poky-linux-gnuspe-ld.bfd: _GLOBAL_OFFSET_TABLE_ not defined in > linker created .got > > Signed-off-by: Zhenhua Luo <zhenhua.luo@freescale.com> > Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com> Applied to u-boot/master, thanks!
diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-nand.lds b/arch/powerpc/cpu/mpc85xx/u-boot-nand.lds index f933b21..0399f93 100644 --- a/arch/powerpc/cpu/mpc85xx/u-boot-nand.lds +++ b/arch/powerpc/cpu/mpc85xx/u-boot-nand.lds @@ -44,7 +44,6 @@ SECTIONS _GOT2_TABLE_ = .; KEEP(*(.got2)) KEEP(*(.got)) - PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4); _FIXUP_TABLE_ = .; KEEP(*(.fixup)) } diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-nand_spl.lds b/arch/powerpc/cpu/mpc85xx/u-boot-nand_spl.lds index b83c553..f044564 100644 --- a/arch/powerpc/cpu/mpc85xx/u-boot-nand_spl.lds +++ b/arch/powerpc/cpu/mpc85xx/u-boot-nand_spl.lds @@ -22,7 +22,6 @@ SECTIONS _GOT2_TABLE_ = .; KEEP(*(.got2)) KEEP(*(.got)) - PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4); _FIXUP_TABLE_ = .; KEEP(*(.fixup)) } diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds index 5ae7b3e..889a4c2 100644 --- a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds +++ b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds @@ -29,7 +29,6 @@ SECTIONS _GOT2_TABLE_ = .; KEEP(*(.got2)) KEEP(*(.got)) - PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4); _FIXUP_TABLE_ = .; KEEP(*(.fixup)) } diff --git a/arch/powerpc/cpu/mpc85xx/u-boot.lds b/arch/powerpc/cpu/mpc85xx/u-boot.lds index 2cf0b25..f15eaf3 100644 --- a/arch/powerpc/cpu/mpc85xx/u-boot.lds +++ b/arch/powerpc/cpu/mpc85xx/u-boot.lds @@ -50,7 +50,6 @@ SECTIONS _GOT2_TABLE_ = .; KEEP(*(.got2)) KEEP(*(.got)) - PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4); _FIXUP_TABLE_ = .; KEEP(*(.fixup)) }