This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [gold] 2.27 generates GOT where 2.26 did not
- From: Andrew Pinski <pinskia at gmail dot com>
- To: Jethro Beekman <binutils at jbeekman dot nl>
- Cc: binutils <binutils at sourceware dot org>
- Date: Thu, 11 Aug 2016 20:10:31 -0700
- Subject: Re: [gold] 2.27 generates GOT where 2.26 did not
- Authentication-results: sourceware.org; auth=none
- References: <dd6f4d4b-5f5f-459c-8c3b-955f6c329233@jbeekman.nl>
On Thu, Aug 11, 2016 at 5:31 PM, Jethro Beekman <binutils@jbeekman.nl> wrote:
> I have these two files:
>
> // asm_var.S
> .section .rodata
> .global asm_var
> .protected asm_var
> .size asm_var, 8
> asm_var:
> .org .+8
>
> // get_addr.c
> extern unsigned long asm_var;
>
> void* get_addr() {
> return &asm_var;
> }
>
> That I compile with:
> gcc -O3 -fuse-ld=gold -fPIC -shared -nostdlib -Wl,-Bsymbolic asm_var.S get_addr.c
>
> With gold 2.26.1 (and most likely older versions as well), this results in:
>
> 00000000000002f0 <get_addr>:
> 2f0: 48 8d 05 01 00 00 00 lea 0x1(%rip),%rax # 2f8 <asm_var>
> 2f7: c3 retq
>
> Yet with 2.27 this results in:
>
> 0000000000000340 <get_addr>:
> 340: 48 8b 05 99 1c 00 00 mov 0x1c99(%rip),%rax # 1fe0 <_DYNAMIC+0x110>
> 347: c3 retq
>
> What's at 1fe0?
>
> 000000001fe0 000500000006 R_X86_64_GLOB_DAT 0000000000000348 asm_var + 0
>
> Is this a regression in 2.27? I really don't want to use the GOT. Is there a
> flag I can pass to get the old behavior?
IIRC this is correct behavior for x86_64 due to copy relocs.
Thanks,
Andrew
>
> Jethro Beekman