Upload Tizen:Base source
[external/binutils.git] / packaging / 159_gas-i8775.diff
1 # DP: Fix assembler bug blocking Thumb-2 kernel builds (CS issue #8775).
2
3 2010-06-02  Paul Brook  <paul@codesourcery.com>
4
5         Issue #8775 - PC relative LDR from global symbol.
6         gas/
7         * config/tc-arm.c (arm_force_relocation): Resolve all pc-relative
8         loads.
9
10         gas/testsuite/
11         * gas/arm/ldr-global.d: New test.
12         * gas/arm/ldr-global.s: New test.
13
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
18 @@ -0,0 +1,14 @@
19 +#objdump: -dr --prefix-addresses --show-raw-insn
20 +#name: PC-relative LDR from global
21 +
22 +.*: +file format .*arm.*
23 +
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 <[^>]*>
32 +#...
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
37 @@ -0,0 +1,22 @@
38 +@ Test pc-relative loads from global objects defined in the same text segment.
39 +@ See tc-arm.c:arm_force_relocation.
40 +.arch armv7-a
41 +.fpu vfp
42 +.syntax unified
43 +.text
44 +foo_arm:
45 +  ldr r0, bar
46 +  ldrsh r0, bar
47 +  vldr s0, bar
48 +.thumb
49 +foo_thumb:
50 +  ldr r0, bar
51 +  ldr.n r0, bar
52 +  vldr s0, bar
53 +  ldr.w r0, bar
54 +  
55 +.align 2
56 +.globl bar
57 +bar:
58 +  .word 42
59 +
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 @@
65      }
66  #endif
67  
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)
89      return 0;
90  
91    /* Always leave these relocations for the linker.  */