aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-03-25 15:12:48 +1030
committerAlan Modra <amodra@gmail.com>2014-03-27 00:49:38 +1030
commitf6c7c3e8b742de0a5926e6a2c268f5803062b556 (patch)
tree1b55c1a26ea275cc79b47a2dd1bb82727047b837 /ld/testsuite
parent0d4d0e772ac36d169d21951c46b0778ae7fa8d53 (diff)
downloadgdb-f6c7c3e8b742de0a5926e6a2c268f5803062b556.zip
gdb-f6c7c3e8b742de0a5926e6a2c268f5803062b556.tar.gz
gdb-f6c7c3e8b742de0a5926e6a2c268f5803062b556.tar.bz2
Referencing a function's address on PowerPC64 ELFv2
ELFv2 needs to create plt entries in a non-PIC executable for an address reference to a function defined in a shared object. It's possible that an object file has no features that distinguish it as ELFv1 or ELFv2, eg. an object only containing data. Such files need to be handled like those that are known to be ELFv2. However, this unnecessarily creates plt entries for the analogous ELFv1 case, so arrange to set output abi version earlier, and use the output abi version to further distinguish ambiguous input files. bfd/ * elf64-ppc.c (ppc64_elf_check_relocs): Account for possibly needed plt entries when taking the address of functions for abiversion == 0 (ie. unknown) as well as abiversion == 2. Move opd setup and abiversion checks to.. (ppc64_elf_before_check_relocs): ..here. Renamed from ppc64_elf_process_dot_syms. Set output abiversion from input and input abiversion from output, if either is not set. (ppc64_elf_merge_private_bfd_data): Don't merge flags here. (elf_backend_check_directives): Update. ld/testsuite/ * ld-powerpc/startv1.s, * ld-powerpc/startv2.s, * ld-powerpc/funref.s, * ld-powerpc/funv1.s, * ld-powerpc/funv2.s, * ld-powerpc/ambiguousv1.d, * ld-powerpc/ambiguousv2.d: New test files. * ld-powerpc/powerpc.exp: Run new tests.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ChangeLog7
-rw-r--r--ld/testsuite/ld-powerpc/ambiguousv1.d12
-rw-r--r--ld/testsuite/ld-powerpc/ambiguousv2.d12
-rw-r--r--ld/testsuite/ld-powerpc/funref.s4
-rw-r--r--ld/testsuite/ld-powerpc/funv1.s10
-rw-r--r--ld/testsuite/ld-powerpc/funv2.s6
-rw-r--r--ld/testsuite/ld-powerpc/powerpc.exp4
-rw-r--r--ld/testsuite/ld-powerpc/startv1.s8
-rw-r--r--ld/testsuite/ld-powerpc/startv2.s5
9 files changed, 68 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index d200277..279958e 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2014-03-26 Alan Modra <amodra@gmail.com>
+
+ * ld-powerpc/startv1.s, * ld-powerpc/startv2.s, * ld-powerpc/funref.s,
+ * ld-powerpc/funv1.s, * ld-powerpc/funv2.s,
+ * ld-powerpc/ambiguousv1.d, * ld-powerpc/ambiguousv2.d: New test files.
+ * ld-powerpc/powerpc.exp: Run new tests.
+
2014-03-25 Will Newton <will.newton@linaro.org>
* ld-aarch64/aarch64-elf.exp: Add relasz dump test.
diff --git a/ld/testsuite/ld-powerpc/ambiguousv1.d b/ld/testsuite/ld-powerpc/ambiguousv1.d
new file mode 100644
index 0000000..73beab9
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/ambiguousv1.d
@@ -0,0 +1,12 @@
+#source: startv1.s
+#source: funref.s
+#as: -a64
+#ld: -melf64ppc
+#ld_after_inputfiles: tmpdir/funv1.so
+#readelf: -r --wide
+# check that we do the right thing with funref.s that doesn't have
+# anything to mark it as ELFv1 or ELFv2
+
+Relocation section .* contains 1 entries:
+.*
+.* R_PPC64_ADDR64 +0+ my_func \+ 0
diff --git a/ld/testsuite/ld-powerpc/ambiguousv2.d b/ld/testsuite/ld-powerpc/ambiguousv2.d
new file mode 100644
index 0000000..5cf047b
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/ambiguousv2.d
@@ -0,0 +1,12 @@
+#source: startv2.s
+#source: funref.s
+#as: -a64
+#ld: -melf64ppc
+#ld_after_inputfiles: tmpdir/funv2.so
+#readelf: -r --wide
+# check that we do the right thing with funref.s that doesn't have
+# anything to mark it as ELFv1 or ELFv2
+
+Relocation section .*contains 1 entries:
+.*
+.* R_PPC64_JMP_SLOT .* my_func \+ 0
diff --git a/ld/testsuite/ld-powerpc/funref.s b/ld/testsuite/ld-powerpc/funref.s
new file mode 100644
index 0000000..3f7de47
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/funref.s
@@ -0,0 +1,4 @@
+ .data
+ .globl func_tab
+func_tab:
+ .dc.a my_func
diff --git a/ld/testsuite/ld-powerpc/funv1.s b/ld/testsuite/ld-powerpc/funv1.s
new file mode 100644
index 0000000..e79009d
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/funv1.s
@@ -0,0 +1,10 @@
+ .globl my_func
+ .type my_func,@function
+ .section .opd,"aw",@progbits
+my_func:
+ .quad .Lmy_func, .TOC.@tocbase
+
+ .text
+.Lmy_func:
+ blr
+ .size my_func,.-.Lmy_func
diff --git a/ld/testsuite/ld-powerpc/funv2.s b/ld/testsuite/ld-powerpc/funv2.s
new file mode 100644
index 0000000..eaff0b3
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/funv2.s
@@ -0,0 +1,6 @@
+ .abiversion 2
+ .globl my_func
+ .type my_func,@function
+my_func:
+ blr
+ .size my_func,.-my_func
diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp
index 8a60eb7..1eaedaa 100644
--- a/ld/testsuite/ld-powerpc/powerpc.exp
+++ b/ld/testsuite/ld-powerpc/powerpc.exp
@@ -212,6 +212,8 @@ set ppc64elftests {
{tocopt4a.s tocopt4b.s} {{objdump -s tocopt4.d}} "tocopt4"}
{"TOC opt5" "-melf64ppc" "" "-a64" {tocopt5.s}
{{objdump -s tocopt5.d}} "tocopt5"}
+ {"ambig shared v1" "-shared -melf64ppc" "" "-a64" {funv1.s} {} "funv1.so"}
+ {"ambig shared v2" "-shared -melf64ppc" "" "-a64" {funv2.s} {} "funv2.so"}
}
set ppceabitests {
@@ -272,6 +274,8 @@ if [ supports_ppc64 ] then {
run_dump_test "elfv2exe"
run_dump_test "elfv2-2so"
run_dump_test "elfv2-2exe"
+ run_dump_test "ambiguousv1"
+ run_dump_test "ambiguousv2"
}
if { [istarget "powerpc*-eabi*"] } {
diff --git a/ld/testsuite/ld-powerpc/startv1.s b/ld/testsuite/ld-powerpc/startv1.s
new file mode 100644
index 0000000..c54e1b0
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/startv1.s
@@ -0,0 +1,8 @@
+ .globl _start
+ .section .opd,"aw",@progbits
+_start:
+ .quad .L_start, .TOC.@tocbase
+
+ .text
+.L_start:
+ b _start
diff --git a/ld/testsuite/ld-powerpc/startv2.s b/ld/testsuite/ld-powerpc/startv2.s
new file mode 100644
index 0000000..7187aa5
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/startv2.s
@@ -0,0 +1,5 @@
+ .abiversion 2
+ .text
+ .globl _start
+_start:
+ b _start