Re: [U-Boot] relocation problem on powerpc

Joakim Tjernlund/Transmode wrote on 2014/09/09 14:30:13:
From: Joakim Tjernlund/Transmode To: Cc: Chris Packham judge.packham@gmail.com, u-boot
Date: 2014/09/09 14:30 Subject: Re: [U-Boot] relocation problem on powerpc
Here's some more info from a build without any of my modifications.
$ git describe v2014.10-rc2-12-g0b703db
$ powerpc-e500-linux-gnu-gcc --version powerpc-e500-linux-gnu-gcc (Gentoo 4.6.3-r1 p1.9, pie-0.5.2) 4.6.3
$ grep '_GOT2_TABLE_|_GLOBAL_OFFSET_TABLE_|__got2_entries'
u-boot.map
0x00000000effb5100 _GOT2_TABLE_ = . 0x00000000effb7d38 _GLOBAL_OFFSET_TABLE_ 0x00000000effb7d48 PROVIDE (_GLOBAL_OFFSET_TABLE_,
(. + 0x4))
0x0000000000000b0d __got2_entries = (((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 0x2) - 0x1)
$ gdb-multiarch u-boot (gdb) disassemble /r 0xeffb5100,0xeffb7d48 Dump of assembler code from 0xeffb5100 to 0xeffb7d48: 0xeffb5100 <_GOT2_TABLE_+0>: ef fb 51 00 .long 0xeffb5100 0xeffb5104 <_GOT2_TABLE_+4>: ef fb 7d 44 dtstsf cr7,f27,f15 0xeffb5108 <_GOT2_TABLE_+8>: ef f4 00 00 .long 0xeff40000 0xeffb510c <_GOT2_TABLE_+12>: ef f4 01 00 .long
0xeff40100
<snip> 0xeffb7d30 <_GOT2_TABLE_+11312>: ef f6 6e 74 .long
0xeff66e74
0xeffb7d34 <_GOT2_TABLE_+11316>: f0 00 00 d0 psq_st
f0,208(r0),0,0
0xeffb7d38 <_GLOBAL_OFFSET_TABLE_+0>: 00 00 00 00 .long
0x0
0xeffb7d3c <_GLOBAL_OFFSET_TABLE_+4>: 00 00 00 00 .long
0x0
0xeffb7d40 <_GLOBAL_OFFSET_TABLE_+8>: 00 00 00 00 .long
0x0
0xeffb7d44 <_FIXUP_TABLE_+0>: ef fb 99 d4 .long
0xeffb99d4
So no there is no brlr at the end of the table.
There should be, see
http://www.freescale.com/files/32bit/doc/ref_manual/E500ABIUG.pdf, chap 4.3.2
So I did a quick test too with my copy of u-boot: (gdb) disass /r 0x00000000effa0a48,0x00000000effa0a68 Dump of assembler code from 0xeffa0a48 to 0xeffa0a68: 0xeffa0a48 <_GOT2_TABLE_+9800>: f0 00 00 dc .long 0xf00000dc 0xeffa0a4c <_GOT2_TABLE_+9804>: ef f6 29 48 .long 0xeff62948 0xeffa0a50 <_GOT2_TABLE_+9808>: f0 00 00 e0 .long 0xf00000e0 0xeffa0a54 <_GOT2_TABLE_+9812>: 4e 80 00 21 blrl ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0xeffa0a58 <_GLOBAL_OFFSET_TABLE_+0>: 00 00 00 00 .long 0x0 0xeffa0a5c <_GLOBAL_OFFSET_TABLE_+4>: 00 00 00 00 .long 0x0 0xeffa0a60 <_GLOBAL_OFFSET_TABLE_+8>: 00 00 00 00 .long 0x0 0xeffa0a64 <_FIXUP_TABLE_+0>: ef fa 23 1c .long 0xeffa231c
$ powerpc-softfloat_4.5.3-linux-gnu-ld --version GNU ld (GNU Binutils) 2.21.1
I don't know it this is tool(ld) problem or if something in u-boot's
build env. Try dropping
--gc-sections, see if that changes anything, or add --bss-plt or similar
--bss-plt seems to be the answer: http://lists.denx.de/pipermail/u-boot/2014-February/173134.html
Jocke

Hi Jocke
On Wed, Sep 10, 2014 at 1:20 AM, Joakim Tjernlund joakim.tjernlund@transmode.se wrote:
Joakim Tjernlund/Transmode wrote on 2014/09/09 14:30:13:
From: Joakim Tjernlund/Transmode To: Cc: Chris Packham judge.packham@gmail.com, u-boot
Date: 2014/09/09 14:30 Subject: Re: [U-Boot] relocation problem on powerpc
Here's some more info from a build without any of my modifications.
$ git describe v2014.10-rc2-12-g0b703db
$ powerpc-e500-linux-gnu-gcc --version powerpc-e500-linux-gnu-gcc (Gentoo 4.6.3-r1 p1.9, pie-0.5.2) 4.6.3
$ grep '_GOT2_TABLE_|_GLOBAL_OFFSET_TABLE_|__got2_entries'
u-boot.map
0x00000000effb5100 _GOT2_TABLE_ = . 0x00000000effb7d38 _GLOBAL_OFFSET_TABLE_ 0x00000000effb7d48 PROVIDE (_GLOBAL_OFFSET_TABLE_,
(. + 0x4))
0x0000000000000b0d __got2_entries = (((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 0x2) - 0x1)
$ gdb-multiarch u-boot (gdb) disassemble /r 0xeffb5100,0xeffb7d48 Dump of assembler code from 0xeffb5100 to 0xeffb7d48: 0xeffb5100 <_GOT2_TABLE_+0>: ef fb 51 00 .long 0xeffb5100 0xeffb5104 <_GOT2_TABLE_+4>: ef fb 7d 44 dtstsf cr7,f27,f15 0xeffb5108 <_GOT2_TABLE_+8>: ef f4 00 00 .long 0xeff40000 0xeffb510c <_GOT2_TABLE_+12>: ef f4 01 00 .long
0xeff40100
<snip> 0xeffb7d30 <_GOT2_TABLE_+11312>: ef f6 6e 74 .long
0xeff66e74
0xeffb7d34 <_GOT2_TABLE_+11316>: f0 00 00 d0 psq_st
f0,208(r0),0,0
0xeffb7d38 <_GLOBAL_OFFSET_TABLE_+0>: 00 00 00 00 .long
0x0
0xeffb7d3c <_GLOBAL_OFFSET_TABLE_+4>: 00 00 00 00 .long
0x0
0xeffb7d40 <_GLOBAL_OFFSET_TABLE_+8>: 00 00 00 00 .long
0x0
0xeffb7d44 <_FIXUP_TABLE_+0>: ef fb 99 d4 .long
0xeffb99d4
So no there is no brlr at the end of the table.
There should be, see
http://www.freescale.com/files/32bit/doc/ref_manual/E500ABIUG.pdf, chap 4.3.2
Yep that's pretty unambiguous "The word at _GLOBAL_OFFSET_TABLE_[-1] shall contain a blrl instruction". No "should", "may" or "can" in sight.
So I did a quick test too with my copy of u-boot: (gdb) disass /r 0x00000000effa0a48,0x00000000effa0a68 Dump of assembler code from 0xeffa0a48 to 0xeffa0a68: 0xeffa0a48 <_GOT2_TABLE_+9800>: f0 00 00 dc .long 0xf00000dc 0xeffa0a4c <_GOT2_TABLE_+9804>: ef f6 29 48 .long 0xeff62948 0xeffa0a50 <_GOT2_TABLE_+9808>: f0 00 00 e0 .long 0xf00000e0 0xeffa0a54 <_GOT2_TABLE_+9812>: 4e 80 00 21 blrl ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0xeffa0a58 <_GLOBAL_OFFSET_TABLE_+0>: 00 00 00 00 .long 0x0 0xeffa0a5c <_GLOBAL_OFFSET_TABLE_+4>: 00 00 00 00 .long 0x0 0xeffa0a60 <_GLOBAL_OFFSET_TABLE_+8>: 00 00 00 00 .long 0x0 0xeffa0a64 <_FIXUP_TABLE_+0>: ef fa 23 1c .long 0xeffa231c
$ powerpc-softfloat_4.5.3-linux-gnu-ld --version GNU ld (GNU Binutils) 2.21.1
I don't know it this is tool(ld) problem or if something in u-boot's
build env. Try dropping
--gc-sections, see if that changes anything, or add --bss-plt or similar
--bss-plt seems to be the answer: http://lists.denx.de/pipermail/u-boot/2014-February/173134.html
Jocke
Same question as that original thread '--bss-plt' or '-mbss-plt'? The former works (I'll send a patch through) but I can only find documentation for the latter.

With some versions of gcc (that we know of 4.6.3 and 4.8.2 are affected) it is necessary to specify --bss-plt to get the final blrl in the _GOT2_TABLE_. Without this the last symbol does not get it's address relocated. For the P2041RDB board this ended up being NetArpWaitTimerStart which caused the ARP packets to timeout immediately.
Helped-by: Joakim Tjernlund joakim.tjernlund@transmode.se Signed-off-by: Chris Packham judge.packham@gmail.com --- Technically this is v2 of http://lists.denx.de/pipermail/u-boot/2014-September/188365.html but the solution is so different that I'm treating it as a new patch series.
arch/powerpc/config.mk | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/config.mk b/arch/powerpc/config.mk index 6329b6c..fec02f2 100644 --- a/arch/powerpc/config.mk +++ b/arch/powerpc/config.mk @@ -11,6 +11,7 @@ endif
CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000 LDFLAGS_FINAL += --gc-sections +LDFLAGS_FINAL += --bss-plt PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections -fdata-sections \ -meabi PLATFORM_CPPFLAGS += -D__powerpc__ -ffixed-r2

Chris Packham judge.packham@gmail.com wrote on 2014/09/10 06:03:10:
With some versions of gcc (that we know of 4.6.3 and 4.8.2 are affected) it is necessary to specify --bss-plt to get the final blrl in the _GOT2_TABLE_. Without this the last symbol does not get it's address relocated. For the P2041RDB board this ended up being NetArpWaitTimerStart which caused the ARP packets to timeout immediately.
Helped-by: Joakim Tjernlund joakim.tjernlund@transmode.se Signed-off-by: Chris Packham judge.packham@gmail.com
The commit text is a bit misleading, it is binutils(ld) which has changed default so now one have to specify --bss-plt to get what u-boot needs. Works fine with binutils 2.21.1
Acked-by: Joakim Tjernlund joakim.tjernlund@transmode.se
One could possibly argue that --secure-plt should have a NULL word there like the other 3 reserved words around _GLOBAL_OFFSET_TABLE_ to preserve compatibility.
PS. -mbss-plt is the gcc option while --bss-plt is the ld option. u-boot invokes ld directly so --bss-plt is appropriate
Technically this is v2 of http://lists.denx.de/pipermail/u-boot/2014-September/188365.html but the solution is so different that I'm treating it as a new patch series.
arch/powerpc/config.mk | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/config.mk b/arch/powerpc/config.mk index 6329b6c..fec02f2 100644 --- a/arch/powerpc/config.mk +++ b/arch/powerpc/config.mk @@ -11,6 +11,7 @@ endif
CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000 LDFLAGS_FINAL += --gc-sections +LDFLAGS_FINAL += --bss-plt PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections
-fdata-sections \
-meabi
PLATFORM_CPPFLAGS += -D__powerpc__ -ffixed-r2
1.7.9.5

On 09/09/2014 09:03 PM, Chris Packham wrote:
With some versions of gcc (that we know of 4.6.3 and 4.8.2 are affected) it is necessary to specify --bss-plt to get the final blrl in the _GOT2_TABLE_. Without this the last symbol does not get it's address relocated. For the P2041RDB board this ended up being NetArpWaitTimerStart which caused the ARP packets to timeout immediately.
Helped-by: Joakim Tjernlund joakim.tjernlund@transmode.se Signed-off-by: Chris Packham judge.packham@gmail.com
Dear Wolfgang,
I am trying to apply this patch. Shall I drop the "Helped-by:" line. I understand Chris is giving credit to Joakim. But "Helped-by:" is not a standard signature.
York

On 09/09/2014 09:03 PM, Chris Packham wrote:
With some versions of gcc (that we know of 4.6.3 and 4.8.2 are
affected)
it is necessary to specify --bss-plt to get the final blrl in the _GOT2_TABLE_. Without this the last symbol does not get it's address relocated. For the P2041RDB board this ended up being NetArpWaitTimerStart which caused the ARP packets to timeout immediately.
Helped-by: Joakim Tjernlund joakim.tjernlund@transmode.se Signed-off-by: Chris Packham judge.packham@gmail.com
Dear Wolfgang,
I am trying to apply this patch. Shall I drop the "Helped-by:" line. I understand Chris is giving credit to Joakim. But "Helped-by:" is not a
standard
signature.
I am happy with Acked-by or Sign-off-by, you choose.
Jocke

On 09/09/2014 09:03 PM, Chris Packham wrote:
With some versions of gcc (that we know of 4.6.3 and 4.8.2 are affected) it is necessary to specify --bss-plt to get the final blrl in the _GOT2_TABLE_. Without this the last symbol does not get it's address relocated. For the P2041RDB board this ended up being NetArpWaitTimerStart which caused the ARP packets to timeout immediately.
Helped-by: Joakim Tjernlund joakim.tjernlund@transmode.se Signed-off-by: Chris Packham judge.packham@gmail.com
Applied to u-boot-mpc85xx, awaiting upstream.
York
participants (3)
-
Chris Packham
-
Joakim Tjernlund
-
York Sun