public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ld: Run --wrap tests only if supported
@ 2024-05-08 13:22 H.J. Lu
  2024-05-08 13:22 ` [PATCH 2/2] ld: Add PR ld/31710 tests H.J. Lu
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2024-05-08 13:22 UTC (permalink / raw)
  To: binutils

Run --wrap tests with shared library only if -shared is supported.

	* testsuite/ld-elf/wrap.exp: Run --wrap tests with shared library
	only if -shared is supported.
---
 ld/testsuite/ld-elf/wrap.exp | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/ld/testsuite/ld-elf/wrap.exp b/ld/testsuite/ld-elf/wrap.exp
index d24c1e7d7ce..90e2d60e67d 100644
--- a/ld/testsuite/ld-elf/wrap.exp
+++ b/ld/testsuite/ld-elf/wrap.exp
@@ -25,34 +25,30 @@ if ![is_elf_format] {
     return
 }
 
-# Skip targets where -shared is not supported
-
-if ![check_shared_lib_support] {
-    return
-}
-
 # Check if compiler works
 if { ![check_compiler_available] } {
     return
 }
 
-set build_tests {
-  {"Build libwrap1a.so"
-   "-shared" "-fPIC"
-   {wrap1a.c} {} "libwrap1a.so"}
-  {"Build libwrap1b.so"
-   "-shared tmpdir/libwrap1a.so" "-fPIC"
-   {wrap1b.c} {} "libwrap1b.so"}
-}
-
-set run_tests {
+if [check_shared_lib_support] {
+  set build_tests {
+    {"Build libwrap1a.so"
+     "-shared" "-fPIC"
+     {wrap1a.c} {} "libwrap1a.so"}
+    {"Build libwrap1b.so"
+     "-shared tmpdir/libwrap1a.so" "-fPIC"
+     {wrap1b.c} {} "libwrap1b.so"}
+  }
+
+  set run_tests {
     {"Run with libwrap1a.so and libwrap1b.so"
      "-Wl,--no-as-needed,--wrap,par tmpdir/libwrap1a.so tmpdir/libwrap1b.so" ""
      {wrap1.c} "wrap1" "wrap1.out"}
     {"Run with libwrap1b.so and libwrap1a.so"
      "-Wl,--no-as-needed,--wrap,par tmpdir/libwrap1b.so tmpdir/libwrap1a.so" ""
      {wrap1.c} "wrap1" "wrap1.out"}
-}
+  }
 
-run_cc_link_tests $build_tests
-run_ld_link_exec_tests $run_tests
+  run_cc_link_tests $build_tests
+  run_ld_link_exec_tests $run_tests
+}
-- 
2.45.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] ld: Add PR ld/31710 tests
  2024-05-08 13:22 [PATCH 1/2] ld: Run --wrap tests only if supported H.J. Lu
@ 2024-05-08 13:22 ` H.J. Lu
  0 siblings, 0 replies; 2+ messages in thread
From: H.J. Lu @ 2024-05-08 13:22 UTC (permalink / raw)
  To: binutils

	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 | 26 ++++++++++++++++++++++++++
 ld/testsuite/ld-elf/wrap2.h  |  6 ++++++
 ld/testsuite/ld-elf/wrap2a.c | 11 +++++++++++
 ld/testsuite/ld-elf/wrap2b.c | 20 ++++++++++++++++++++
 4 files changed, 63 insertions(+)
 create mode 100644 ld/testsuite/ld-elf/wrap2.h
 create mode 100644 ld/testsuite/ld-elf/wrap2a.c
 create mode 100644 ld/testsuite/ld-elf/wrap2b.c

diff --git a/ld/testsuite/ld-elf/wrap.exp b/ld/testsuite/ld-elf/wrap.exp
index 90e2d60e67d..efc44bc013f 100644
--- a/ld/testsuite/ld-elf/wrap.exp
+++ b/ld/testsuite/ld-elf/wrap.exp
@@ -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
index 00000000000..8fd9495f6f4
--- /dev/null
+++ b/ld/testsuite/ld-elf/wrap2.h
@@ -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
index 00000000000..a37655fccad
--- /dev/null
+++ b/ld/testsuite/ld-elf/wrap2a.c
@@ -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
index 00000000000..c1f4444a08a
--- /dev/null
+++ b/ld/testsuite/ld-elf/wrap2b.c
@@ -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;
+}
-- 
2.45.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-08 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-08 13:22 [PATCH 1/2] ld: Run --wrap tests only if supported H.J. Lu
2024-05-08 13:22 ` [PATCH 2/2] ld: Add PR ld/31710 tests H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).