[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gold/14091] New: Gold doesn't handle R_X86_64_RELATIVE properly for
From: |
hjl.tools at gmail dot com |
Subject: |
[Bug gold/14091] New: Gold doesn't handle R_X86_64_RELATIVE properly for x32 |
Date: |
Thu, 10 May 2012 14:04:07 +0000 |
http://sourceware.org/bugzilla/show_bug.cgi?id=14091
Bug #: 14091
Summary: Gold doesn't handle R_X86_64_RELATIVE properly for x32
Product: binutils
Version: 2.23 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: gold
AssignedTo: address@hidden
ReportedBy: address@hidden
CC: address@hidden
Classification: Unclassified
address@hidden gold]$ cat main.c
extern void foo (void);
int
main (void)
{
foo ();
return 0;
}
address@hidden gold]$ cat tst-quadmod2.S
#define BIAS 0x7fff0000
.section .data.rel.local,"aw",@progbits
.align 8
.Ljmp:
.quad func + BIAS
.text
.type func, @function
func:
.cfi_startproc
xorl %edi, %edi
jmp address@hidden
.cfi_endproc
.size func, .-func
.globl foo
.type foo, @function
foo:
.cfi_startproc
.cfi_def_cfa_register 6
movq .Ljmp(%rip), %rax
subq $BIAS, %rax
jmp *%rax
.cfi_endproc
.size foo, .-foo
address@hidden gold]$ make
gcc -B./ -mx32 -g -c -o main.o main.c
gcc -B./ -mx32 -c -g -o tst-quadmod2.o tst-quadmod2.S
./ld -shared -m elf32_x86_64 -o libtst-quadmod2.so tst-quadmod2.o
gcc -B./ -mx32 -g -o x2 main.o libtst-quadmod2.so -Wl,-rpath,.
./readelf -r --wide libtst-quadmod2.so
Relocation section '.rela.dyn' at offset 0x164 contains 1 entries:
Offset Info Type Sym. Value Symbol's Name + Addend
000012f0 00000008 R_X86_64_RELATIVE 7fff01a0
Relocation section '.rela.plt' at offset 0x170 contains 1 entries:
Offset Info Type Sym. Value Symbol's Name + Addend
000012e8 00000107 R_X86_64_JUMP_SLOT 00000000 exit + 0
./x2
make: *** [all] Segmentation fault
address@hidden gold]$
The problem is
address@hidden gold]$ readelf -rW tst-quadmod2.o
...
Offset Info Type Sym. Value Symbol's Name + Addend
00000000 00000101 R_X86_64_64 00000000 .text + 7fff0000
Symbol value + addend > 32bits at run-time. BFD linker generates:
address@hidden gold]$ make LD=ld
gcc -B./ -mx32 -g -c -o main.o main.c
gcc -B./ -mx32 -c -g -o tst-quadmod2.o tst-quadmod2.S
ld -shared -m elf32_x86_64 -o libtst-quadmod2.so tst-quadmod2.o
gcc -B./ -mx32 -g -o x2 main.o libtst-quadmod2.so -Wl,-rpath,.
./readelf -r --wide libtst-quadmod2.so
Relocation section '.rela.dyn' at offset 0x158 contains 1 entries:
Offset Info Type Sym. Value Symbol's Name + Addend
002002b0 00000026 R_X86_64_RELATIVE64 7fff0190
Relocation section '.rela.plt' at offset 0x164 contains 1 entries:
Offset Info Type Sym. Value Symbol's Name + Addend
address@hidden gold]$
The difference is R_X86_64_RELATIVE64 vs R_X86_64_RELATIVE. For
R_X86_64_64, we need to generate R_X86_64_RELATIVE64.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
- [Bug gold/14091] New: Gold doesn't handle R_X86_64_RELATIVE properly for x32,
hjl.tools at gmail dot com <=