[binutils-gdb] ld: Add PR ld/32816 tests
H.J. Lu
hjl@sourceware.org
Thu Sep 10 11:54:35 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0b1fba3c49986faa9e310415e2ff666a7d8d8e6e
commit 0b1fba3c49986faa9e310415e2ff666a7d8d8e6e
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Sep 10 09:07:21 2026 +0800
ld: Add PR ld/32816 tests
PR ld/32816
* testsuite/ld-elf/pr32816.rd: New file.
* testsuite/ld-elf/pr32816a.c: Likewise.
* testsuite/ld-elf/pr32816b.c: Likewise.
* testsuite/ld-elf/shared.exp: Run PR ld/32816 tests.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Diff:
---
ld/testsuite/ld-elf/pr32816.rd | 3 +++
ld/testsuite/ld-elf/pr32816a.c | 17 +++++++++++++++++
ld/testsuite/ld-elf/pr32816b.c | 8 ++++++++
ld/testsuite/ld-elf/shared.exp | 18 ++++++++++++++++++
4 files changed, 46 insertions(+)
diff --git a/ld/testsuite/ld-elf/pr32816.rd b/ld/testsuite/ld-elf/pr32816.rd
new file mode 100644
index 00000000000..f3dcf8dcfdb
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr32816.rd
@@ -0,0 +1,3 @@
+#...
+ +0x[0-9a-f]+ +\(NEEDED\) +Shared library: +\[.*pr32816.so\]
+#pass
diff --git a/ld/testsuite/ld-elf/pr32816a.c b/ld/testsuite/ld-elf/pr32816a.c
new file mode 100644
index 00000000000..2cf637dd3e0
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr32816a.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+void
+ProfilerStart (const char *filename)
+{
+ printf ("Starting with arg: %s!\n", filename);
+}
+
+static __attribute__ ((constructor)) void
+startup (void)
+{
+ const char *v = getenv ("CPUPROFILE");
+ if (!v)
+ return;
+ ProfilerStart (v);
+}
diff --git a/ld/testsuite/ld-elf/pr32816b.c b/ld/testsuite/ld-elf/pr32816b.c
new file mode 100644
index 00000000000..f6ca01a335f
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr32816b.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int
+main (void)
+{
+ printf ("main!\n");
+ return 0;
+}
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 043090c61c2..ae70ad2cc1a 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -942,6 +942,24 @@ run_cc_link_tests [list \
{{readelf -d pr21086.rd}} \
"pr21086" \
] \
+ [list \
+ "Build pr32816.so" \
+ "-shared" \
+ "-fPIC" \
+ {pr32816a.c} \
+ {} \
+ "pr32816.so" \
+ ] \
+ [list \
+ "Build pr32816" \
+ "-Wl,-u,ProfilerStart,--as-need" \
+ "" \
+ {pr32816b.c} \
+ {{readelf -d pr32816.rd}} \
+ "pr32816" \
+ "c" \
+ "tmpdir/pr32816.so" \
+ ] \
]
# pr19073.s uses .set, which has a different meaning on alpha.
More information about the Binutils-cvs
mailing list