https://sourceware.org/bugzilla/show_bug.cgi?id=21532
--- Comment #1 from Nick Clifton <nickc at redhat dot com> ---
Here is a reduced, C based, test case:
% cat main.c
extern int int_datum_1;
extern int int_datum_2;
extern int printf (const char *, ...);
extern void call_lib (void);
int * ptr1 = & int_datum_1;
int main (void)
{
printf ("main: int data = %p %p\n", & int_datum_1, & int_datum_2);
call_lib ();
return 0;
}
% cat lib.c
int int_datum_1 = 1;
int int_datum_2 = 1;
extern int printf (const char *, ...);
void call_lib (void)
{
printf ("lib : int data = %p %p\n", & int_datum_1, & int_datum_2);
}
% gcc -fPIC -c main.c lib.c
% gcc -fPIC -Wl,-Bsymbolic,-z,defs,-soname,libfred.so -shared -o libl.so
lib.o
% gcc -fPIC -o test main.o libl.so
% LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH ./test
main: int data = 0x420038 0xffff93f40018
lib : int data = 0xffff93f4001c 0xffff93f40018
Note how the address of int_datum_2 is consistent, but the address of
int_datum_1 differs. The difference is that the address of int_datum_1
is used to initialise ptr1 in main.c.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
bug-binutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-binutils