aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-arm
diff options
context:
space:
mode:
authorRoland McGrath <mcgrathr@google.com>2014-08-20 10:12:57 -0700
committerRoland McGrath <mcgrathr@google.com>2014-08-20 10:12:57 -0700
commit469a34932ae4208240e98c843b01ea1f00892137 (patch)
tree5ec5e106992782cd4b6b7ff1451ede29dd4875fa /ld/testsuite/ld-arm
parent01e6c1a48d2c56a5e8a78f54b3b2021da42257e7 (diff)
downloadgdb-469a34932ae4208240e98c843b01ea1f00892137.zip
gdb-469a34932ae4208240e98c843b01ea1f00892137.tar.gz
gdb-469a34932ae4208240e98c843b01ea1f00892137.tar.bz2
Fix PR ld/17277: bogus dynamic relocs and TEXTREL for ARM PC-relative relocs
bfd/ PR ld/17277 * elf32-arm.c (elf32_arm_check_relocs): Increment P->pc_count for all reloc types with pc_relative set in the howto, not just for R_ARM_REL32 and R_ARM_REL32_NOI. (allocate_dynrelocs_for_symbol): Update comment. (elf32_arm_gc_sweep_hook): For all reloc types with pc_relative set in the howto, set call_reloc_p and may_need_local_target_p but not may_become_dynamic_p; not only for R_ARM_REL32 and R_ARM_REL32_NOI. (elf32_arm_check_relocs): Likewise. ld/testsuite/ PR ld/17277 * ld-arm/pcrel-shared.s: New file. * ld-arm/pcrel-shared.rd: New file. * ld-arm/arm-elf.exp (armelftests_common): Add it.
Diffstat (limited to 'ld/testsuite/ld-arm')
-rw-r--r--ld/testsuite/ld-arm/arm-elf.exp4
-rw-r--r--ld/testsuite/ld-arm/pcrel-shared.rd16
-rw-r--r--ld/testsuite/ld-arm/pcrel-shared.s25
3 files changed, 45 insertions, 0 deletions
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
index 0576847..677e7b2 100644
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -203,6 +203,10 @@ set armelftests_common {
{"EABI ABI flags ld -r" "-r" "" "-mfloat-abi=soft -meabi=5" {eabi-soft-float.s}
{{readelf -h eabi-soft-float-r.d}}
"eabi-soft-float-r.o"}
+ {"PC-relative in -shared" "-shared" ""
+ "" {pcrel-shared.s}
+ {{readelf -dr pcrel-shared.rd}}
+ "pcrel-shared.so"}
}
set armelftests_nonacl {
diff --git a/ld/testsuite/ld-arm/pcrel-shared.rd b/ld/testsuite/ld-arm/pcrel-shared.rd
new file mode 100644
index 0000000..f371664
--- /dev/null
+++ b/ld/testsuite/ld-arm/pcrel-shared.rd
@@ -0,0 +1,16 @@
+Dynamic section at offset 0x[0-9a-f]+ contains \d+ entries:
+\s+Tag\s+Type\s+Name/Value
+\s*0x[0-9a-f]+ \(HASH\).*
+\s*0x[0-9a-f]+ \(STRTAB\).*
+\s*0x[0-9a-f]+ \(SYMTAB\).*
+\s*0x[0-9a-f]+ \(STRSZ\).*
+\s*0x[0-9a-f]+ \(SYMENT\).*
+# Specifically want *not* to see here:
+# (REL)
+# (RELSZ)
+# (RELENT)
+# (TEXTREL)
+#...
+\s*0x[0-9a-f]+ \(NULL\).*
+
+There are no relocations in this file\.
diff --git a/ld/testsuite/ld-arm/pcrel-shared.s b/ld/testsuite/ld-arm/pcrel-shared.s
new file mode 100644
index 0000000..a2ad0b2
--- /dev/null
+++ b/ld/testsuite/ld-arm/pcrel-shared.s
@@ -0,0 +1,25 @@
+# This tests PR ld/17277, wherein ld -shared for cross-section PC-relative
+# relocs (other than plain R_ARM_REL32, as in data) produce bogus dynamic
+# relocs and TEXTREL markers.
+
+ .syntax unified
+ .arm
+ .arch armv7-a
+
+ .text
+ .globl foo
+ .type foo,%function
+foo: movw r0, #:lower16:symbol - 1f - 8
+ movt r0, #:upper16:symbol - 1f - 8
+1: add r0, pc
+ @ And now a case with a local symbol.
+ movw r0, #:lower16:3f - 2f - 8
+ movt r0, #:upper16:3f - 2f - 8
+2: add r0, pc
+ bx lr
+
+.data
+ .globl symbol
+ .hidden symbol
+symbol: .long 23
+3: .long 17