This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Avoiding GOT in gold
- From: Jethro Beekman <binutils at jbeekman dot nl>
- To: binutils at sourceware dot org
- Date: Mon, 8 Feb 2016 16:35:59 -0800
- Subject: Avoiding GOT in gold
- Authentication-results: sourceware.org; auth=none
I have some code that when using ld doesn't produce a GOT entry, but when using
gold does.
### Inputs
test1.S
=======
.data
test1:
.long 1234
.text
call test2
test2.c
=======
int test1;
int test2() {
asm volatile(""::"a"(test1));
}
### Compile
test1.S -o test1.o
gcc -fPIC -c test2.c
ar rcs test2.a test2.o
### Link with ld
ld -shared -nostdlib -Bstatic -Bsymbolic test1.o test2.a
objdump -d
0000000000000222 <test2>:
222: 55 push %rbp
223: 48 89 e5 mov %rsp,%rbp
226: 48 8d 05 1f 01 20 00 lea 0x20011f(%rip),%rax # 20034c <_edata>
22d: 8b 00 mov (%rax),%eax
22f: 5d pop %rbp
230: c3 retq
### Link with gold
ld.gold -shared -nostdlib -Bstatic -Bsymbolic test1.o test2.a
objdump -d
000000000000025d <test2>:
25d: 55 push %rbp
25e: 48 89 e5 mov %rsp,%rbp
261: 48 8b 05 60 11 00 00 mov 0x1160(%rip),%rax # 13c8 <_DYNAMIC+0x120>
268: 8b 00 mov (%rax),%eax
26a: 5d pop %rbp
26b: c3 retq
I'd like to use gold for various reasons, but how do I make gold not put test1
in the GOT here?
Jethro Beekman