diff options
author | kib <kib@FreeBSD.org> | 2009-04-03 19:17:23 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2009-04-03 19:17:23 +0000 |
commit | d2fcac0ee269d1860c774a5ecf65296ce9417c84 (patch) | |
tree | 49cd2d7fe74d5b0bb669f8057c2e879c1c85b348 /libexec | |
parent | cde6991b73026c367b500f4d6e6fa8a7e0af8c79 (diff) | |
download | FreeBSD-src-d2fcac0ee269d1860c774a5ecf65296ce9417c84.zip FreeBSD-src-d2fcac0ee269d1860c774a5ecf65296ce9417c84.tar.gz |
Allow the NULL, RTLD_SELF and RTLD_NEXT handles to work with dlfunc(3).
dlfunc() called dlsym() to do the work, and dlsym() determines the dso
that originating the call by the return address. Due to this, dlfunc()
operated as if the caller is always the libc.
To fix this, move the dlfunc() to rtld, where it can call the internal
implementation of dlsym, and still correctly fetch return address.
Provide usual weak stub for the symbol from libc for static binaries.
dlfunc is put to FBSD_1.0 symver namespace in the ld.so export to
override dlfunc@FBSD_1.0 weak symbol, exported by libc.
Reported, analyzed and tested by: Tijl Coosemans <tijl ulyssis org>
PR: standards/133339
Reviewed by: kan
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/rtld-elf/Symbol.map | 1 | ||||
-rw-r--r-- | libexec/rtld-elf/rtld.c | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/libexec/rtld-elf/Symbol.map b/libexec/rtld-elf/Symbol.map index 20f8d60..ce1e3e5 100644 --- a/libexec/rtld-elf/Symbol.map +++ b/libexec/rtld-elf/Symbol.map @@ -8,6 +8,7 @@ FBSD_1.0 { dlerror; dlopen; dlsym; + dlfunc; dlvsym; dladdr; dllockinit; diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 07529b3..40ed6ed 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -200,6 +200,7 @@ static func_ptr_type exports[] = { (func_ptr_type) &dlerror, (func_ptr_type) &dlopen, (func_ptr_type) &dlsym, + (func_ptr_type) &dlfunc, (func_ptr_type) &dlvsym, (func_ptr_type) &dladdr, (func_ptr_type) &dllockinit, @@ -2170,6 +2171,19 @@ dlsym(void *handle, const char *name) SYMLOOK_DLSYM); } +dlfunc_t +dlfunc(void *handle, const char *name) +{ + union { + void *d; + dlfunc_t f; + } rv; + + rv.d = do_dlsym(handle, name, __builtin_return_address(0), NULL, + SYMLOOK_DLSYM); + return (rv.f); +} + void * dlvsym(void *handle, const char *name, const char *version) { |