This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Avoiding GOT in gold

I have some code that when using ld doesn't produce a GOT entry, but when using
gold does.

### Inputs

.long 1234

call test2

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 -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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]