[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/12131] New: Using R_ARM_MOV[WT]_PREL to load address of _GLOBAL_
stephen.clarke at st dot com
[Bug ld/12131] New: Using R_ARM_MOV[WT]_PREL to load address of _GLOBAL_OFFSET_TABLE_
Mon, 18 Oct 2010 14:31:00 +0000
Summary: Using R_ARM_MOV[WT]_PREL to load address of
I'm seeing a problem with ARM GOT relocations, specifically
when the .got.plt section is not placed at the start of its output
section. I have reproduced the problem with the binutils.weekly.bz2
tarball snapshot dated Oct 12 2010.
Here's my test example (also in the attachment):
$ cat gottest.s
movw r0, :lower16:_GLOBAL_OFFSET_TABLE_-(here+8)
movt r0, :upper16:_GLOBAL_OFFSET_TABLE_-(here+8)
ldr r1, littab
.section .jcr, "aw"
$ cat gottest.ld
*(.glue_7t) *(.glue_7) *(.vfp11_veneer)
.data : ALIGN (8)
I build like this:
$ arm-none-eabi-as -o gottest.o gottest.s
$ arm-none-eabi-ld --script gottest.ld gottest.o
My expectation is that the code will load the same value
into r0 and r1, but here is the disassembly:
$ arm-none-eabi-objdump -d a.out
a.out: file format elf32-littlearm
Disassembly of section .text:
0: e30003e4 movw r0, #996 ; 0x3e4
4: e3400000 movt r0, #0
8: e51f1004 ldr r1, [pc, #-4] ; c <here>
c: fffffffc .word 0xfffffffc
It seems that r0 is being loaded with 996, and r1 is loaded
with -4. The difference (1000) is exactly the size of the .jcr
section I placed at the start of .data.
Looking at the resolved symbol values:
$ arm-none-eabi-nm a.out
000003f8 d _GLOBAL_OFFSET_TABLE_
00000000 T _start
0000000c t here
0000000c t littab
it seems the correct value should be 0x3f8-(0xc+0x8) = 0x3e4 = 996, i.e. the
movw/movt sequence is consistent with the symbol values.
However, the movw/movt sequence does not work when I use it in my
compiler in combination with R_ARM_GOT32 to get the address of a GOT entry,
whereas the ldr instruction does work.
Everything is fine and consistent iff the .got sections are
placed right at the start of the .data output section (e.g. if the
.jcr section has size zero). But as soon as there is something before
them, I get problems.
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
- [Bug ld/12131] New: Using R_ARM_MOV[WT]_PREL to load address of _GLOBAL_OFFSET_TABLE_,
stephen.clarke at st dot com <=