dladdr() will act unexpectedly if called from non-pic code on a
compile-time-generated function pointer:
/* test_dladdr.c */
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
int
main(void)
{
void *func;
Dl_info info = {};
func = printf;
dladdr(func, &info);
printf("%s at %p resolved from %s\n", info.dli_sname,
func, info.dli_fname);
return 0;
}
$ cc test_dladdr.c -ldl
$ ./a.out
printf at 0x804838c resolved from ./a.out
$ cc -fPIC test_dladdr.c -ldl
$ ./a.out
_IO_printf at 0xb7f71c30 resolved from /lib/libc.so.6
In the long term, it might make sense to make dladdr() recognize
plt pointers and recurse, but I'm too afraid of Ulrich ;-)
(and he seems to be heavy proponent of pic code anyway, so
the chances for that to be accepted probably aren't high).
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Make it clear that LD_LIBRARY_PATH is inspected *once*, at
program start-up. (Verified from source and by experiment.)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: Michael B. Trausch <mike@trausch.us>
Various pages use inconsistent terms for 'null byte' (which
is the C99/SUSv3 term for the '\0' character).
To rectify this the following changes were made in these pages:
Replace 'zero byte' with 'null byte'.
Replace 'null character' with 'null byte'.
Replace 'nulls' with 'null bytes'.
Replace 'NUL-terminated' by 'null-terminated'.
Replace 'NUL' by 'null byte'.
Replace 'terminating NUL' by 'terminating null byte'.
Replace 'final NUL' by 'terminating null byte'.
Replace 'NUL character' by 'null byte'.