This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] ARM: Don't adjust MOVW/MOVT relocations.
- From: Carlos O'Donell <carlos at codesourcery dot com>
- To: binutils at sourceware dot org, Paul Brook <paul at codesourcery dot com>
- Date: Tue, 01 Jul 2008 10:34:42 -0400
- Subject: [PATCH] ARM: Don't adjust MOVW/MOVT relocations.
Assembling code for ARMv7 may result in offset out of range errors.
These errors are because the MOVW and MOVT relocs have limited
range and should not be adjusted to reference other symbols which
may be too far away.
The following patch changes the behaviour of arm_fix_adjustable,
so that MOVW/MOVT relocs are not adjusted.
I'm submitting this on behalf of Paul Brook.
No regressions on arm-none-eabi.
OK to checkin?
Cheers,
Carlos.
--
Carlos O'Donell
CodeSourcery
carlos@codesourcery.com
(650) 331-3385 x716
gas/
2008-05-27 Paul Brook <paul@codesourcery.com>
* config/tc-arm.c (arm_fix_adjustable): Don't adjust MOVW/MOVT
relocations.
gas/testsuite/
2008-05-27 Paul Brook <paul@codesourcery.com>
* gas/arm/movw-local.d: New test.
* gas/arm/movw-local.s: New test.
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.358
diff -u -p -r1.358 tc-arm.c
--- gas/config/tc-arm.c 3 Jun 2008 14:29:07 -0000 1.358
+++ gas/config/tc-arm.c 27 Jun 2008 14:48:32 -0000
@@ -19420,6 +19420,17 @@ arm_fix_adjustable (fixS * fixP)
|| fixP->fx_r_type == BFD_RELOC_ARM_LDR_PC_G0)
return 0;
+ /* MOVW/MOVT REL relocations have limited offsets, so keep the symbols. */
+ if (fixP->fx_r_type == BFD_RELOC_ARM_MOVW
+ || fixP->fx_r_type == BFD_RELOC_ARM_MOVT
+ || fixP->fx_r_type == BFD_RELOC_ARM_MOVW_PCREL
+ || fixP->fx_r_type == BFD_RELOC_ARM_MOVT_PCREL
+ || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVW
+ || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVT
+ || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVW_PCREL
+ || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVT_PCREL)
+ return 0;
+
return 1;
}
#endif /* defined (OBJ_ELF) || defined (OBJ_COFF) */
Index: gas/testsuite/gas/arm/movw-local.d
===================================================================
RCS file: gas/testsuite/gas/arm/movw-local.d
diff -N gas/testsuite/gas/arm/movw-local.d
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/arm/movw-local.d 27 Jun 2008 14:48:32 -0000
@@ -0,0 +1,16 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#skip: *-*-*coff *-*-pe *-*-wince *-*-*aout* *-*-netbsd *-*-riscix*
+#name: MOVW/MOVT relocations against local symbols
+
+.*: +file format .*arm.*
+
+Disassembly of section .text:
+0[0-9a-f]+ <[^>]+> e3000000 movw r0, #0 ; 0x0
+ 0: R_ARM_MOVW_ABS_NC bar
+0[0-9a-f]+ <[^>]+> e3400000 movt r0, #0 ; 0x0
+ 4: R_ARM_MOVT_ABS bar
+0[0-9a-f]+ <[^>]+> f240 0000 movw r0, #0 ; 0x0
+ 8: R_ARM_THM_MOVW_ABS_NC bar
+0[0-9a-f]+ <[^>]+> f2c0 0000 movt r0, #0 ; 0x0
+ c: R_ARM_THM_MOVT_ABS bar
+#...
Index: gas/testsuite/gas/arm/movw-local.s
===================================================================
RCS file: gas/testsuite/gas/arm/movw-local.s
diff -N gas/testsuite/gas/arm/movw-local.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/arm/movw-local.s 27 Jun 2008 14:48:32 -0000
@@ -0,0 +1,13 @@
+.arch armv7-a
+.text
+.syntax unified
+foo:
+movw r0, #:lower16: bar
+movt r0, #:upper16: bar
+.thumb
+movw r0, #:lower16: bar
+movt r0, #:upper16: bar
+
+.space 0x10000
+
+bar: