]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
dlopen.3: Correct the pathname used in EXAMPLE
authorMichael Kerrisk <mtk.manpages@gmail.com>
Sat, 5 Dec 2015 07:00:25 +0000 (08:00 +0100)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Sat, 5 Dec 2015 09:40:31 +0000 (10:40 +0100)
Quoting Florian:

    This does not work because libm.so can be a linker script:

           handle = dlopen("libm.so", RTLD_LAZY);

    The proper way to do this is to include <gnu/lib-names.h>
    and use LIBM_SO.

See https://bugzilla.kernel.org/show_bug.cgi?id=108821

Reported-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
man3/dlopen.3

index 2a773c8a863c837dc669fb14a683491c77611d99..4e0744202561641c6ace43c94683afbd255eed66 100644 (file)
@@ -499,13 +499,14 @@ called when a shared object is unloaded.
 .SS History
 These functions are part of the dlopen API, derived from SunOS.
 .SH EXAMPLE
-Load the math library, and print the cosine of 2.0:
+Load the (glibc) math library, and print the cosine of 2.0:
 .nf
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <dlfcn.h>
-
+#include <gnu/lib-names.h>  /* Defines LIBM_SO (which will be a
+                               string such as "libm.so.6") */
 int
 main(int argc, char **argv)
 {
@@ -513,7 +514,7 @@ main(int argc, char **argv)
     double (*cosine)(double);
     char *error;
 
-    handle = dlopen("libm.so", RTLD_LAZY);
+    handle = dlopen(LIBM_SO, RTLD_LAZY);
     if (!handle) {
         fprintf(stderr, "%s\en", dlerror());
         exit(EXIT_FAILURE);