]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2009-06-22 Christophe Lyon <christophe.lyon@st.com>
authorChristophe Lyon <christophe.lyon@st.com>
Mon, 22 Jun 2009 10:55:33 +0000 (10:55 +0000)
committerChristophe Lyon <christophe.lyon@st.com>
Mon, 22 Jun 2009 10:55:33 +0000 (10:55 +0000)
bfd/
* elf32-arm.c (elf32_arm_size_stubs): Use PLT address as
destination for defined dynamic symbols when deciding whether to
insert a stub or not.
(allocate_dynrelocs): Make sure functions are not marked as Thumb
when actually accessed through a PLT, even when generating a
shared lib.

ld/testsuite:
* ld-arm/farcall-mixed-app.s: Add new references to check more
modes switching.
* ld-arm/farcall-mixed-lib1.s: Likewise.
* ld-arm/farcall-mixed-app-v5.d: Update expected result.
* farcall-mixed-app.d: Likewise.
* ld-arm/farcall-mixed-lib.d: Likewise.

bfd/ChangeLog
bfd/elf32-arm.c
ld/testsuite/ChangeLog
ld/testsuite/ld-arm/farcall-mixed-app-v5.d
ld/testsuite/ld-arm/farcall-mixed-app.d
ld/testsuite/ld-arm/farcall-mixed-app.s
ld/testsuite/ld-arm/farcall-mixed-lib.d
ld/testsuite/ld-arm/farcall-mixed-lib1.s

index 7e7b526d370b116560d9a4314d79a10b624fff97..563f454ec2ee8c18bdf76aa22c60b68ddd3f184c 100644 (file)
@@ -1,3 +1,12 @@
+2009-06-22  Christophe Lyon  <christophe.lyon@st.com>
+
+       * elf32-arm.c (elf32_arm_size_stubs): Use PLT address as
+       destination for defined dynamic symbols when deciding whether to
+       insert a stub or not.
+       (allocate_dynrelocs): Make sure functions are not marked as Thumb
+       when actually accessed through a PLT, even when generating a
+       shared lib.
+
 2009-06-22  Tristan Gingold  <gingold@adacore.com>
 
        * mach-o.c (bfd_mach_o_canonicalize_reloc): Append a sentinel to
index bdb895af6008f698aa7bd3e03965be7ab9ddfa6c..cd40eefbf5c52e3d108ca01b5e0666fab066fb65 100644 (file)
@@ -4361,7 +4361,25 @@ elf32_arm_size_stubs (bfd *output_bfd,
                        {
                          sym_sec = hash->root.root.u.def.section;
                          sym_value = hash->root.root.u.def.value;
-                         if (sym_sec->output_section != NULL)
+
+                         struct elf32_arm_link_hash_table *globals =
+                                                 elf32_arm_hash_table (info);
+
+                         /* For a destination in a shared library,
+                            use the PLT stub as target address to
+                            decide whether a branch stub is
+                            needed.  */
+                         if (globals->splt != NULL && hash != NULL
+                             && hash->root.plt.offset != (bfd_vma) -1)
+                           {
+                             sym_sec = globals->splt;
+                             sym_value = hash->root.plt.offset;
+                             if (sym_sec->output_section != NULL)
+                               destination = (sym_value
+                                              + sym_sec->output_offset
+                                              + sym_sec->output_section->vma);
+                           }
+                         else if (sym_sec->output_section != NULL)
                            destination = (sym_value + irela->r_addend
                                           + sym_sec->output_offset
                                           + sym_sec->output_section->vma);
@@ -11277,14 +11295,14 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
            {
              h->root.u.def.section = s;
              h->root.u.def.value = h->plt.offset;
-
-             /* Make sure the function is not marked as Thumb, in case
-                it is the target of an ABS32 relocation, which will
-                point to the PLT entry.  */
-             if (ELF_ST_TYPE (h->type) == STT_ARM_TFUNC)
-               h->type = ELF_ST_INFO (ELF_ST_BIND (h->type), STT_FUNC);
            }
 
+         /* Make sure the function is not marked as Thumb, in case
+            it is the target of an ABS32 relocation, which will
+            point to the PLT entry.  */
+         if (ELF_ST_TYPE (h->type) == STT_ARM_TFUNC)
+           h->type = ELF_ST_INFO (ELF_ST_BIND (h->type), STT_FUNC);
+
          /* Make room for this entry.  */
          s->size += htab->plt_entry_size;
 
index 9b4ea2d63d1ec4a4f419124b479abf4ee7f3890d..0c3ad41d950a1602d0e7bb806fa009d85982f500 100644 (file)
@@ -1,3 +1,13 @@
+2009-06-22  Christophe Lyon  <christophe.lyon@st.com>
+
+       ld/testsuite:
+       * ld-arm/farcall-mixed-app.s: Add new references to check more
+       modes switching.
+       * ld-arm/farcall-mixed-lib1.s: Likewise.
+       * ld-arm/farcall-mixed-app-v5.d: Update expected result.
+       * farcall-mixed-app.d: Likewise.
+       * ld-arm/farcall-mixed-lib.d: Likewise.
+
 2009-06-22  Dave Korn  <dave.korn.cygwin@gmail.com>
 
        * ld-pe/pe-run.exp (proc test_direct_link_dll):  Fix incorrect
index ba6c77deebb14807a771caccc1bccd7bfd8bcdd8..d34a686f99d81889a75d05a9e102298c6039c5cd 100644 (file)
@@ -25,11 +25,11 @@ Disassembly of section .text:
  .*:   e1a0c00d        mov     ip, sp
  .*:   e92dd800        push    {fp, ip, lr, pc}
  .*:   eb000008        bl      .* <__app_func_veneer>
+ .*:   ebfffff8        bl      .* <_start-0xc>
+ .*:   ebfffff4        bl      .* <_start-0x18>
  .*:   e89d6800        ldm     sp, {fp, sp, lr}
  .*:   e12fff1e        bx      lr
  .*:   e1a00000        nop                     \(mov r0,r0\)
- .*:   e1a00000        nop                     \(mov r0,r0\)
- .*:   e1a00000        nop                     \(mov r0,r0\)
 
 .* <app_tfunc_close>:
  .*:   b500            push    {lr}
@@ -49,12 +49,12 @@ Disassembly of section .far_arm:
 .* <app_func>:
  .*:   e1a0c00d        mov     ip, sp
  .*:   e92dd800        push    {fp, ip, lr, pc}
- .*:   eb000008        bl      .* <__lib_func1_veneer>
+ .*:   eb00000a        bl      .* <__lib_func1_veneer>
+ .*:   eb000007        bl      .* <__lib_func2_veneer>
  .*:   e89d6800        ldm     sp, {fp, sp, lr}
  .*:   e12fff1e        bx      lr
  .*:   e1a00000        nop                     \(mov r0,r0\)
  .*:   e1a00000        nop                     \(mov r0,r0\)
- .*:   e1a00000        nop                     \(mov r0,r0\)
 
 .* <app_func2>:
  .*:   e12fff1e        bx      lr
@@ -62,8 +62,11 @@ Disassembly of section .far_arm:
  .*:   e1a00000        nop                     \(mov r0,r0\)
  .*:   e1a00000        nop                     \(mov r0,r0\)
 
+.* <__lib_func2_veneer>:
+ .*:   e51ff004        ldr     pc, \[pc, #-4\] ; 2100034 <__lib_func2_veneer\+0x4>
+ .*:   00008218        .word   0x00008218
 .* <__lib_func1_veneer>:
- .*:   e51ff004        ldr     pc, \[pc, #-4\] ; 2100034 <__lib_func1_veneer\+0x4>
+ .*:   e51ff004        ldr     pc, \[pc, #-4\] ; 210003c <__lib_func1_veneer\+0x4>
  .*:   00008224        .word   0x00008224
 
 Disassembly of section .far_thumb:
index df565e6c96cbe585868133b50c7d1a5de4541a37..fac7037ce311f35488f025146c4b76ddc2b4509e 100644 (file)
@@ -27,11 +27,11 @@ Disassembly of section .text:
  .*:   e1a0c00d        mov     ip, sp
  .*:   e92dd800        push    {fp, ip, lr, pc}
  .*:   eb000008        bl      .* <__app_func_veneer>
+ .*:   ebfffff5        bl      .* <_start-0x18>
+ .*:   ebfffff1        bl      .* <_start-0x24>
  .*:   e89d6800        ldm     sp, {fp, sp, lr}
  .*:   e12fff1e        bx      lr
  .*:   e1a00000        nop                     \(mov r0,r0\)
- .*:   e1a00000        nop                     \(mov r0,r0\)
- .*:   e1a00000        nop                     \(mov r0,r0\)
 
 .* <app_tfunc_close>:
  .*:   b500            push    {lr}
@@ -51,12 +51,12 @@ Disassembly of section .far_arm:
 .* <app_func>:
  .*:   e1a0c00d        mov     ip, sp
  .*:   e92dd800        push    {fp, ip, lr, pc}
- .*:   eb000008        bl      .* <__lib_func1_veneer>
+ .*:   eb00000a        bl      .* <__lib_func1_veneer>
+ .*:   eb000007        bl      .* <__lib_func2_veneer>
  .*:   e89d6800        ldm     sp, {fp, sp, lr}
  .*:   e12fff1e        bx      lr
  .*:   e1a00000        nop                     \(mov r0,r0\)
  .*:   e1a00000        nop                     \(mov r0,r0\)
- .*:   e1a00000        nop                     \(mov r0,r0\)
 
 .* <app_func2>:
  .*:   e12fff1e        bx      lr
@@ -64,8 +64,11 @@ Disassembly of section .far_arm:
  .*:   e1a00000        nop                     \(mov r0,r0\)
  .*:   e1a00000        nop                     \(mov r0,r0\)
 
+.* <__lib_func2_veneer>:
+ .*:   e51ff004        ldr     pc, \[pc, #-4\] ; 2100034 <__lib_func2_veneer\+0x4>
+ .*:   0000821c        .word   0x0000821c
 .* <__lib_func1_veneer>:
- .*:   e51ff004        ldr     pc, \[pc, #-4\] ; 2100034 <__lib_func1_veneer\+0x4>
+ .*:   e51ff004        ldr     pc, \[pc, #-4\] ; 210003c <__lib_func1_veneer\+0x4>
  .*:   00008228        .word   0x00008228
 
 Disassembly of section .far_thumb:
index 78d5f652098db58e3ac634cd92a13189e82369ee..e462ba36260eb4dd190e29839f6c6f7c3bfe2a2f 100644 (file)
@@ -5,6 +5,8 @@ _start:
        mov     ip, sp
        stmdb   sp!, {r11, ip, lr, pc}
        bl      app_func
+       bl      lib_func1
+       bl      lib_func2
        ldmia   sp, {r11, sp, lr}
        bx lr
 
@@ -30,6 +32,7 @@ app_func:
        mov     ip, sp
        stmdb   sp!, {r11, ip, lr, pc}
        bl      lib_func1
+       bl      lib_func2
        ldmia   sp, {r11, sp, lr}
        bx lr
 
index 829db457faa8225f9c8f77f82e382eda95d7cab0..18e7ef08fbb489ddb7f49248d7aa9bdd891ba6cb 100644 (file)
@@ -17,6 +17,13 @@ Disassembly of section .plt:
  .*:   e28fc6.*        add     ip, pc, #.*     ; 0x.*
  .*:   e28cca.*        add     ip, ip, #.*     ; 0x.*
  .*:   e5bcf.*         ldr     pc, \[ip, #.*\]!
+ .*:   e28fc6.*        add     ip, pc, #.*     ; 0x.*
+ .*:   e28cca.*        add     ip, ip, #.*     ; 0x.*
+ .*:   e5bcf.*         ldr     pc, \[ip, #.*\]!
+ .*:   e28fc6.*        add     ip, pc, #.*     ; 0x.*
+ .*:   e28cca.*        add     ip, ip, #.*     ; 0x.*
+ .*:   e5bcf.*         ldr     pc, \[ip, #.*\]!
+
 Disassembly of section .text:
 
 .* <lib_func1>:
@@ -24,46 +31,62 @@ Disassembly of section .text:
  .*:   e92dd800        push    {fp, ip, lr, pc}
  .*:   ebfffff.        bl      .* <lib_func1-0x..?>
  .*:   ebfffff.        bl      .* <lib_func1-0x..?>
+ .*:   ebfffff.        bl      .* <lib_func1-0x..?>
+ .*:   ebfffff.        bl      .* <lib_func1-0x..?>
  .*:   e89d6800        ldm     sp, {fp, sp, lr}
  .*:   e12fff1e        bx      lr
        ...
- .*:   e1a00000        .word   0xe1a00000
- .*:   e1a00000        .word   0xe1a00000
 
 .* <lib_func2>:
- .*:   f000 e806       blx     1000300 <__app_func_from_thumb>
- .*:   f000 e80a       blx     100030c <__app_func_weak_from_thumb>
+ .*:   f000 e80e       blx     1000350 <__app_func_from_thumb>
+ .*:   f000 e818       blx     1000368 <__app_func_weak_from_thumb>
+ .*:   f000 e810       blx     100035c <__lib_func3_from_thumb>
+ .*:   f000 e81a       blx     1000374 <__lib_func4_from_thumb>
  .*:   4770            bx      lr
  .*:   46c0            nop                     \(mov r8, r8\)
  .*:   46c0            nop                     \(mov r8, r8\)
  .*:   46c0            nop                     \(mov r8, r8\)
+ .*:   46c0            nop                     \(mov r8, r8\)
+ .*:   46c0            nop                     \(mov r8, r8\)
+ .*:   46c0            nop                     \(mov r8, r8\)
+ .*:   46c0            nop                     \(mov r8, r8\)
 
 .* <__app_func_from_thumb>:
- .*:   e59fc000        ldr     ip, \[pc, #0\]  ; 1000308 <__app_func_from_thumb\+0x8>
+ .*:   e59fc000        ldr     ip, \[pc, #0\]  ; 1000358 <__app_func_from_thumb\+0x8>
  .*:   e08ff00c        add     pc, pc, ip
- .*:   feffffa8        .word   0xfeffffa8
+ .*:   feffff84        .word   0xfeffff84
+
+.* <__lib_func3_from_thumb>:
+ .*:   e59fc000        ldr     ip, \[pc, #0\]  ; 1000364 <__lib_func3_from_thumb\+0x8>
+ .*:   e08ff00c        add     pc, pc, ip
+ .*:   feffff90        .word   0xfeffff90
 
 .* <__app_func_weak_from_thumb>:
- .*:   e59fc000        ldr     ip, \[pc, #0\]  ; 1000314 <__app_func_weak_from_thumb\+0x8>
+ .*:   e59fc000        ldr     ip, \[pc, #0\]  ; 1000370 <__app_func_weak_from_thumb\+0x8>
+ .*:   e08ff00c        add     pc, pc, ip
+ .*:   feffff78        .word   0xfeffff78
+
+.* <__lib_func4_from_thumb>:
+ .*:   e59fc000        ldr     ip, \[pc, #0\]  ; 100037c <__lib_func4_from_thumb\+0x8>
  .*:   e08ff00c        add     pc, pc, ip
- .*:   feffffa8        .word   0xfeffffa8
+ .*:   feffff84        .word   0xfeffff84
        ...
 
 .* <lib_func3>:
- .*:   f000 e80c       blx     200033c <__app_func_from_thumb>
- .*:   f000 e804       blx     2000330 <__app_func_weak_from_thumb>
+ .*:   f000 e80c       blx     20003ac <__app_func_from_thumb>
+ .*:   f000 e804       blx     20003a0 <__app_func_weak_from_thumb>
  .*:   4770            bx      lr
  .*:   46c0            nop                     \(mov r8, r8\)
  .*:   46c0            nop                     \(mov r8, r8\)
  .*:   46c0            nop                     \(mov r8, r8\)
 
 .* <__app_func_weak_from_thumb>:
- .*:   e59fc000        ldr     ip, \[pc, #0\]  ; 2000338 <__app_func_weak_from_thumb\+0x8>
+ .*:   e59fc000        ldr     ip, \[pc, #0\]  ; 20003a8 <__app_func_weak_from_thumb\+0x8>
  .*:   e08ff00c        add     pc, pc, ip
- .*:   fdffff84        .word   0xfdffff84
+ .*:   fdffff40        .word   0xfdffff40
 
 .* <__app_func_from_thumb>:
- .*:   e59fc000        ldr     ip, \[pc, #0\]  ; 2000344 <__app_func_from_thumb\+0x8>
+ .*:   e59fc000        ldr     ip, \[pc, #0\]  ; 20003b4 <__app_func_from_thumb\+0x8>
  .*:   e08ff00c        add     pc, pc, ip
- .*:   fdffff6c        .word   0xfdffff6c
+ .*:   fdffff28        .word   0xfdffff28
        ...
index a64c0bbbb5db73be4b1ef961437cea3b374958cb..f13e71727154c6921ec2b610b4b0111c1543e65c 100644 (file)
@@ -14,6 +14,8 @@ lib_func1:
        bl      app_func
        .weak   app_func_weak
        bl      app_func_weak
+       bl      lib_func3
+       bl      lib_func4
        ldmia   sp, {r11, sp, lr}
        bx lr
        .size lib_func1, . - lib_func1
@@ -27,5 +29,7 @@ lib_func1:
 lib_func2:
        bl      app_func
        bl      app_func_weak
+       bl      lib_func3
+       bl      lib_func4
        bx lr
        .size lib_func2, . - lib_func2