bfd/efl32-arm.c: Fix handling of IRELATIVE relocs.
authorWill Newton <willnewton@sourceware.org>
Mon, 29 Apr 2013 09:48:32 +0000 (09:48 +0000)
committerWill Newton <willnewton@sourceware.org>
Mon, 29 Apr 2013 09:48:32 +0000 (09:48 +0000)
bfd/ChangeLog:

2013-04-24  Will Newton  <will.newton@linaro.org>

* elf32-arm.c (elf32_arm_populate_plt_entry): Call
elf32_arm_add_dynreloc when emitting R_ARM_IRELATIVE relocs.

ld/testsuite/ChangeLog:

2013-04-24  Will Newton  <will.newton@linaro.org>

* ld-arm/arm-elf.exp: Add IFUNC test 17.
* ld-arm/ifunc-17.dd: New file.
* ld-arm/ifunc-17.gd: Likewise.
* ld-arm/ifunc-17.rd: Likewise.
* ld-arm/ifunc-17.s: Likweise.
* ld-arm/ifunc-1.rd: Reorder relocs to match linker output.
* ld-arm/ifunc-2.rd: Likewise.
* ld-arm/ifunc-5.rd: Likewise.
* ld-arm/ifunc-6.rd: Likewise.

12 files changed:
bfd/ChangeLog
bfd/elf32-arm.c
ld/testsuite/ChangeLog
ld/testsuite/ld-arm/arm-elf.exp
ld/testsuite/ld-arm/ifunc-1.rd
ld/testsuite/ld-arm/ifunc-17.dd [new file with mode: 0644]
ld/testsuite/ld-arm/ifunc-17.gd [new file with mode: 0644]
ld/testsuite/ld-arm/ifunc-17.rd [new file with mode: 0644]
ld/testsuite/ld-arm/ifunc-17.s [new file with mode: 0644]
ld/testsuite/ld-arm/ifunc-2.rd
ld/testsuite/ld-arm/ifunc-5.rd
ld/testsuite/ld-arm/ifunc-6.rd

index 14abe010a8fa6f24af800b74d9b0903cb465834b..6c5739a7fa8a02f9a9c9c4044682e52e09e7ed10 100644 (file)
@@ -1,3 +1,8 @@
+2013-04-29  Will Newton  <will.newton@linaro.org>
+
+       * elf32-arm.c (elf32_arm_populate_plt_entry): Call
+       elf32_arm_add_dynreloc when emitting R_ARM_IRELATIVE relocs.
+
 2013-04-29  Will Newton  <will.newton@linaro.org>
 
        * elf64-aarch64.c (elf64_aarch64_check_relocs): Move relocation
index 6201e60735ccb453175ef36e8846637d3d67f4cb..2ed4741b98506dedf8ed0ed9bd77d3feee64c576 100644 (file)
@@ -7699,8 +7699,13 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info,
                  sgot->contents + got_offset);
     }
 
-  loc = srel->contents + plt_index * RELOC_SIZE (htab);
-  SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc);
+  if (dynindx == -1)
+    elf32_arm_add_dynreloc (output_bfd, info, srel, &rel);
+  else
+    {
+      loc = srel->contents + plt_index * RELOC_SIZE (htab);
+      SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc);
+    }
 }
 
 /* Some relocations map to different relocations depending on the
index 0d1e999e45d480d070a32d2290717a6a5a1a7e25..27dae44d1cbba7b0ecfc1749ef2fec0cc21ef317 100644 (file)
@@ -1,3 +1,15 @@
+2013-04-29  Will Newton  <will.newton@linaro.org>
+
+       * ld-arm/arm-elf.exp: Add IFUNC test 17.
+       * ld-arm/ifunc-17.dd: New file.
+       * ld-arm/ifunc-17.gd: Likewise.
+       * ld-arm/ifunc-17.rd: Likewise.
+       * ld-arm/ifunc-17.s: Likweise.
+       * ld-arm/ifunc-1.rd: Reorder relocs to match linker output.
+       * ld-arm/ifunc-2.rd: Likewise.
+       * ld-arm/ifunc-5.rd: Likewise.
+       * ld-arm/ifunc-6.rd: Likewise.
+
 2013-04-29  Will Newton  <will.newton@linaro.org>
 
        * ld-plugin/lto.exp: Disable ld/12942 test for gcc < 4.7.0.
index f13fae57e4e29d139dc650c4c65a38604e483626..c488e3cba8125c099302d91ba8d258d51a04773a 100644 (file)
@@ -451,6 +451,11 @@ set armelftests_nonacl {
       {objdump {-s -j.data -j.got} ifunc-16.gd}
       {readelf -r ifunc-16.rd}}
      "ifunc-16"}
+    {"IFUNC test 17" "" "" "" {ifunc-17.s}
+     {{objdump -d ifunc-17.dd}
+      {objdump {-s -j.data -j.got} ifunc-17.gd}
+      {readelf -r ifunc-17.rd}}
+     "ifunc-17"}
 }
 
 run_ld_link_tests $armelftests_common
index 75e6d700bc0e0ef6f4a6740c80f7cfad99400b77..264412312f68eb89c401777dcc087cb0efc4cbe4 100644 (file)
@@ -4,5 +4,5 @@ There is no dynamic section in this file\.
 Relocation section '\.rel\.dyn' at offset 0x8000 contains 3 entries:
  Offset     Info    Type            Sym\.Value  Sym\. Name
 0001100c  ......a0 R_ARM_IRELATIVE  
-00011010  ......a0 R_ARM_IRELATIVE  
 00011014  ......a0 R_ARM_IRELATIVE  
+00011010  ......a0 R_ARM_IRELATIVE  
diff --git a/ld/testsuite/ld-arm/ifunc-17.dd b/ld/testsuite/ld-arm/ifunc-17.dd
new file mode 100644 (file)
index 0000000..f23a249
--- /dev/null
@@ -0,0 +1,25 @@
+
+.*
+
+
+Disassembly of section \.iplt:
+
+00008084 <.iplt>:
+#------------------------------------------------------------------------------
+#------ appfunc1's .iplt entry
+#------------------------------------------------------------------------------
+    8084:      e28fc600        add     ip, pc, #0, 12
+    8088:      e28cca08        add     ip, ip, #8, 20  ; 0x8000
+    808c:      e5bcf01c        ldr     pc, \[ip, #28\]!
+
+Disassembly of section \.text:
+
+00008090 <appfunc1>:
+    8090:      46f7            mov     pc, lr
+
+00008092 <appfunc2>:
+    8092:      46f7            mov     pc, lr
+
+00008094 <_start>:
+    8094:      f7ff eff6       blx     8084 <appfunc1-0xc>
+    8098:      00000010        \.word  0x00000010
diff --git a/ld/testsuite/ld-arm/ifunc-17.gd b/ld/testsuite/ld-arm/ifunc-17.gd
new file mode 100644 (file)
index 0000000..4a12eb8
--- /dev/null
@@ -0,0 +1,10 @@
+
+.*
+
+Contents of section \.got:
+#------------------------------------------------------------------------------
+#------ 000100a8: 0x8091 (appfunc1)
+#------ 000100ac: 0x8093 (appfunc2)
+#------------------------------------------------------------------------------
+ 1009c 00000000 00000000 00000000 91800000  .*
+ 100ac 93800000                             .*
diff --git a/ld/testsuite/ld-arm/ifunc-17.rd b/ld/testsuite/ld-arm/ifunc-17.rd
new file mode 100644 (file)
index 0000000..a93fd64
--- /dev/null
@@ -0,0 +1,5 @@
+
+Relocation section '\.rel\.dyn' at offset 0x74 contains 2 entries:
+ Offset     Info    Type            Sym\.Value  Sym\. Name
+000100a8  ......a0 R_ARM_IRELATIVE  
+000100ac  ......a0 R_ARM_IRELATIVE  
diff --git a/ld/testsuite/ld-arm/ifunc-17.s b/ld/testsuite/ld-arm/ifunc-17.s
new file mode 100644 (file)
index 0000000..75c4c56
--- /dev/null
@@ -0,0 +1,24 @@
+       .syntax unified
+       .arch armv6t2
+
+       .global appfunc1
+       .type   appfunc1,%gnu_indirect_function
+       .thumb
+appfunc1:
+       mov     pc,lr
+       .size   appfunc1,.-appfunc1
+
+       .global appfunc2
+       .type   appfunc2,%gnu_indirect_function
+       .thumb
+appfunc2:
+       mov     pc,lr
+       .size   appfunc2,.-appfunc2
+
+       .global _start
+       .type _start,%function
+       .thumb
+_start:
+       bl      appfunc1(PLT)
+       .word   appfunc2(GOT)
+       .size   _start,.-_start
index 92b000a86f59cefc5caa459760c724b4e6801e0a..7bbabf421f3686c5f32d4894a4ff0644c431a320 100644 (file)
@@ -5,9 +5,9 @@ Relocation section '\.rel\.dyn' at offset 0x8000 contains 8 entries:
  Offset     Info    Type            Sym\.Value  Sym\. Name
 0001100c  ......a0 R_ARM_IRELATIVE  
 00011010  ......a0 R_ARM_IRELATIVE  
+00011020  ......a0 R_ARM_IRELATIVE  
+00011028  ......a0 R_ARM_IRELATIVE  
 00011014  ......a0 R_ARM_IRELATIVE  
 00011018  ......a0 R_ARM_IRELATIVE  
 0001101c  ......a0 R_ARM_IRELATIVE  
-00011020  ......a0 R_ARM_IRELATIVE  
 00011024  ......a0 R_ARM_IRELATIVE  
-00011028  ......a0 R_ARM_IRELATIVE  
index 75e6d700bc0e0ef6f4a6740c80f7cfad99400b77..264412312f68eb89c401777dcc087cb0efc4cbe4 100644 (file)
@@ -4,5 +4,5 @@ There is no dynamic section in this file\.
 Relocation section '\.rel\.dyn' at offset 0x8000 contains 3 entries:
  Offset     Info    Type            Sym\.Value  Sym\. Name
 0001100c  ......a0 R_ARM_IRELATIVE  
-00011010  ......a0 R_ARM_IRELATIVE  
 00011014  ......a0 R_ARM_IRELATIVE  
+00011010  ......a0 R_ARM_IRELATIVE  
index 0fbfec5905dda5df06b64bc24ec2ee9d68f0e0ae..04c18a926f616f91b4867e8deb430e2a397deddd 100644 (file)
@@ -3,7 +3,7 @@ There is no dynamic section in this file\.
 
 Relocation section '\.rel\.dyn' at offset 0x8000 contains 4 entries:
  Offset     Info    Type            Sym\.Value  Sym\. Name
-0001100c  ......a0 R_ARM_IRELATIVE  
+00011018  ......a0 R_ARM_IRELATIVE  
 00011010  ......a0 R_ARM_IRELATIVE  
+0001100c  ......a0 R_ARM_IRELATIVE  
 00011014  ......a0 R_ARM_IRELATIVE  
-00011018  ......a0 R_ARM_IRELATIVE