* bug in dlopen(3) man page
@ 2014-03-08 21:30 Thomas Klausner
[not found] ` <20140308213059.GA25275-k3ZVrZPR2RPzPE21tAIdciO7C/xPubJB@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Klausner @ 2014-03-08 21:30 UTC (permalink / raw)
To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 812 bytes --]
Hi!
There is a bug in dlopen(3). The NOTES section claims:
"The symbols RTLD_DEFAULT and RTLD_NEXT are defined by <dlfcn.h> only
when _GNU_SOURCE was defined before including it."
However, this is not correct.
>From dlfcn.h on a "Gentoo Base System release 2.1":
#ifdef __USE_GNU
...
# define RTLD_NEXT ((void *) -1l)
...
# define RTLD_DEFAULT ((void *) 0)
...
You can verify this by compiling the attached program. For me it gives:
test.c: In function `main':
test.c:8: error: `RTLD_NEXT' undeclared (first use in this function)
test.c:8: error: (Each undeclared identifier is reported only once
test.c:8: error: for each function it appears in.)
It works if I set "__USE_GNU_" instead.
Please also check the "Glibc extensions: dladdr() and dlvsym()"
section, it also mentions _GNU_SOURCE.
Thomas
[-- Attachment #2: test.c --]
[-- Type: text/plain, Size: 169 bytes --]
#include <stdio.h>
#include <stdlib.h>
#define _GNU_SOURCE
#include <dlfcn.h>
int main(int argc, char *argv[]) {
printf ("RTLD_NEXT is %d\n", RTLD_NEXT);
exit(0);
}
^ permalink raw reply [flat|nested] 4+ messages in thread[parent not found: <20140308213059.GA25275-k3ZVrZPR2RPzPE21tAIdciO7C/xPubJB@public.gmane.org>]
* Re: bug in dlopen(3) man page [not found] ` <20140308213059.GA25275-k3ZVrZPR2RPzPE21tAIdciO7C/xPubJB@public.gmane.org> @ 2014-03-09 23:25 ` Mike Frysinger 2014-03-10 11:53 ` Thomas Klausner 0 siblings, 1 reply; 4+ messages in thread From: Mike Frysinger @ 2014-03-09 23:25 UTC (permalink / raw) To: Thomas Klausner Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w, linux-man-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1151 bytes --] On Sat 08 Mar 2014 22:30:59 Thomas Klausner wrote: > There is a bug in dlopen(3). The NOTES section claims: > > "The symbols RTLD_DEFAULT and RTLD_NEXT are defined by <dlfcn.h> only > when _GNU_SOURCE was defined before including it." > > However, this is not correct. > > From dlfcn.h on a "Gentoo Base System release 2.1": > #ifdef __USE_GNU > ... > # define RTLD_NEXT ((void *) -1l) > ... > # define RTLD_DEFAULT ((void *) 0) > ... > > You can verify this by compiling the attached program. For me it gives: > test.c: In function `main': > test.c:8: error: `RTLD_NEXT' undeclared (first use in this function) > test.c:8: error: (Each undeclared identifier is reported only once > test.c:8: error: for each function it appears in.) > > It works if I set "__USE_GNU_" instead. > > Please also check the "Glibc extensions: dladdr() and dlvsym()" > section, it also mentions _GNU_SOURCE. the man page is correct. you must define _GNU_SOURCE before including any headers. you must never use the __USE_XXX defines directly. see feature_test_macros(7) for details as the dlopen() man page references. -mike [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: bug in dlopen(3) man page 2014-03-09 23:25 ` Mike Frysinger @ 2014-03-10 11:53 ` Thomas Klausner [not found] ` <20140310115304.GS25275-k3ZVrZPR2RPzPE21tAIdciO7C/xPubJB@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Thomas Klausner @ 2014-03-10 11:53 UTC (permalink / raw) To: Mike Frysinger Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w, linux-man-u79uwXL29TY76Z2rM5mHXA On Sun, Mar 09, 2014 at 07:25:20PM -0400, Mike Frysinger wrote: > On Sat 08 Mar 2014 22:30:59 Thomas Klausner wrote: > > There is a bug in dlopen(3). The NOTES section claims: > > > > "The symbols RTLD_DEFAULT and RTLD_NEXT are defined by <dlfcn.h> only > > when _GNU_SOURCE was defined before including it." > > > > However, this is not correct. > > > > From dlfcn.h on a "Gentoo Base System release 2.1": > > #ifdef __USE_GNU > > ... > > # define RTLD_NEXT ((void *) -1l) > > ... > > # define RTLD_DEFAULT ((void *) 0) > > ... > > > > You can verify this by compiling the attached program. For me it gives: > > test.c: In function `main': > > test.c:8: error: `RTLD_NEXT' undeclared (first use in this function) > > test.c:8: error: (Each undeclared identifier is reported only once > > test.c:8: error: for each function it appears in.) > > > > It works if I set "__USE_GNU_" instead. > > > > Please also check the "Glibc extensions: dladdr() and dlvsym()" > > section, it also mentions _GNU_SOURCE. > > the man page is correct. you must define _GNU_SOURCE before including any > headers. you must never use the __USE_XXX defines directly. > > see feature_test_macros(7) for details as the dlopen() man page references. Thanks for your reply. Michael Kerrisk already pointed me to that in a private email. However, this makes writing portable code a bit harder. When I know I need the define for this particular header, I can wrap the header in #define __FOO #include foo.h #undef __FOO but here it seems I have to live with whatever side effects __FOO might have on any other headers. Well, you can't fix that, so thanks for the pointer. Thomas -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <20140310115304.GS25275-k3ZVrZPR2RPzPE21tAIdciO7C/xPubJB@public.gmane.org>]
* Re: bug in dlopen(3) man page [not found] ` <20140310115304.GS25275-k3ZVrZPR2RPzPE21tAIdciO7C/xPubJB@public.gmane.org> @ 2014-03-10 12:32 ` Michael Kerrisk (man-pages) 0 siblings, 0 replies; 4+ messages in thread From: Michael Kerrisk (man-pages) @ 2014-03-10 12:32 UTC (permalink / raw) To: Thomas Klausner; +Cc: Mike Frysinger, linux-man On Mon, Mar 10, 2014 at 12:53 PM, Thomas Klausner <tk-JlXkzPh5ucKzZXS1Dc/lvw@public.gmane.org> wrote: > On Sun, Mar 09, 2014 at 07:25:20PM -0400, Mike Frysinger wrote: >> On Sat 08 Mar 2014 22:30:59 Thomas Klausner wrote: >> > There is a bug in dlopen(3). The NOTES section claims: >> > >> > "The symbols RTLD_DEFAULT and RTLD_NEXT are defined by <dlfcn.h> only >> > when _GNU_SOURCE was defined before including it." >> > >> > However, this is not correct. >> > >> > From dlfcn.h on a "Gentoo Base System release 2.1": >> > #ifdef __USE_GNU >> > ... >> > # define RTLD_NEXT ((void *) -1l) >> > ... >> > # define RTLD_DEFAULT ((void *) 0) >> > ... >> > >> > You can verify this by compiling the attached program. For me it gives: >> > test.c: In function `main': >> > test.c:8: error: `RTLD_NEXT' undeclared (first use in this function) >> > test.c:8: error: (Each undeclared identifier is reported only once >> > test.c:8: error: for each function it appears in.) >> > >> > It works if I set "__USE_GNU_" instead. >> > >> > Please also check the "Glibc extensions: dladdr() and dlvsym()" >> > section, it also mentions _GNU_SOURCE. >> >> the man page is correct. you must define _GNU_SOURCE before including any >> headers. you must never use the __USE_XXX defines directly. >> >> see feature_test_macros(7) for details as the dlopen() man page references. > > Thanks for your reply. > > Michael Kerrisk already pointed me to that in a private email. Yup, though it was unintentional -- I overlooked that the fact that reply on my mobile device did not do a CC-all. Cheers, Michael > > However, this makes writing portable code a bit harder. When I know I need > the define for this particular header, I can wrap the header in > #define __FOO > #include foo.h > #undef __FOO > > but here it seems I have to live with whatever side effects __FOO > might have on any other headers. > > Well, you can't fix that, so thanks for the pointer. > Thomas -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-10 12:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-08 21:30 bug in dlopen(3) man page Thomas Klausner
[not found] ` <20140308213059.GA25275-k3ZVrZPR2RPzPE21tAIdciO7C/xPubJB@public.gmane.org>
2014-03-09 23:25 ` Mike Frysinger
2014-03-10 11:53 ` Thomas Klausner
[not found] ` <20140310115304.GS25275-k3ZVrZPR2RPzPE21tAIdciO7C/xPubJB@public.gmane.org>
2014-03-10 12:32 ` Michael Kerrisk (man-pages)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox