https://sourceware.org/bugzilla/show_bug.cgi?id=32443

--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to H.J. Lu from comment #7)
> (In reply to Stephen Kell from comment #5)
> > > When compiler sees a hidden undefined symbol, it assumes that
> > > it is defined somewhere else and it isn't an ABS symbol.  As
> > > the result, you won't get 0x2a.
> > 
> > I see. In what way does the "not an ABS symbol" assumption affect the
> > compiler output?
> 
> Compiler generates
> 
>       leaq    value(%rip), %rax
> 
> for hidden symbol reference without GOT and you won't get 0x2a
> at run-time.

[hjl@gnu-tgl-3 pr32443]$ cat pie.c 
#include <stdio.h>
#include <stdint.h>

extern int value __attribute__ ((visibility("hidden")));

void
lib_func (void)
{
  printf ("value: %p\n", &value);
}

int
main(void)
{
  lib_func();
  return 0;
}
[hjl@gnu-tgl-3 pr32443]$ gcc -pie -g -Wl,-R,. -Wl,--defsym,value=42 -o pie
pie.o
[hjl@gnu-tgl-3 pr32443]$ ./pie
value: 0x556f3cbdb02a
[hjl@gnu-tgl-3 pr32443]$

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to