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