From dk@tetsuo.karasik.eu.org  Sat Sep 16 12:32:46 2006
Return-Path: <dk@tetsuo.karasik.eu.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3A7DE16A403
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 16 Sep 2006 12:32:46 +0000 (UTC)
	(envelope-from dk@tetsuo.karasik.eu.org)
Received: from tetsuo.karasik.eu.org (tetsuo.karasik.eu.org [193.88.77.78])
	by mx1.FreeBSD.org (Postfix) with ESMTP id B674543D49
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 16 Sep 2006 12:32:45 +0000 (GMT)
	(envelope-from dk@tetsuo.karasik.eu.org)
Received: by tetsuo.karasik.eu.org (Postfix, from userid 1003)
	id 7DF9239C99E; Sat, 16 Sep 2006 14:32:43 +0200 (CEST)
Message-Id: <20060916123243.7DF9239C99E@tetsuo.karasik.eu.org>
Date: Sat, 16 Sep 2006 14:32:43 +0200 (CEST)
From: Dmitry Karasik <dmitry@karasik.eu.org>
Reply-To: Dmitry Karasik <dmitry@karasik.eu.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: dlsym(NULL,) doesn't work properly 
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         103312
>Category:       kern
>Synopsis:       [libc] dlsym(NULL,) doesn't work properly
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Sep 16 12:40:19 GMT 2006
>Closed-Date:    Wed Mar 02 16:29:41 UTC 2011
>Last-Modified:  Wed Mar 02 16:29:41 UTC 2011
>Originator:     Dmitry Karasik
>Release:        FreeBSD 6.1-PRERELEASE i386
>Organization:
>Environment:
System: FreeBSD tetsuo.karasik.eu.org 6.1-PRERELEASE FreeBSD 6.1-PRERELEASE #1: Fri Mar 31 20:36:29 CEST 2006 root@flow.eu.org:/data/obj/usr/src/sys/GENERIC i386


>Description:

	man 3 dlsym states:

     If dlsym() is called with the special handle NULL, it is interpreted as a
     reference to the executable or shared object from which the call is being
     made.  

	however, dlsym(NULL,) returns NULL always.
>How-To-Repeat:

	
#include <stdio.h>
#include <dlfcn.h>
#include <math.h>

int main()
{
	void * ptr;

	ptr = fabs;
	printf("fabs: %x\n", fabs);

	ptr = dlsym( NULL, "fabs");
	if ( ptr) {
		printf("dlsym(NULL,fabs)=%x\n", fabs);
	} else {
		printf("dlsym(NULL,fabs) error:%s\n", dlerror());
	}

	ptr = dlopen( NULL, RTLD_LOCAL);
	printf("dlopen(NULL): %x\n", ptr);

	ptr = dlsym( ptr, "fabs");
	if ( ptr) {
		printf("dlsym(dlopen(NULL),fabs)=%x\n", fabs);
	} else {
		printf("dlsym(dlopen(NULL),fabs) error:%s\n", dlerror());
	}

	return 0;
	
}

>Fix:
>Release-Note:
>Audit-Trail:

From: Dmitry Karasik <dmitry@karasik.eu.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/103312: dlsym(NULL,) doesn't work properly
Date: Mon, 18 Sep 2006 16:45:53 +0200

 I've been digging myself for a workaround and realized that the problem is
 based on my assumption that for the main executable, results of dlsym(NULL,...)
 and dlsym(dlopen(NULL),...) should be identical. Now, I'm not that sure if this
 should actually be true. If it should, please let me know so I can try to fix
 this myself; otherwise please close the PR.
 
 -- 
 Sincerely,
 	Dmitry Karasik
 
State-Changed-From-To: open->closed 
State-Changed-By: jh 
State-Changed-When: Wed Mar 2 16:29:40 UTC 2011 
State-Changed-Why:  
Not a bug. Closed at submitter's request. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=103312 
>Unformatted:
