auto-buildrequires-preload: Use libc.so name from GNU headers
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 17 May 2016 13:50:27 +0000 (15:50 +0200)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 17 May 2016 14:14:20 +0000 (15:14 +0100)
There's this header file gnu/lib-names.h which contains
stringified versions of library names such as:

  #define LIBC_SO "libc.so.6"

Advantage of using that is whenever there's a soname bump we
don't have to care about that and bare rebuild just works (TM).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
auto-buildrequires-preload.c

index a1e6773..b67e20a 100644 (file)
@@ -36,6 +36,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <dlfcn.h>
+#include <gnu/lib-names.h>
 
 #define ALIAS(ret,syscall,params,brfunc)                               \
   extern ret syscall params __attribute__((alias (brfunc)))
@@ -191,9 +192,9 @@ br_init (void)
 {
   void *dl;
 
-  dl = dlopen ("/lib64/libc.so.6", RTLD_LAZY|RTLD_LOCAL);
+  dl = dlopen ("/lib64/" LIBC_SO, RTLD_LAZY|RTLD_LOCAL);
   if (dl == NULL)      // Try '/lib/' also
-         dl = dlopen("/lib/libc.so.6", RTLD_LAZY|RTLD_LOCAL);
+         dl = dlopen("/lib/" LIBC_SO, RTLD_LAZY|RTLD_LOCAL);
   if (dl == NULL) {
     fprintf (stderr, "%s\n", dlerror ());
     abort ();