This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[arm] target2 relocs
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: binutils <binutils at sources dot redhat dot com>
- Date: Tue, 07 Jul 2009 12:45:37 +0100
- Subject: [arm] target2 relocs
This patch fixes a bug I found with generating target2 relocs. Unlike get32 and
gotoff, target2 is not a partial-inplace relocation. If we don't write the
addend out explicitly in the assembler, we end up silently dropping it for REL
targets.
tested on arm-eabi and arm-vxworks. ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery
2009-07-07 Nathan Sidwell <nathan@codesourcery.com>
gas/
* config/tc-arm.c (md_apply_fix <BFD_RELOC_ARM_TARGET2>): Write
the offset for REL targets here.
gas/testsuite/
* gas/arm/target-reloc-1.s: New.
* gas/arm/target-reloc-1.d: New.
ld/testsuite/
* ld-arm/arm-target2.s: Add addend cases.
* ld-arm/arm-target2-rel.d: Adjust.
* ld-arm/arm-target2-abs.d: Adjust.
* ld-arm/arm-target2-got-rel.d: Adjust.
Index: ld/testsuite/ld-arm/arm-target2-rel.d
===================================================================
--- ld/testsuite/ld-arm/arm-target2-rel.d (revision 255182)
+++ ld/testsuite/ld-arm/arm-target2-rel.d (working copy)
@@ -2,6 +2,6 @@
.*: file format.*
Contents of section .text:
- 8000 (04000000|00000004) .*
+ 8000 (10000000|00000010) (40120000|00001240) (0800efcd|cdef0008) (14325476|76543214) .*
# Ignore .ARM.attributes section
#...
Index: ld/testsuite/ld-arm/arm-target2-abs.d
===================================================================
--- ld/testsuite/ld-arm/arm-target2-abs.d (revision 255182)
+++ ld/testsuite/ld-arm/arm-target2-abs.d (working copy)
@@ -2,6 +2,6 @@
.*: file format.*
Contents of section .text:
- 8000 (04800000|00008004) .*
+ 8000 (10800000|00008010) (44920000|00009244) (1080efcd|cdef8010) (20b25476|7654b220) .*
# Ignore .ARM.attributes section
#...
Index: ld/testsuite/ld-arm/arm-target2-got-rel.d
===================================================================
--- ld/testsuite/ld-arm/arm-target2-got-rel.d (revision 255182)
+++ ld/testsuite/ld-arm/arm-target2-got-rel.d (working copy)
@@ -2,8 +2,8 @@
.*: file format.*
Contents of section .text:
- 8000 (00100000|00001000) .*
+ 8000 (00100000|00001000) (30220000|00002230) (f80fefcd|cdef0ff8) (04425476|76544204) .*
Contents of section .got:
- 9000 (04800000|00008004) .*
+ 9000 (10800000|00008010) .*
# Ignore .ARM.attributes section
#...
Index: ld/testsuite/ld-arm/arm-target2.s
===================================================================
--- ld/testsuite/ld-arm/arm-target2.s (revision 255182)
+++ ld/testsuite/ld-arm/arm-target2.s (working copy)
@@ -3,4 +3,7 @@
.global _start
_start:
.word foo(target2)
+ .word foo+0x1234(target2)
+ .word foo+0xcdef0000(target2)
+ .word foo+0x76543210(target2)
foo:
Index: gas/testsuite/gas/arm/target-reloc-1.d
===================================================================
--- gas/testsuite/gas/arm/target-reloc-1.d (revision 0)
+++ gas/testsuite/gas/arm/target-reloc-1.d (revision 0)
@@ -0,0 +1,15 @@
+#objdump: -dr --show-raw-insn
+#skip: *-*-*coff *-*-pe *-*-wince *-*-*aout* *-*-netbsd *-*-riscix* *-*-vxworks
+#name: TARGET reloc
+
+.*: file format .*arm.*
+
+Disassembly of section .text:
+
+00000000 <foo>:
+ 0: 00001234 .*
+ 0: R_ARM_TARGET2 foo
+ 4: cdef0000 .*
+ 4: R_ARM_TARGET2 foo
+ 8: 76543210 .*
+ 8: R_ARM_TARGET2 foo
Index: gas/testsuite/gas/arm/target-reloc-1.s
===================================================================
--- gas/testsuite/gas/arm/target-reloc-1.s (revision 0)
+++ gas/testsuite/gas/arm/target-reloc-1.s (revision 0)
@@ -0,0 +1,3 @@
+foo: .word foo(TARGET2) + 0x1234
+ .word foo + 0xcdef0000(TARGET2)
+ .word (foo + 0x76543210)(TARGET2)
Index: gas/config/tc-arm.c
===================================================================
--- gas/config/tc-arm.c (revision 255182)
+++ gas/config/tc-arm.c (working copy)
@@ -19775,10 +19775,17 @@ md_apply_fix (fixS * fixP,
case BFD_RELOC_ARM_GOT32:
case BFD_RELOC_ARM_GOTOFF:
- case BFD_RELOC_ARM_TARGET2:
if (fixP->fx_done || !seg->use_rela_p)
md_number_to_chars (buf, 0, 4);
break;
+
+ case BFD_RELOC_ARM_TARGET2:
+ /* TARGET2 is not partial-inplace, so we need to write the
+ addend here for REL targets, because it won't be written out
+ during reloc processing later. */
+ if (fixP->fx_done || !seg->use_rela_p)
+ md_number_to_chars (buf, fixP->fx_offset, 4);
+ break;
#endif
case BFD_RELOC_RVA: