bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/21532] AArch64: Symbol address inconsistency across compilation


From: nickc at redhat dot com
Subject: [Bug ld/21532] AArch64: Symbol address inconsistency across compilation units
Date: Mon, 05 Jun 2017 15:06:03 +0000

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.


reply via email to

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