Bug 14088 - Strange addend from readelf
Summary: Strange addend from readelf
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-10 03:57 UTC by H.J. Lu
Modified: 2017-02-01 22:26 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 2012-05-10 03:57:54 UTC
On Linux/x86-64, I got

[hjl@gnu-6 runtime]$ 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	exit@PLT
	.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
[hjl@gnu-6 runtime]$ make libtst-quadmod2.so
gcc -B./ -c -g -o tst-quadmod2.o tst-quadmod2.S
./ld -shared  -o libtst-quadmod2.so tst-quadmod2.o
[hjl@gnu-6 runtime]$ readelf -r libtst-quadmod2.so

Relocation section '.rela.dyn' at offset 0x1e8 contains 1 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
0000002003f8  000000000008 R_X86_64_RELATIVE                    ffffffff80010240

Relocation section '.rela.plt' at offset 0x200 contains 1 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
0000002003f0  000600000007 R_X86_64_JUMP_SLO 0000000000000000 exit + 0

Addend for R_X86_64_RELATIVE is a negative number. But it is displayed
as an address.
Comment 1 Andreas Schwab 2012-05-10 08:00:19 UTC
Displaying it as a decimal number would be much less useful.
Comment 2 Sourceware Commits 2012-05-11 15:48:22 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2012-05-11 15:48:15

Modified files:
	binutils       : ChangeLog readelf.c 
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-ia64: tlspic.rd 
	ld/testsuite/ld-x86-64: tlsdesc-nacl.rd tlsdesc.rd 
	                        tlspic-nacl.rd tlspic.rd 

Log message:
	Always display addend as signed hex number
	
	binutils/
	
	PR binutils/14088
	* readelf.c (dump_relocations): Always display addend as
	signed hex number.
	
	ld/testsuite/
	
	PR binutils/14088
	* ld-ia64/tlspic.rd: Updated.
	* ld-x86-64/tlsdesc-nacl.rd: Likewise.
	* ld-x86-64/tlsdesc.rd: Likewise.
	* ld-x86-64/tlspic-nacl.rd: Likewise.
	* ld-x86-64/tlspic.rd: Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/ChangeLog.diff?cvsroot=src&r1=1.1903&r2=1.1904
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/readelf.c.diff?cvsroot=src&r1=1.570&r2=1.571
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1523&r2=1.1524
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ia64/tlspic.rd.diff?cvsroot=src&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/tlsdesc-nacl.rd.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/tlsdesc.rd.diff?cvsroot=src&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/tlspic-nacl.rd.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/tlspic.rd.diff?cvsroot=src&r1=1.16&r2=1.17
Comment 3 H.J. Lu 2012-05-11 15:50:19 UTC
Fixed.
Comment 4 Sourceware Commits 2017-02-01 22:20:47 UTC
The master branch has been updated by Maciej W. Rozycki <macro@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c0c237fcdd133e84e67657cc6b7e4678f106bdcb

commit c0c237fcdd133e84e67657cc6b7e4678f106bdcb
Author: Maciej W. Rozycki <macro@imgtec.com>
Date:   Wed Feb 1 22:09:33 2017 +0000

    MIPS/LD/testsuite: Correct relocation addends in VxWorks tests
    
    Fix commit 171191bac50e ("Add support for STT_IFUNC"),
    <https://sourceware.org/ml/binutils/2008-12/msg00052.html>, commit
    e04d7088afe0 ("PR ld/14088: Always display addend as signed hex
    number"), <https://sourceware.org/ml/binutils/2012-05/msg00123.html> and
    commit 343dbc36ffae ("Print addend as signed in objdump"),
    <https://sourceware.org/ml/binutils/2012-05/msg00163.html> regressions:
    
    FAIL: VxWorks executable test 1 (dynamic)
    FAIL: ld-mips-elf/vxworks-forced-local-1
    
    seen with `mips-vxworks' and `mipsel-vxworks' targets and adjust dump
    patterns according to changes made to the presentation of relocation
    addends in `readelf -r' and `objdump -r' output.
    
    	ld/
    	* testsuite/ld-mips-elf/vxworks-forced-local-1.d: Correct the
    	presentation of relocation addends.
    	* testsuite/ld-mips-elf/vxworks1-lib.rd: Likewise.
    	* testsuite/ld-mips-elf/vxworks1.dd: Likewise.
    	* testsuite/ld-mips-elf/vxworks1.rd: Likewise.
Comment 5 Sourceware Commits 2017-02-01 22:26:11 UTC
The binutils-2_28-branch branch has been updated by Maciej W. Rozycki <macro@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1d0d283e6bcc643c6ca96edd7ac4551e09d9975d

commit 1d0d283e6bcc643c6ca96edd7ac4551e09d9975d
Author: Maciej W. Rozycki <macro@imgtec.com>
Date:   Wed Feb 1 22:09:33 2017 +0000

    MIPS/LD/testsuite: Correct relocation addends in VxWorks tests
    
    Fix commit 171191bac50e ("Add support for STT_IFUNC"),
    <https://sourceware.org/ml/binutils/2008-12/msg00052.html>, commit
    e04d7088afe0 ("PR ld/14088: Always display addend as signed hex
    number"), <https://sourceware.org/ml/binutils/2012-05/msg00123.html> and
    commit 343dbc36ffae ("Print addend as signed in objdump"),
    <https://sourceware.org/ml/binutils/2012-05/msg00163.html> regressions:
    
    FAIL: VxWorks executable test 1 (dynamic)
    FAIL: ld-mips-elf/vxworks-forced-local-1
    
    seen with `mips-vxworks' and `mipsel-vxworks' targets and adjust dump
    patterns according to changes made to the presentation of relocation
    addends in `readelf -r' and `objdump -r' output.
    
    	ld/
    	* testsuite/ld-mips-elf/vxworks-forced-local-1.d: Correct the
    	presentation of relocation addends.
    	* testsuite/ld-mips-elf/vxworks1-lib.rd: Likewise.
    	* testsuite/ld-mips-elf/vxworks1.dd: Likewise.
    	* testsuite/ld-mips-elf/vxworks1.rd: Likewise.
    
    (cherry picked from commit c0c237fcdd133e84e67657cc6b7e4678f106bdcb)