aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-powerpc
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2016-12-03 21:00:01 +1030
committerAlan Modra <amodra@gmail.com>2016-12-03 21:00:01 +1030
commit8c5b4e5228ec94923fbdfb0008926b0b2a3f51c2 (patch)
tree609d1d4f5f5f0db079c91b00c8806f818e419076 /ld/testsuite/ld-powerpc
parent4e95fbcd79b84308417fc25ce12cacdb2a61c0d0 (diff)
downloadgdb-8c5b4e5228ec94923fbdfb0008926b0b2a3f51c2.zip
gdb-8c5b4e5228ec94923fbdfb0008926b0b2a3f51c2.tar.gz
gdb-8c5b4e5228ec94923fbdfb0008926b0b2a3f51c2.tar.bz2
PowerPC64 dot-symbol compatibility bugfixes
Lots of fixes for the compatibility code that handles linking of -mcall-aixdesc code (or that generated by 12 year old gcc) with current ELFv1 ABI code. 1) A reference to a dot-symbol in an object file wasn't satisfied by a function descriptor in later object files. 2) The as-needed code had bit-rotted; Shared libs now need a strong reference to be counted as needed. 3) --gc-sections involving dot-symbols was broken, needing func_desc_adjust to be run early and lots of other fixes. bfd/ * elf64-ppc.c (struct ppc_link_hash_entry): Delete "was_undefined". (struct ppc_link_hash_table): Delete "twiddled_syms". Add "need_func_desc_adj". (lookup_fdh): Link direct fdh sym via oh field and set flags. (make_fdh): Make strong and weak undefined function descriptor symbols. (ppc64_elf_merge_symbol): New function. (elf_backend_merge_symbol): Define. (ppc64_elf_archive_symbol_lookup): Don't test undefweak for fake function descriptors. (add_symbol_adjust): Don't twiddle symbols to undefweak. Propagate more ref flags to function descriptor symbol. Make some function descriptor symbols dynamic. (ppc64_elf_before_check_relocs): Only run add_symbol_adjust for ELFv1. Set need_func_desc_adj. Don't fix undefs list. (ppc64_elf_check_relocs): Set non_ir_ref for descriptors. Don't call lookup_fdh here. (ppc64_elf_gc_sections): New function. (bfd_elf64_bfd_gc_sections): Define. (ppc64_elf_gc_mark_hook): Mark descriptor. (func_desc_adjust): Don't make fake function descriptor syms strong here. Exit earlier on non-dotsyms. Take note of elf.dynamic flag when deciding whether a dynamic function descriptor might be needed. Transfer elf.dynamic and set elf.needs_plt. Move plt regardless of visibility. Make descriptor dynamic if entry sym is dynamic, not for other cases. (ppc64_elf_func_desc_adjust): Don't run func_desc_adjust if already done. (ppc64_elf_edit_opd): Use oh field rather than lookup_fdh. (ppc64_elf_size_stubs): Likewise. (ppc_build_one_stub): Don't clear was_undefined. Only set sym undefweak if stub symbol is defined. (undo_symbol_twiddle, ppc64_elf_restore_symbols): Delete. * elf64-ppc.h (ppc64_elf_restore_symbols): Don't declare. ld/ * emultempl/ppc64elf.em (gld${EMULATION_NAME}_finish): Don't call ppc64_elf_restore_symbols. * testsuite/ld-powerpc/dotsym1.d: New. * testsuite/ld-powerpc/dotsym2.d: New. * testsuite/ld-powerpc/dotsym3.d: New. * testsuite/ld-powerpc/dotsym4.d: New. * testsuite/ld-powerpc/dotsymref.s: New. * testsuite/ld-powerpc/nodotsym.s: New. * testsuite/ld-powerpc/powerpc.exp: Run new tests.
Diffstat (limited to 'ld/testsuite/ld-powerpc')
-rw-r--r--ld/testsuite/ld-powerpc/dotsym1.d15
-rw-r--r--ld/testsuite/ld-powerpc/dotsym2.d16
-rw-r--r--ld/testsuite/ld-powerpc/dotsym3.d16
-rw-r--r--ld/testsuite/ld-powerpc/dotsym4.d17
-rw-r--r--ld/testsuite/ld-powerpc/dotsymref.s4
-rw-r--r--ld/testsuite/ld-powerpc/nodotsym.s11
-rw-r--r--ld/testsuite/ld-powerpc/powerpc.exp4
7 files changed, 83 insertions, 0 deletions
diff --git a/ld/testsuite/ld-powerpc/dotsym1.d b/ld/testsuite/ld-powerpc/dotsym1.d
new file mode 100644
index 0000000..1cb9338
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/dotsym1.d
@@ -0,0 +1,15 @@
+#source: nodotsym.s
+#source: dotsymref.s
+#as: -a64
+#ld: -melf64ppc -Ttext=0x10000000 -e foo
+#objdump: -d
+
+.*: file format .*
+
+Disassembly of section \.text:
+
+0+10000000 <\.foo>:
+.*: (4e 80 00 20|20 00 80 4e) blr
+.*: (60 00 00 00|00 00 00 60) nop
+.*: (00 00 00 00|00 00 00 10) .*
+.*: (10 00 00 00|00 00 00 00) .*
diff --git a/ld/testsuite/ld-powerpc/dotsym2.d b/ld/testsuite/ld-powerpc/dotsym2.d
new file mode 100644
index 0000000..7704db7
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/dotsym2.d
@@ -0,0 +1,16 @@
+#source: dotsymref.s
+#source: nodotsym.s
+#as: -a64
+#ld: -melf64ppc -Ttext=0x10000000 -e foo
+#objdump: -d
+
+.*: file format .*
+
+Disassembly of section \.text:
+
+0+10000000 <\.foo-0x8>:
+.*: (00 00 00 00|08 00 00 10) .*
+.*: (10 00 00 08|00 00 00 00) .*
+
+0+10000008 <\.foo>:
+.*: (4e 80 00 20|20 00 80 4e) blr
diff --git a/ld/testsuite/ld-powerpc/dotsym3.d b/ld/testsuite/ld-powerpc/dotsym3.d
new file mode 100644
index 0000000..fac2f8e
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/dotsym3.d
@@ -0,0 +1,16 @@
+#source: nodotsym.s
+#source: dotsymref.s
+#as: -a64
+#ld: -melf64ppc -Ttext=0x1000 -shared
+#objdump: -dR
+
+.*: file format .*
+
+Disassembly of section \.text:
+
+0+1000 <\.foo>:
+.*: (4e 80 00 20|20 00 80 4e) blr
+.*: (60 00 00 00|00 00 00 60) nop
+.*: (00 00 00 00|00 10 00 00) .*
+.*: R_PPC64_RELATIVE \*ABS\*\+0x1000
+.*: (00 00 10 00|00 00 00 00) .*
diff --git a/ld/testsuite/ld-powerpc/dotsym4.d b/ld/testsuite/ld-powerpc/dotsym4.d
new file mode 100644
index 0000000..fdd92f3
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/dotsym4.d
@@ -0,0 +1,17 @@
+#source: dotsymref.s
+#source: nodotsym.s
+#as: -a64
+#ld: -melf64ppc -Ttext=0x1000 -shared
+#objdump: -dR
+
+.*: file format .*
+
+Disassembly of section \.text:
+
+0+1000 <\.foo-0x8>:
+.*: (00 00 00 00|08 10 00 00) .*
+.*: R_PPC64_RELATIVE \*ABS\*\+0x1008
+.*: (00 00 10 08|00 00 00 00) .*
+
+0+1008 <\.foo>:
+.*: (4e 80 00 20|20 00 80 4e) blr
diff --git a/ld/testsuite/ld-powerpc/dotsymref.s b/ld/testsuite/ld-powerpc/dotsymref.s
new file mode 100644
index 0000000..54c6f5c
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/dotsymref.s
@@ -0,0 +1,4 @@
+ .abiversion 1
+ .text
+ .p2align 3
+ .quad .foo
diff --git a/ld/testsuite/ld-powerpc/nodotsym.s b/ld/testsuite/ld-powerpc/nodotsym.s
new file mode 100644
index 0000000..dbc44ec
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/nodotsym.s
@@ -0,0 +1,11 @@
+ .section .opd,"aw"
+ .p2align 3
+ .global foo
+ .type foo,@function
+foo:
+ .quad .L.foo,.TOC.@tocbase,0
+
+ .text
+.L.foo:
+ blr
+ .size foo,.-.L.foo
diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp
index 07226c6..18a8e62 100644
--- a/ld/testsuite/ld-powerpc/powerpc.exp
+++ b/ld/testsuite/ld-powerpc/powerpc.exp
@@ -299,6 +299,10 @@ if [ supports_ppc64 ] then {
run_dump_test "tlsld"
run_dump_test "relocsort"
run_dump_test "addpcis"
+ run_dump_test "dotsym1"
+ run_dump_test "dotsym2"
+ run_dump_test "dotsym3"
+ run_dump_test "dotsym4"
}
run_dump_test "tlsld32"