[PATCH] add test for correct calculation of dl_phdr_info.dlpi_subs

Gleb Natapov gleb@scylladb.com
Mon Aug 1 12:20:00 GMT 2016


diff --git a/elf/Makefile b/elf/Makefile
index 593403c..d64b281 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -149,7 +149,7 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
 	 tst-nodelete) \
 	 tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \
 	 tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
-	 tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error
+	 tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error tst-dlpi_subs
 #	 reldep9
 ifeq ($(build-hardcoded-path-in-tests),yes)
 tests += tst-dlopen-aout
@@ -1005,6 +1005,9 @@ generated += check-execstack.out
 $(objpfx)tst-dlmodcount: $(libdl)
 $(objpfx)tst-dlmodcount.out: $(test-modules)
 
+$(objpfx)tst-dlpi_subs: $(libdl)
+$(objpfx)tst-dlpi_subs.out: $(test-modules)
+
 $(all-built-dso:=.jmprel): %.jmprel: % Makefile
 	@rm -f $@T
 	LC_ALL=C $(READELF) -W -S -d -r $< > $@T
diff --git a/elf/tst-dlpi_subs.c b/elf/tst-dlpi_subs.c
new file mode 100644
index 0000000..bea0110
--- /dev/null
+++ b/elf/tst-dlpi_subs.c
@@ -0,0 +1,33 @@
+#include <dlfcn.h>
+#include <stdio.h>
+
+static int fail = false;
+
+static int
+callback (struct dl_phdr_info *info, size_t size, void *data)
+{
+  if (info->dlpi_subs != 0) {
+    printf ("dlpi_subs == %llu instead of 0\n", info->dlpi_subs);
+    fail = true;
+  }
+  return 0;
+}
+
+
+static int
+do_test (void)
+{
+  void *h = dlmopen (LM_ID_NEWLM, "$ORIGIN/tst-deep1mod2.so", RTLD_LAZY);
+  if (h == NULL)
+    {
+      printf ("cannot get handle for %s: %s\n",
+	      "tst-deep1mod2.so", dlerror ());
+      return 1;
+    }
+  dl_iterate_phdr (callback, NULL);
+
+  return fail;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
--
			Gleb.



More information about the Libc-alpha mailing list