From owner-freebsd-standards@FreeBSD.ORG Fri Apr 3 12:50:02 2009 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 56E36106566B for ; Fri, 3 Apr 2009 12:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 2DEBA8FC26 for ; Fri, 3 Apr 2009 12:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n33Co2hc046010 for ; Fri, 3 Apr 2009 12:50:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n33Co2O4046009; Fri, 3 Apr 2009 12:50:02 GMT (envelope-from gnats) Resent-Date: Fri, 3 Apr 2009 12:50:02 GMT Resent-Message-Id: <200904031250.n33Co2O4046009@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-standards@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Tijl Coosemans Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 049FB106568C for ; Fri, 3 Apr 2009 12:47:12 +0000 (UTC) (envelope-from tijl@kalimero.kotnet.org) Received: from mailrelay004.isp.belgacom.be (mailrelay004.isp.belgacom.be [195.238.6.170]) by mx1.freebsd.org (Postfix) with ESMTP id 94F0F8FC1C for ; Fri, 3 Apr 2009 12:47:11 +0000 (UTC) (envelope-from tijl@kalimero.kotnet.org) Received: from 107.213-244-81.adsl-dyn.isp.belgacom.be (HELO kalimero.kotnet.org) ([81.244.213.107]) by relay.skynet.be with ESMTP; 03 Apr 2009 14:47:09 +0200 Received: from kalimero.kotnet.org (kalimero.kotnet.org [127.0.0.1]) by kalimero.kotnet.org (8.14.3/8.14.3) with ESMTP id n33Cl4MC006872 for ; Fri, 3 Apr 2009 14:47:04 +0200 (CEST) (envelope-from tijl@kalimero.kotnet.org) Received: (from tijl@localhost) by kalimero.kotnet.org (8.14.3/8.14.3/Submit) id n33Cl4Dn006871; Fri, 3 Apr 2009 14:47:04 +0200 (CEST) (envelope-from tijl) Message-Id: <200904031247.n33Cl4Dn006871@kalimero.kotnet.org> Date: Fri, 3 Apr 2009 14:47:04 +0200 (CEST) From: Tijl Coosemans To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: standards/133339: dlfunc(3) does not respect RTLD_SELF, RTLD_NEXT, ... X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Tijl Coosemans List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Apr 2009 12:50:02 -0000 >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 #include 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: