bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ld-2.3.2.so libc-2.3.2.so : first available symbol used even if it is we


From: Sunil Kuravinakop
Subject: ld-2.3.2.so libc-2.3.2.so : first available symbol used even if it is weak.
Date: Thu, 7 Aug 2003 16:23:40 -0700


Hello,

        I define wrappers for some functions in std libraries like libdl.so. These wrapped functions are defined weak. After updating to libc-2.3.2.so package I find that the first available symbol is picked up instead of searching for a strong symbol. The dynamic linker was updated to ld-2.2.93.so as part of the glibc package.
e.g.

File j.c:

#include <stdio.h>

#pragma weak dlopen
void *dlopen(const char *filename, int flag) {

   printf("Weak dlopen \n");
    return NULL;
}

File main.c:

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

int main()
{
    printf("0x%x \n",dlopen("/lib/libc.so.6",RTLD_LAZY));
}

gcc -g -fpic -shared j.c -o libj.so

1st :
-----
gcc -g main.c -ldl -L. -lj  
a.out output : 0x8049688 i.e. a non-NULL output.

2nd:
------
gcc -g main.c -L. -lj -ldl
a.out output : "Weak dlopen"
                  0x0



   Am I doing anything wrong here?  Thanks for the help.
regards,
--Sunil
reply via email to

[Prev in Thread] Current Thread [Next in Thread]