aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-07-08 15:24:06 +0930
committerAlan Modra <amodra@gmail.com>2014-07-08 19:42:03 +0930
commitbffebb6ba5b4ddbca7353626d682f9f974584dbf (patch)
tree093877e73fca460e1b1f378024e210b46ddc1f00 /ld
parent161ac41e03a819bc34e8c70a3fd1bc26f43858a2 (diff)
downloadgdb-bffebb6ba5b4ddbca7353626d682f9f974584dbf.zip
gdb-bffebb6ba5b4ddbca7353626d682f9f974584dbf.tar.gz
gdb-bffebb6ba5b4ddbca7353626d682f9f974584dbf.tar.bz2
Copy st_other for linker script symbol assignments
This fixes a problem seen on powerpc64le ELFv2 when creating a function symbol alias with ld --defsym. st_other needs to be copied from the source symbol to the alias in order to set up the local entry offset for the alias. I decided to make this change in the generic ELF code rather than in elf64-ppc.c since it looks like other targets that use st_other bits might benefit too. bfd/ * elflink.c (_bfd_elf_copy_link_hash_symbol_type): Copy st_other bits from source to dest. * linker.c (_bfd_generic_copy_link_hash_symbol_type): Update comment. * targets.c (struct bfd_target <_bfd_copy_link_hash_symbol_type>): Likewise. * bfd-in2.h: Regenerate. ld/testsuite/ * ld-powerpc/defsym.s, * ld-powerpc/defsym.d: New test. * ld-powerpc/powerpc.exp: Run it.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ChangeLog5
-rw-r--r--ld/testsuite/ld-powerpc/defsym.d26
-rw-r--r--ld/testsuite/ld-powerpc/defsym.s19
-rw-r--r--ld/testsuite/ld-powerpc/powerpc.exp1
4 files changed, 51 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index bbef087..340c23f 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -7,6 +7,11 @@
2014-07-08 Alan Modra <amodra@gmail.com>
+ * ld-powerpc/defsym.s, * ld-powerpc/defsym.d: New test.
+ * ld-powerpc/powerpc.exp: Run it.
+
+2014-07-08 Alan Modra <amodra@gmail.com>
+
PR 17112
* ld-plugin/lto.exp: When building liblti-11.a, pass
--plugin path_to_gcc/liblto_plugin.so to ar.
diff --git a/ld/testsuite/ld-powerpc/defsym.d b/ld/testsuite/ld-powerpc/defsym.d
new file mode 100644
index 0000000..1e5b567
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/defsym.d
@@ -0,0 +1,26 @@
+#source: defsym.s
+#as: -a64
+#ld: -melf64ppc --defsym bar=foo
+#objdump: -Dr
+
+.*: file format elf64-powerpc.*
+
+Disassembly of section \.text:
+
+0+100000b0 <_start>:
+ 100000b0: (15 00 00 48|48 00 00 15) bl 100000c4 <(foo|bar)\+0x8>
+ 100000b4: (11 00 00 48|48 00 00 11) bl 100000c4 <(foo|bar)\+0x8>
+ 100000b8: (00 00 00 60|60 00 00 00) nop
+
+0+100000bc <(foo|bar)>:
+ 100000bc: (02 10 40 3c|3c 40 10 02) lis r2,4098
+ 100000c0: (c8 80 42 38|38 42 80 c8) addi r2,r2,-32568
+ 100000c4: (20 00 80 4e|4e 80 00 20) blr
+
+Disassembly of section \.data:
+
+0+100100c8 .*:
+ 100100c8: (bc 00 00 10|00 00 00 00) .*
+ 100100cc: (00 00 00 00|10 00 00 bc) .*
+ 100100d0: (bc 00 00 10|00 00 00 00) .*
+ 100100d4: (00 00 00 00|10 00 00 bc) .*
diff --git a/ld/testsuite/ld-powerpc/defsym.s b/ld/testsuite/ld-powerpc/defsym.s
new file mode 100644
index 0000000..efca072
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/defsym.s
@@ -0,0 +1,19 @@
+ .text
+ .globl _start
+_start:
+ bl foo
+ bl bar
+ nop
+
+ .globl foo
+ .type foo,@function
+foo:
+ addis 2,12,.TOC.-foo@ha
+ addi 2,2,.TOC.-foo@l
+ .localentry foo,.-foo
+ blr
+ .size foo,.-foo
+
+ .data
+ .dc.a foo
+ .dc.a bar
diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp
index 08a7e2b..23572c6 100644
--- a/ld/testsuite/ld-powerpc/powerpc.exp
+++ b/ld/testsuite/ld-powerpc/powerpc.exp
@@ -278,6 +278,7 @@ if [ supports_ppc64 ] then {
run_dump_test "ambiguousv1b"
run_dump_test "ambiguousv2"
run_dump_test "ambiguousv2b"
+ run_dump_test "defsym"
}
if { [istarget "powerpc*-eabi*"] } {