This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Dynamic loader problem
- To: gnu-gcc-bug at moderators dot isc dot org
- Subject: Dynamic loader problem
- From: Igor Mordkovitch <igorm at mainsoft dot com>
- Date: Wed, 18 Aug 1999 20:01:29 +0200
- Newsgroups: gnu.gcc.bug,gnu.gcc.help
- Organization: Mainsoft
- Reply-To: igorm at mainsoft dot com
Hi,
Seems there is a bug in the dynamic loader. I have symbol defined in
the shared library. When I try to work with it from the code which is
outside the library (.o file), I see another value and it's address
isn't the same.
I'm running RH 6.0 , gcc 2.95
Simple example attached:
/*
main.c:
*/
/***********************************************/
#include <stdio.h>
extern int libi;
extern void printlibi();
main()
{
printlibi();
printf("main.c: Address of libi is %lx, libi is %d\n", &libi, libi);
}
/*
lib.c
*/
#include <stdio.h>
int libi=0;
void printlibi()
{
libi = 10;
printf("lib.c: Address of libi is %lx, libi is %d\n", &libi, libi);
}
Build it this way:
gcc -shared -Wl,-Bsymbolic lib.c -o liblll.so
gcc main.c liblll.so
a.out:
(First add . to the LD_LIBRARY_PATH)
lib.c: Address of libi is 40015674, libi is 10
main.c: Address of libi is 804975c, libi is 0
As you see, address is different.
If you try 'nm' on a.out, you can see line like
0804975c B libi
which means, IMHO, that symbol libi is already resolved. Should it?
Any help will be appreciated.
Thanks,
Igor