[binutils-gdb] PR27451, -z start_stop_gc for powerpc64
Alan Modra
amodra@sourceware.org
Tue Mar 2 11:26:59 GMT 2021
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b80e421f9136117389be9d96210b35b3d562d725
commit b80e421f9136117389be9d96210b35b3d562d725
Author: Alan Modra <amodra@gmail.com>
Date: Tue Mar 2 21:25:20 2021 +1030
PR27451, -z start_stop_gc for powerpc64
PowerPC64 has its own gc_mark_dynamic_ref.
bfd/
PR 27451
* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Ignore synthesized
linker defined start/stop symbols when start_stop_gc.
ld/
* testsuite/ld-powerpc/startstop.d,
* testsuite/ld-powerpc/startstop.r,
* testsuite/ld-powerpc/startstop.s: New test.
* testsuite/ld-powerpc/powerpc.exp: Run it.
Diff:
---
bfd/ChangeLog | 6 ++++++
bfd/elf64-ppc.c | 3 +++
ld/ChangeLog | 7 +++++++
ld/testsuite/ld-powerpc/powerpc.exp | 3 +++
ld/testsuite/ld-powerpc/startstop.d | 10 ++++++++++
ld/testsuite/ld-powerpc/startstop.r | 2 ++
ld/testsuite/ld-powerpc/startstop.s | 16 ++++++++++++++++
7 files changed, 47 insertions(+)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 44286c2195d..c4c4fa2647a 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2021-03-02 Alan Modra <amodra@gmail.com>
+
+ PR 27451
+ * elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Ignore synthesized
+ linker defined start/stop symbols when start_stop_gc.
+
2021-03-02 Alan Modra <amodra@gmail.com>
* elf64-ppc.c (ppc64_elf_relocate_section): Don't optimise got
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 769fff9bb5c..ab0e0d33aac 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -5749,6 +5749,9 @@ ppc64_elf_gc_mark_dynamic_ref (struct elf_link_hash_entry *h, void *inf)
if ((eh->elf.root.type == bfd_link_hash_defined
|| eh->elf.root.type == bfd_link_hash_defweak)
+ && (!eh->elf.start_stop
+ || eh->elf.root.ldscript_def
+ || !info->start_stop_gc)
&& ((eh->elf.ref_dynamic && !eh->elf.forced_local)
|| ((eh->elf.def_regular || ELF_COMMON_DEF_P (&eh->elf))
&& ELF_ST_VISIBILITY (eh->elf.other) != STV_INTERNAL
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 2bb97bd2809..d12e537791a 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2021-03-02 Alan Modra <amodra@gmail.com>
+
+ * testsuite/ld-powerpc/startstop.d,
+ * testsuite/ld-powerpc/startstop.r,
+ * testsuite/ld-powerpc/startstop.s: New test.
+ * testsuite/ld-powerpc/powerpc.exp: Run it.
+
2021-03-02 Alan Modra <amodra@gmail.com>
* testsuite/ld-powerpc/weak1.d,
diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp
index 8aa0eccfa0e..2ac02b1c02b 100644
--- a/ld/testsuite/ld-powerpc/powerpc.exp
+++ b/ld/testsuite/ld-powerpc/powerpc.exp
@@ -350,6 +350,9 @@ set ppc64elftests {
{"weak1.so" "-shared -melf64ppc --hash-style=both" ""
"-a64 -mpower10" {weak1.s}
{{objdump -d weak1so.d} {readelf {-srW} weak1so.r}} "weak1.so"}
+ {"startstop" "-shared -melf64ppc --hash-style=sysv --gc-sections -z start-stop-gc" ""
+ "-a64 -mpower10" {startstop.s}
+ {{objdump -d startstop.d} {readelf {-rW} startstop.r}} "startstop.so"}
}
set ppceabitests {
diff --git a/ld/testsuite/ld-powerpc/startstop.d b/ld/testsuite/ld-powerpc/startstop.d
new file mode 100644
index 00000000000..2bf4c73cbfe
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/startstop.d
@@ -0,0 +1,10 @@
+
+.*: file format .*
+
+Disassembly of section \.text:
+
+0+140 <_start>:
+ 140: (04 10 00 01|01 00 10 04) pld r3,66000
+ 144: (e4 60 01 d0|d0 01 60 e4)
+ 148: (04 10 00 01|01 00 10 04) pld r4,65984
+ 14c: (e4 80 01 c0|c0 01 80 e4)
diff --git a/ld/testsuite/ld-powerpc/startstop.r b/ld/testsuite/ld-powerpc/startstop.r
new file mode 100644
index 00000000000..9a583fbfad4
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/startstop.r
@@ -0,0 +1,2 @@
+
+There are no relocations in this file.
diff --git a/ld/testsuite/ld-powerpc/startstop.s b/ld/testsuite/ld-powerpc/startstop.s
new file mode 100644
index 00000000000..8e88a721578
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/startstop.s
@@ -0,0 +1,16 @@
+ .weak __start_xx
+ .weak __stop_xx
+
+ .global _start
+_start:
+ pld 3,__start_xx@got@pcrel
+ pld 4,__stop_xx@got@pcrel
+
+ .section xx,"a",unique,0
+ .byte 0
+
+ .section xx,"a",unique,1
+ .byte 1
+
+ .section xx,"a",unique,2
+ .byte 2
More information about the Binutils-cvs
mailing list