]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld: Add PR ld/31615 tests
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 8 Apr 2024 02:52:49 +0000 (19:52 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 8 Apr 2024 12:18:24 +0000 (05:18 -0700)
PR ld/31615
* testsuite/ld-plugin/lto.exp: Run ld/31615 tests.
* testsuite/ld-plugin/pr31615.ver: New file.
* testsuite/ld-plugin/pr31615a.c: Likewise.
* testsuite/ld-plugin/pr31615b.c: Likewise.
* testsuite/ld-plugin/pr31615c.c: Likewise.
* testsuite/ld-plugin/pr31615d.c: Likewise.

ld/testsuite/ld-plugin/lto.exp
ld/testsuite/ld-plugin/pr31615.ver [new file with mode: 0644]
ld/testsuite/ld-plugin/pr31615a.c [new file with mode: 0644]
ld/testsuite/ld-plugin/pr31615b.c [new file with mode: 0644]
ld/testsuite/ld-plugin/pr31615c.c [new file with mode: 0644]
ld/testsuite/ld-plugin/pr31615d.c [new file with mode: 0644]

index b56d71a668ba529b4e32b8bb521f40521a27d952..35ce38731d0c8d1386bca8c1de7d16be7410afea 100644 (file)
@@ -555,6 +555,30 @@ set lto_link_elf_tests [list \
    "" \
    "pr31482c.so" \
   ] \
+  [list \
+   "Build pr31615b.so" \
+   "-shared -Wl,--version-script=pr31615.ver" \
+   "-fPIC" \
+   {pr31615b.c} \
+   "" \
+   "pr31615b.so" \
+  ] \
+  [list \
+   "Build pr31615c.so" \
+   "-shared -Wl,--version-script=pr31615.ver" \
+   "-fPIC" \
+   {pr31615c.c} \
+   "" \
+   "pr31615c.so" \
+  ] \
+  [list \
+   "Build pr31615d.so" \
+   "-shared -Wl,--version-script=pr31615.ver" \
+   "-fPIC" \
+   {pr31615d.c} \
+   "" \
+   "pr31615d.so" \
+  ] \
 ]
 
 # PR 14918 checks that libgcc is not spuriously included in a shared link of
@@ -754,6 +778,16 @@ set lto_run_elf_shared_tests [list \
    {-Wl,--as-needed,-R,tmpdir} {} \
    {pr31482a.c} {pr31489b.exe} {pass1.out} {-flto} {c} {} \
    {tmpdir/pr31482c.so tmpdir/pr31482b.a}] \
+  [list {pr31615a} \
+   {-Wl,-R,tmpdir} {} \
+   {pr31615a.c} {pr31615a.exe} {pass.out} {-O3 -flto} {c} {} \
+   {-Wl,--as-needed tmpdir/pr31615b.so -Wl,--no-as-needed \
+    tmpdir/pr31615d.so}] \
+  [list {pr31615b} \
+   {-Wl,-R,tmpdir} {} \
+   {pr31615a.c} {pr31615b.exe} {pass.out} {-O3 -flto} {c} {} \
+   {-Wl,--as-needed tmpdir/pr31615c.so -Wl,--no-as-needed \
+    tmpdir/pr31615d.so}] \
 ]
 
 # LTO run-time tests for ELF
diff --git a/ld/testsuite/ld-plugin/pr31615.ver b/ld/testsuite/ld-plugin/pr31615.ver
new file mode 100644 (file)
index 0000000..f1e1f9d
--- /dev/null
@@ -0,0 +1,4 @@
+BAR {
+global:
+  bar;
+};
diff --git a/ld/testsuite/ld-plugin/pr31615a.c b/ld/testsuite/ld-plugin/pr31615a.c
new file mode 100644 (file)
index 0000000..450b2d5
--- /dev/null
@@ -0,0 +1,8 @@
+extern void bar ();
+
+int
+main()
+{
+  bar ();
+  return 0;
+}
diff --git a/ld/testsuite/ld-plugin/pr31615b.c b/ld/testsuite/ld-plugin/pr31615b.c
new file mode 100644 (file)
index 0000000..973dc31
--- /dev/null
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+void
+bar (void)
+{
+  printf ("PASS\n");
+}
diff --git a/ld/testsuite/ld-plugin/pr31615c.c b/ld/testsuite/ld-plugin/pr31615c.c
new file mode 100644 (file)
index 0000000..dbe0788
--- /dev/null
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+__attribute__ ((weak))
+void
+bar (void)
+{
+  printf ("PASS\n");
+}
diff --git a/ld/testsuite/ld-plugin/pr31615d.c b/ld/testsuite/ld-plugin/pr31615d.c
new file mode 100644 (file)
index 0000000..352f598
--- /dev/null
@@ -0,0 +1,5 @@
+__attribute__ ((weak))
+void
+bar (void)
+{
+}