This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Dynamic loader problem




	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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]