add test for correct calculation of dl_phdr_info.dlpi_subs
Commit Message
Comments
On 01 Aug 2016 15:20, Gleb Natapov wrote:
> --- /dev/null
> +++ b/elf/tst-dlpi_subs.c
> @@ -0,0 +1,33 @@
> +#include <dlfcn.h>
> +#include <stdio.h>
please put a proper comment block at the top (copyright/license) and a
short blurb explaining what the test does.
> +static int fail = false;
"false" is for bool types, not int types
-mike
@@ -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
new file mode 100644
@@ -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"