]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
dlfcn: Eliminate GLIBC_PRIVATE dependency from tststatic2
authorFlorian Weimer <fweimer@redhat.com>
Thu, 3 Jun 2021 06:26:04 +0000 (08:26 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 3 Jun 2021 07:12:05 +0000 (09:12 +0200)
The test appears to use _dlfcn_hook@@GLIBC_PRIVATE as a way to
test dlvsym without having to know the appropriate symbol version.
With <first-versions.h>, we can use a public symbol and the symbol
version at which it was defined first.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
dlfcn/modstatic2.c
dlfcn/tststatic2.c

index 9b5aae8b9f7a0bc2b1a6a05becf96258b2b982ec..02d561a7b07534201e74fe0c05984b8ce60b7135 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <gnu/lib-names.h>
+#include <first-versions.h>
 
 int test (FILE *out, int a);
 
@@ -117,11 +118,18 @@ test (FILE *out, int a)
       exit (1);
     }
 
-  if (dlvsym (handle2, "_dlfcn_hook", "GLIBC_PRIVATE") == NULL)
+  /* _exit is very unlikely to receive a second symbol version.  */
+  void *exit_ptr = dlvsym (handle2, "_exit", FIRST_VERSION_libc__exit_STRING);
+  if (exit_ptr == NULL)
     {
       fprintf (out, "dlvsym: %s\n", dlerror ());
       exit (1);
     }
+  if (exit_ptr != dlsym (handle2, "_exit"))
+    {
+      fprintf (out, "dlvsym for _exit does not match dlsym\n");
+      exit (1);
+    }
 
   void *(*dlsymfn) (void *, const char *);
   dlsymfn = dlsym (handle2, "dlsym");
index f8cd5a964ba3e503d52398f6eb0c7cbf96eb4135..5d8a7831b23cdeb6a1c46876d8ac43584c7e5595 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <gnu/lib-names.h>
+#include <first-versions.h>
 
 static int
 do_test (void)
@@ -115,11 +116,18 @@ do_test (void)
       exit (1);
     }
 
-  if (dlvsym (handle2, "_dlfcn_hook", "GLIBC_PRIVATE") == NULL)
+  /* _exit is very unlikely to receive a second symbol version.  */
+  void *exit_ptr = dlvsym (handle2, "_exit", FIRST_VERSION_libc__exit_STRING);
+  if (exit_ptr == NULL)
     {
       printf ("dlvsym: %s\n", dlerror ());
       exit (1);
     }
+  if (exit_ptr != dlsym (handle2, "_exit"))
+    {
+      printf ("dlvsym for _exit does not match dlsym\n");
+      exit (1);
+    }
 
   void *(*dlsymfn) (void *, const char *);
   dlsymfn = dlsym (handle2, "dlsym");