This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Define __start/__stop symbols when there is only a dynamic def
On Mon, Jan 29, 2018 at 08:07:09PM -0800, H.J. Lu wrote:
> On Mon, Jan 29, 2018 at 6:18 PM, Alan Modra <amodra@gmail.com> wrote:
> > On Mon, Jan 29, 2018 at 05:17:10PM -0800, H.J. Lu wrote:
> >> Can you add another testcase with -Wl,--gc-sections on executable?
> >
> > Do you suspect something goes wrong with --gc-sections? With the
>
> I hope not. A test is reassuring. We had quite some issues with --gc-sections
> and __start/__stop symbols before.
I think we are already covered. There isn't much difference between
--gc-sections on shared libs and --gc-sections on executables except
that ld acts like --export-dynamic is given for -shared. The
ld-elf/pr21562* series covers -shared, thanks to your efforts.
There's also ld-gc/start.d, ld-gc/pr19161.d, and ld-gc/pr2022d for
executables.
Hmm, maybe we could do with a test that --gc-sections removes
__start/__stop symbols.
>From 040b4a9eb8430dc5e0fc657da88b08ab730b97ee Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Tue, 30 Jan 2018 22:11:00 +1030
Subject: [PATCH 1/4] Add --gc-sections test checking removal of __start/__stop
symbols.
Well, just __stop__foo but that should be good enough.
* testsuite/ld-gc/stop.d,
* testsuite/ld-gc/stop.s: New test.
* testsuite/ld-gc/gc.exp: Run it.
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 83c9689..f29d51a 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2018-01-30 Alan Modra <amodra@gmail.com>
+
+ * testsuite/ld-gc/stop.d,
+ * testsuite/ld-gc/stop.s: New test.
+ * testsuite/ld-gc/gc.exp: Run it.
+
2018-01-30 Maciej W. Rozycki <macro@mips.com>
PR ld/22649
diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
index eaaa8e1..ad983ef 100644
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -104,6 +104,7 @@ test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func"
run_dump_test "noent"
run_dump_test "abi-note"
run_dump_test "start"
+run_dump_test "stop"
run_dump_test "pr19167"
if { [is_elf_format] } then {
run_dump_test "all-debug-sections"
diff --git a/ld/testsuite/ld-gc/stop.d b/ld/testsuite/ld-gc/stop.d
new file mode 100644
index 0000000..f8a32d6
--- /dev/null
+++ b/ld/testsuite/ld-gc/stop.d
@@ -0,0 +1,10 @@
+#name: --gc-sections removing __stop_
+#ld: --gc-sections -e _start
+#nm: -n
+#target: *-*-linux* *-*-gnu*
+#notarget: *-*-*aout *-*-*oldld frv-*-linux* metag-*-linux*
+
+#failif
+#...
+[0-9a-f]+ D +__stop__foo
+#...
diff --git a/ld/testsuite/ld-gc/stop.s b/ld/testsuite/ld-gc/stop.s
new file mode 100644
index 0000000..cb46d04
--- /dev/null
+++ b/ld/testsuite/ld-gc/stop.s
@@ -0,0 +1,8 @@
+ .text
+ .globl _start
+_start:
+ .dc.a 0
+
+ .section _foo,"aw",%progbits
+foo:
+ .long 1
--
Alan Modra
Australia Development Lab, IBM