]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld: Add PR ld/31710 tests
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 8 May 2024 13:22:20 +0000 (06:22 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 8 May 2024 14:01:24 +0000 (07:01 -0700)
PR ld/31710
* testsuite/ld-elf/wrap.exp: Run ld/31710 tests.
* testsuite/ld-elf/wrap2.h: New file.
* testsuite/ld-elf/wrap2a.c: Likewise.
* testsuite/ld-elf/wrap2b.c: Likewise.

ld/testsuite/ld-elf/wrap.exp
ld/testsuite/ld-elf/wrap2.h [new file with mode: 0644]
ld/testsuite/ld-elf/wrap2a.c [new file with mode: 0644]
ld/testsuite/ld-elf/wrap2b.c [new file with mode: 0644]

index 90e2d60e67dfbea689e4e55643c6eb3968fb1481..efc44bc013f8f3be4ebbf60afb119c2c6eeb7c7e 100644 (file)
@@ -52,3 +52,29 @@ if [check_shared_lib_support] {
   run_cc_link_tests $build_tests
   run_ld_link_exec_tests $run_tests
 }
+
+run_ld_link_tests [list \
+    [list \
+       "Build libwrap2.a" \
+       "" \
+       "" \
+       "" \
+       {wrap2a.c} \
+       {} \
+       "libwrap2.a" \
+       "-g" \
+    ] \
+]
+
+# Test very simple native Linux/x86 programs with linux-x86.S.
+run_ld_link_exec_tests [list \
+    [list \
+       "Run wrap2" \
+       "-Wl,--wrap=impl" \
+       "" \
+       { wrap2b.c } \
+       "wrap2" \
+       "pass.out" \
+       "-g" \
+    ] \
+]
diff --git a/ld/testsuite/ld-elf/wrap2.h b/ld/testsuite/ld-elf/wrap2.h
new file mode 100644 (file)
index 0000000..8fd9495
--- /dev/null
@@ -0,0 +1,6 @@
+struct ops
+{
+  void (*loaded)(void);
+};
+
+extern struct ops impl;
diff --git a/ld/testsuite/ld-elf/wrap2a.c b/ld/testsuite/ld-elf/wrap2a.c
new file mode 100644 (file)
index 0000000..a37655f
--- /dev/null
@@ -0,0 +1,11 @@
+#include "wrap2.h"
+
+static void
+loaded (void)
+{
+}
+
+struct ops impl =
+{
+  .loaded = loaded
+};
diff --git a/ld/testsuite/ld-elf/wrap2b.c b/ld/testsuite/ld-elf/wrap2b.c
new file mode 100644 (file)
index 0000000..c1f4444
--- /dev/null
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include "wrap2.h"
+
+static void
+loaded(void)
+{
+  printf ("PASS\n");
+}
+
+struct ops __wrap_impl =
+{
+  .loaded = loaded,
+};
+
+int
+main()
+{
+  impl.loaded ();
+  return 0;
+}