1 # DP: Fix assembler bug blocking Thumb-2 kernel builds (CS issue #8775).
3 2010-06-02 Paul Brook <paul@codesourcery.com>
5 Issue #8775 - PC relative LDR from global symbol.
7 * config/tc-arm.c (arm_force_relocation): Resolve all pc-relative
11 * gas/arm/ldr-global.d: New test.
12 * gas/arm/ldr-global.s: New test.
14 Index: binutils-2.21.0.20110216/gas/testsuite/gas/arm/ldr-global.d
15 ===================================================================
16 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
17 +++ binutils-2.21.0.20110216/gas/testsuite/gas/arm/ldr-global.d 2011-02-16 18:25:14.528229049 +0000
19 +#objdump: -dr --prefix-addresses --show-raw-insn
20 +#name: PC-relative LDR from global
22 +.*: +file format .*arm.*
24 +Disassembly of section .text:
25 +0+00 <[^>]*> e59f0010 ? ldr r0, \[pc, #16\] ; 0+18 <[^>]*>
26 +0+04 <[^>]*> e1df00fc ? ldrsh r0, \[pc, #12\] ; 0+18 <[^>]*>
27 +0+08 <[^>]*> ed9f0a02 ? vldr s0, \[pc, #8\] ; 0+18 <[^>]*>
28 +0+0c <[^>]*> 4802 ? ldr r0, \[pc, #8\] ; \(0+18 <[^>]*>\)
29 +0+0e <[^>]*> 4802 ? ldr r0, \[pc, #8\] ; \(0+18 <[^>]*>\)
30 +0+10 <[^>]*> ed9f 0a01 ? vldr s0, \[pc, #4\] ; 0+18 <[^>]*>
31 +0+14 <[^>]*> f8df 0000 ? ldr\.w r0, \[pc\] ; 0+18 <[^>]*>
33 Index: binutils-2.21.0.20110216/gas/testsuite/gas/arm/ldr-global.s
34 ===================================================================
35 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
36 +++ binutils-2.21.0.20110216/gas/testsuite/gas/arm/ldr-global.s 2011-02-16 18:25:14.528229049 +0000
38 +@ Test pc-relative loads from global objects defined in the same text segment.
39 +@ See tc-arm.c:arm_force_relocation.
60 Index: binutils-2.21.0.20110216/gas/config/tc-arm.c
61 ===================================================================
62 --- binutils-2.21.0.20110216.orig/gas/config/tc-arm.c 2011-02-16 18:23:21.728228999 +0000
63 +++ binutils-2.21.0.20110216/gas/config/tc-arm.c 2011-02-16 18:25:14.538229024 +0000
64 @@ -21675,14 +21675,25 @@
68 - /* Resolve these relocations even if the symbol is extern or weak. */
69 + /* Resolve these relocations even if the symbol is extern or weak.
70 + Technically this is probably wrong due to symbol preemption.
71 + In practice these relocations do not have enough range to be useful
72 + at dynamic link time, and some code (e.g. in the Linux kernel)
73 + expects these references to be resolved. */
74 if (fixp->fx_r_type == BFD_RELOC_ARM_IMMEDIATE
75 || fixp->fx_r_type == BFD_RELOC_ARM_OFFSET_IMM
76 + || fixp->fx_r_type == BFD_RELOC_ARM_OFFSET_IMM8
77 || fixp->fx_r_type == BFD_RELOC_ARM_ADRL_IMMEDIATE
78 + || fixp->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM
79 + || fixp->fx_r_type == BFD_RELOC_ARM_CP_OFF_IMM_S2
80 + || fixp->fx_r_type == BFD_RELOC_ARM_THUMB_OFFSET
81 || fixp->fx_r_type == BFD_RELOC_ARM_T32_ADD_IMM
82 || fixp->fx_r_type == BFD_RELOC_ARM_T32_IMMEDIATE
83 || fixp->fx_r_type == BFD_RELOC_ARM_T32_IMM12
84 - || fixp->fx_r_type == BFD_RELOC_ARM_T32_ADD_PC12)
85 + || fixp->fx_r_type == BFD_RELOC_ARM_T32_OFFSET_IMM
86 + || fixp->fx_r_type == BFD_RELOC_ARM_T32_ADD_PC12
87 + || fixp->fx_r_type == BFD_RELOC_ARM_T32_CP_OFF_IMM
88 + || fixp->fx_r_type == BFD_RELOC_ARM_T32_CP_OFF_IMM_S2)
91 /* Always leave these relocations for the linker. */