4fc7fc
Downstream-specific patch to link DSO sorting tests with -ldl
4fc7fc
if needed.  Upstream does not need this because <dlfcn.h> interfaces
4fc7fc
are part of libc.
4fc7fc
4fc7fc
diff --git a/scripts/dso-ordering-test.py b/scripts/dso-ordering-test.py
4fc7fc
index 43b5ec4d920ad6a3..ae85e0f4a6ae5b3e 100644
4fc7fc
--- a/scripts/dso-ordering-test.py
4fc7fc
+++ b/scripts/dso-ordering-test.py
4fc7fc
@@ -657,6 +657,8 @@ def process_testcase(t):
4fc7fc
                                  % (test_name + "-" + dep + ".FAKE.so",
4fc7fc
                                     ("$(objpfx)" + test_subdir + "/"
4fc7fc
                                      + test_name + "-" + dep + ".so")))
4fc7fc
+                            makefile.write(
4fc7fc
+                                "LDLIBS-%s += -Wl,--as-needed -ldl -Wl,--no-as-needed\n" % dso)
4fc7fc
                             rule = ("$(objpfx)" + test_subdir + "/"
4fc7fc
                                     + test_name + "-" + dep + ".FAKE.os: "
4fc7fc
                                     "$(objpfx)" + test_srcdir
4fc7fc
@@ -685,6 +687,8 @@ def process_testcase(t):
4fc7fc
                           + test_descr.soname_map[o] + ".so")
4fc7fc
                 ldflags += (" -Wl,-soname=" + soname)
4fc7fc
             makefile.write("LDFLAGS-%s = %s\n" % (dso, ldflags))
4fc7fc
+            makefile.write(
4fc7fc
+                "LDLIBS-%s += -Wl,--as-needed -ldl -Wl,--no-as-needed\n" % dso)
4fc7fc
             if o in test_descr.callrefs:
4fc7fc
                 makefile.write("%s-no-z-defs = yes\n" % (dso))
4fc7fc
 
4fc7fc
@@ -702,6 +706,8 @@ def process_testcase(t):
4fc7fc
                       + test_descr.soname_map['#'] + ".so")
4fc7fc
             ldflags += (" -Wl,-soname=" + soname)
4fc7fc
         makefile.write("LDFLAGS-%s = %s\n" % (test_name, ldflags))
4fc7fc
+        makefile.write(
4fc7fc
+            "LDLIBS-%s += -Wl,--as-needed -ldl -Wl,--no-as-needed\n" % test_name)
4fc7fc
         rule = ("$(objpfx)" + test_subdir + "/" + test_name + ".o: "
4fc7fc
                 "$(objpfx)" + test_srcdir + test_name + ".c\n"
4fc7fc
                 "\t$(compile.c) $(OUTPUT_OPTION)\n")