Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 7635

Summary: dlsym can't find objects in the case of dlopen(NULL, flag)
Product: [Retired] Red Hat Linux Reporter: braddr
Component: glibcAssignee: Cristian Gafton <gafton>
Status: CLOSED NOTABUG QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 6.1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-01-05 03:16:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description braddr 1999-12-06 19:02:44 UTC
Unlike solaris, this program demonstrates that glibc has issues resolving
symbols to data elements.  I've tried it with glibc 2.0.7 and 2.1.2, both
with and without x being initialized:

#include <stdio.h>
#include <stdlib.h>

#include <dlfcn.h>

int x=1;

int main()
{
    void *handle = dlopen(NULL, RTLD_NOW);
    int *symbol = (int*)dlsym(handle, "x");
    char *errmsg = dlerror();

    printf("%d\n", x);

    if (symbol)
        printf("%d\n", *symbol);
    else
        printf("error: %s\n", errmsg);
    return 0;
}

Comment 1 braddr 1999-12-06 22:47:59 UTC
Actually, it seems unable to locate any local symbols.. main, or if I add
another function it can't look up that one either.  It seems that
dlopen(NULL,blah) is what's broken possibly.

Comment 2 braddr 1999-12-13 19:27:59 UTC
change the sort desc to match the actual bug report

Comment 3 Cristian Gafton 2000-01-05 03:02:59 UTC
Yepp, this is a bug.

Comment 4 Cristian Gafton 2000-01-05 03:16:59 UTC
Oops, not really a bug. You need to pass -rdynamic at the link time to have this
fucntionality (you need to be able to access your own proram space like a shared
object)