Bug 13082 - Invalid R_X86_64_64 relocation for x32
Summary: Invalid R_X86_64_64 relocation for x32
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-12 04:22 UTC by H.J. Lu
Modified: 2011-08-14 14:37 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2011-08-12 04:22:31 UTC
[hjl@gnu-6 pr-y]$ cat x.s
	.text
	.globl main
main:
	lea	.Ljmp(%rip), %rax
	jmp	*(%rax)
	.section	.data.rel.ro.local,"aw",@progbits
	.align	8, 0x90
.Ljmp:
	.quad main
[hjl@gnu-6 pr-y]$ make X32=1
as --x32 -o x.o x.s
./ld -shared -m elf32_x86_64 -o x.so x.o
./ld -pie -m elf32_x86_64 -o x.pie x.o
./ld: warning: cannot find entry symbol _start; defaulting to 0000000000000184
./ld -m elf32_x86_64 -o x x.o
./ld: warning: cannot find entry symbol _start; defaulting to 0000000000400074
readelf -r x

There are no relocations in this file.
readelf -r x.pie

Relocation section '.rela.dyn' at offset 0x178 contains 1 entries:
 Offset     Info    Type            Sym.Value  Sym. Name + Addend
00200190  00000101 R_X86_64_64       000000d4   .interp + 184
readelf -r x.so

Relocation section '.rela.dyn' at offset 0x140 contains 1 entries:
 Offset     Info    Type            Sym.Value  Sym. Name + Addend
00200158  00000301 R_X86_64_64       0000014c   main + 0
[hjl@gnu-6 pr-y]$ 
[hjl@gnu-6 pr-x]$ make clean
rm -f a.out *.o *.so
[hjl@gnu-6 pr-x]$ cat x.s
	.text
	.globl main
main:
	lea	.Ljmp(%rip), %rax
	jmp	*(%rax)
.L1:
	nop
	.section	.data.rel.ro.local,"aw",@progbits
	.align	8, 0x90
.Ljmp:
	.quad .L1
[hjl@gnu-6 pr-x]$ make X32=yes
as --x32 -o x.o x.s
./ld -shared -m elf32_x86_64 -o x.so x.o
./ld -pie -m elf32_x86_64 -o x.pie x.o
./ld: warning: cannot find entry symbol _start; defaulting to 0000000000000184
./ld -m elf32_x86_64 -o x x.o
./ld: warning: cannot find entry symbol _start; defaulting to 0000000000400074
readelf -r x

There are no relocations in this file.
readelf -r x.pie

Relocation section '.rela.dyn' at offset 0x178 contains 1 entries:
 Offset     Info    Type            Sym.Value  Sym. Name + Addend
00200190  00000101 R_X86_64_64       000000d4   .interp + 18d
readelf -r x.so

Relocation section '.rela.dyn' at offset 0x140 contains 1 entries:
 Offset     Info    Type            Sym.Value  Sym. Name + Addend
00200158  00000101 R_X86_64_64       0000014c   .text + 155
[hjl@gnu-6 pr-x]$
Comment 1 Sourceware Commits 2011-08-12 19:42:44 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2011-08-12 19:42:40

Modified files:
	bfd            : ChangeLog elf64-x86-64.c 
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-x86-64: x86-64.exp 
Added files:
	ld/testsuite/ld-x86-64: pr13082-1.s pr13082-1a.d pr13082-1b.d 
	                        pr13082-2.s pr13082-2a.d pr13082-2b.d 
	                        pr13082-3.s pr13082-3a.d pr13082-3b.d 
	                        pr13082-4.s pr13082-4a.d pr13082-4b.d 
	                        pr13082-5.s pr13082-5a.d pr13082-5b.d 
	                        pr13082-6.s pr13082-6a.d pr13082-6b.d 

Log message:
	Add R_X86_64_RELATIVE64 and handle R_X86_64_64 for x32.
	
	bfd/
	
	2011-08-12  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/13082
	* elf64-x86-64.c (x86_64_elf_howto_table): Add R_X86_64_RELATIVE64.
	(elf_x86_64_relocate_section): Treat R_X86_64_64 like R_X86_64_32
	and zero-extend it to 64bit if addend is zero for x32.  Generate
	R_X86_64_RELATIVE64 for x32.
	
	include/elf/
	
	2011-08-12  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/13082
	* x86-64.h (R_X86_64_RELATIVE64): New.
	
	ld/testsuite/
	
	2011-08-12  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/13082
	* ld-x86-64/pr13082-1.s: New.
	* ld-x86-64/pr13082-1a.d: Likewise.
	* ld-x86-64/pr13082-1b.d: Likewise.
	* ld-x86-64/pr13082-2.s: Likewise.
	* ld-x86-64/pr13082-2a.d: Likewise.
	* ld-x86-64/pr13082-2b.d: Likewise.
	* ld-x86-64/pr13082-3.s: Likewise.
	* ld-x86-64/pr13082-3a.d: Likewise.
	* ld-x86-64/pr13082-3b.d: Likewise.
	* ld-x86-64/pr13082-4.s: Likewise.
	* ld-x86-64/pr13082-4a.d: Likewise.
	* ld-x86-64/pr13082-4b.d: Likewise.
	* ld-x86-64/pr13082-5.s: Likewise.
	* ld-x86-64/pr13082-5a.d: Likewise.
	* ld-x86-64/pr13082-5b.d: Likewise.
	* ld-x86-64/pr13082-6.s: Likewise.
	* ld-x86-64/pr13082-6a.d: Likewise.
	* ld-x86-64/pr13082-6b.d: Likewise.
	
	* ld-x86-64/x86-64.exp: Run pr13082-[1-6][ab].

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5455&r2=1.5456
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=src&r1=1.238&r2=1.239
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1453&r2=1.1454
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-1.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-1a.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-1b.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-2.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-2a.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-2b.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-3.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-3a.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-3b.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-4.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-4a.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-4b.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-5.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-5a.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-5b.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-6.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-6a.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13082-6b.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/x86-64.exp.diff?cvsroot=src&r1=1.36&r2=1.37
Comment 2 Sourceware Commits 2011-08-12 20:33:48 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2011-08-12 20:33:34

Modified files:
	include/elf    : ChangeLog x86-64.h 

Log message:
	Add R_X86_64_RELATIVE64.
	
	2011-08-12  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/13082
	* x86-64.h (R_X86_64_RELATIVE64): New.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/elf/ChangeLog.diff?cvsroot=src&r1=1.427&r2=1.428
http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/elf/x86-64.h.diff?cvsroot=src&r1=1.14&r2=1.15
Comment 3 H.J. Lu 2011-08-14 14:37:55 UTC
Fixed.