bash-3.1$ cat foo.c extern char x __attribute__((weak, visibility("hidden"))); void *_start(void) { return &x; } bash-3.1$ make gcc -fPIC -c -o foo.o foo.c ld -Ttext 100000000 -o foo foo.o objdump -dr foo.o
foo.o: file format elf64-x86-64 Disassembly of section .text: 0000000000000000 <_start>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 48 8d 05 00 00 00 00 lea 0(%rip),%rax # b <_start+0xb> 7: R_X86_64_PC32 x+0xfffffffffffffffc b: c9 leaveq c: c3 retq objdump -d foo foo: file format elf64-x86-64 Disassembly of section .text: 0000000100000000 <_start>: 100000000: 55 push %rbp 100000001: 48 89 e5 mov %rsp,%rbp 100000004: 48 8d 05 f5 ff ff ff lea -11(%rip),%rax # 100000000 <_start> 10000000b: c9 leaveq 10000000c: c3 retq bash-3.1$ Linker ignores relocation overflow. As the result, &x is no longer 0. This change was introduced by http://sourceware.org/ml/binutils/2004-06/msg00199.html -- Summary: x86-64 linker ignores relocation overflow Product: binutils Version: 2.18 (HEAD) Status: NEW Severity: normal Priority: P2 Component: ld AssignedTo: unassigned at sources dot redhat dot com ReportedBy: hjl at lucon dot org CC: amodra at bigpond dot net dot au,bug-binutils at gnu dot org http://sourceware.org/bugzilla/show_bug.cgi?id=3283 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils