From owner-freebsd-bugs@FreeBSD.ORG Wed Dec 21 10:40:10 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 20CE916A41F for ; Wed, 21 Dec 2005 10:40:10 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id ED88843D62 for ; Wed, 21 Dec 2005 10:40:04 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id jBLAe4ah088475 for ; Wed, 21 Dec 2005 10:40:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id jBLAe43t088472; Wed, 21 Dec 2005 10:40:04 GMT (envelope-from gnats) Resent-Date: Wed, 21 Dec 2005 10:40:04 GMT Resent-Message-Id: <200512211040.jBLAe43t088472@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Konstantin Oznobikhin Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9699716A425 for ; Wed, 21 Dec 2005 10:31:47 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6C8AF43D83 for ; Wed, 21 Dec 2005 10:31:40 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id jBLAVevD081770 for ; Wed, 21 Dec 2005 10:31:40 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id jBLAVdww081768; Wed, 21 Dec 2005 10:31:39 GMT (envelope-from nobody) Message-Id: <200512211031.jBLAVdww081768@www.freebsd.org> Date: Wed, 21 Dec 2005 10:31:39 GMT From: Konstantin Oznobikhin To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Cc: Subject: misc/90736: dlfunc can not be defined in libc X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Dec 2005 10:40:10 -0000 >Number: 90736 >Category: misc >Synopsis: dlfunc can not be defined in libc >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Dec 21 10:40:03 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Konstantin Oznobikhin >Release: 5.4-STABLE >Organization: Computer Center of Rostov State University >Environment: FreeBSD rocky.cc.rsu.ru 5.4-STABLE FreeBSD 5.4-STABLE #0: Tue Jul 26 17:57:13 UTC 2005 root@rocky.cc.rsu.ru:/usr/obj/usr/src/sys/rocky.athlon-xp_5 i386 >Description: The dlfunc(3) is placed in the libc to provide a C standard compliant way of getting functions addresses from shared libraries. It's implemented as a simple wrapper for the dlsym(3) (see src/lib/libc/gen/dlfunc.c). This leads to wrong determination of the calling module handle in the dlsym, which becomes libc.so instead of the module which called dlfunc. This makes impossible to correctly use NULL, RTLD_SELF and RTLD_NEXT values for handle when using dlfunc. >How-To-Repeat: compile the following with "-Xliker --export-dynamic" option to gcc and run. #include #include void foo(void) { printf("here we are!\n"); } typedef void (*foo_ptr_t)(void); int main(void) { foo_ptr_t f; f = (foo_ptr_t)dlsym(NULL, "foo"); // search for foo in the executable from which the call is being made. f(); // this one works f = (foo_ptr_t)dlfunc(NULL, "foo"); // actually searches the libc for foo f(); // this one crashes! (f is NULL now) } >Fix: One of the solutions would be to implement dlfunc in the linker itself as it done for dlopen, dlsym and other dl* functions. >Release-Note: >Audit-Trail: >Unformatted: