[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
binutils 2.11(.2): ARM relocation problem in linker
From: |
Eberhard Mattes |
Subject: |
binutils 2.11(.2): ARM relocation problem in linker |
Date: |
Sat, 14 Jul 2001 11:57:07 +0200 (MET DST) |
Binutils version: 2.11 and 2.11.2
Configuration: --target=arm-epoc-pe (PE/COFF)
For branches between different .text* sections (C++ templates and
.linkonce discard!), ld computes wrong target addresses as shown by
this sample code:
------------------------------------------------------------------------
.text
.globl foo
nop
foo: b bar
.section .text$bar
bar: b foo
------------------------------------------------------------------------
Here's an excerpt from the resulting executable (using objdump -D):
------------------------------------------------------------------------
Disassembly of section .text:
00401000 <__bss_end__>:
401000: e1a00000 nop (mov r0,r0)
00401004 <foo>:
401004: eaffffff b 401008 <bar>
00401008 <bar>:
401008: eafffffc b 401000 <__bss_end__>
------------------------------------------------------------------------
Note that the target of the last `b' instruction is wrong, it should
be 401004 instead of 401000. This bug does not show up for other COFF
targets such as i686-pc-cygwin.
Apparently, coff_arm_relocate_section (in coff-arm.c) and
_bfd_coff_generic_relocate_section (in cofflink.c) got out of sync;
enabling this disabled code:
#if 0 /* We must not ignore the symbol value. If the symbol is
within the same section, the relocation should have already
been fixed, but if it is not, we'll be handed a reloc into
the beginning of the symbol's section, so we must not cancel
out the symbol's value, otherwise we'll be adding it in
twice. */
if (sym != NULL && sym->n_scnum != 0)
addend += sym->n_value;
#endif
seems to fix the problem as shown by this disassembly:
------------------------------------------------------------------------
Disassembly of section .text:
00401000 <__bss_end__>:
401000: e1a00000 nop (mov r0,r0)
00401004 <foo>:
401004: eaffffff b 401008 <bar>
00401008 <bar>:
401008: eafffffd b 401004 <foo>
------------------------------------------------------------------------
I think there are more differences between coff_arm_relocate_section
and _bfd_coff_generic_relocate_section which are not intentional.
Eberhard Mattes
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- binutils 2.11(.2): ARM relocation problem in linker,
Eberhard Mattes <=