Date: Fri, 3 Apr 2009 14:47:04 +0200 (CEST) From: Tijl Coosemans <tijl@ulyssis.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: standards/133339: dlfunc(3) does not respect RTLD_SELF, RTLD_NEXT, ... Message-ID: <200904031247.n33Cl4Dn006871@kalimero.kotnet.org> Resent-Message-ID: <200904031250.n33Co2O4046009@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904031247.n33Cl4Dn006871>