Bug 7635 - dlsym can't find objects in the case of dlopen(NULL, flag)
dlsym can't find objects in the case of dlopen(NULL, flag)
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Cristian Gafton
Depends On:
  Show dependency treegraph
Reported: 1999-12-06 14:02 EST by braddr
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-01-04 22:16:47 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description braddr 1999-12-06 14:02:44 EST
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);
        printf("error: %s\n", errmsg);
    return 0;
Comment 1 braddr 1999-12-06 17:47:59 EST
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 14:27:59 EST
change the sort desc to match the actual bug report
Comment 3 Cristian Gafton 2000-01-04 22:02:59 EST
Yepp, this is a bug.
Comment 4 Cristian Gafton 2000-01-04 22:16:59 EST
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

Note You need to log in before you can comment on or make changes to this bug.