standards/133339: dlfunc(3) does not respect RTLD_SELF, RTLD_NEXT,
...
Tijl Coosemans
tijl at ulyssis.org
Fri Apr 3 05:50:02 PDT 2009
>Number: 133339
>Category: standards
>Synopsis: dlfunc(3) does not respect RTLD_SELF, RTLD_NEXT,...
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-standards
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Apr 03 12:50:01 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator: Tijl Coosemans
>Release: FreeBSD 7.1-STABLE i386
>Organization:
>Environment:
FreeBSD 7.1-STABLE #4: Tue Mar 10 16:04:51 CET 2009
>Description:
The dlfunc(3) function doesn't respect special handles like
NULL, RTLD_SELF, RTLD_NEXT as explained in the manpage.
In those cases dlsym(3) determines the list of objects to
search through by looking at the return address on the stack
to figure out which object the call originated from.
Because dlfunc has been implemented in libc as a simple
wrapper around dlsym, the return address on the stack
points to libc and not the object the call originated from
like the main program or another library.
>How-To-Repeat:
I've attached a small test program that should print the same
address twice, but it currently prints NULL in the dlfunc case.
>Fix:
I'm guessing dlfunc has to be moved to rtld (strong alias
to dlsym perhaps) and the current implementation in libc
replaced with a dummy implementation like the other dl*
functions in lib/libc/gen/dlfcn.c.
--- test.c begins here ---
#include <dlfcn.h>
#include <stdio.h>
int main( void ) {
void *addr;
addr = dlsym( RTLD_NEXT, "getpid" );
printf( "%p\n", addr ); /* this works */
addr = dlfunc( RTLD_NEXT, "getpid" );
printf( "%p\n", addr ); /* this prints NULL */
return( 0 );
}
--- test.c ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-standards
mailing list