bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/20117] New: GOT relocation changes another instruction


From: louis.granboulan.developer at gmail dot com
Subject: [Bug ld/20117] New: GOT relocation changes another instruction
Date: Thu, 19 May 2016 09:39:37 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=20117

            Bug ID: 20117
           Summary: GOT relocation changes another instruction
           Product: binutils
           Version: 2.25
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: louis.granboulan.developer at gmail dot com
  Target Milestone: ---

Created attachment 9278
  --> https://sourceware.org/bugzilla/attachment.cgi?id=9278&action=edit
Almost minimal example that triggers the bug

Using the attached file, on a recent Debian (with gcc 4.9.2 as the default
compiler), we can reproduce the bug with the following steps.

echo 'long DEBUGLEVEL; int main(){return 66;}' > main.c
gcc -m32 -c -o main.o main.c
gcc -m32 -c -o bug-ld.o bug-ld.s
gcc -m32 -o main main.o bug-ld.o

The bug can be seen using objdump.
objdump -d bug-ld.o | grep jmp
returns
  73:   eb 8b                   jmp    0 <bug>
but
objdump -d main | grep jmp
 80482a6:       ff 25 bc 96 04 08       jmp    *0x80496bc
 80482b0:       ff 25 c0 96 04 08       jmp    *0x80496c0
 80482bb:       e9 e0 ff ff ff          jmp    80482a0 <_init+0x2c>
 80482c0:       ff 25 c4 96 04 08       jmp    *0x80496c4
 80482cb:       e9 d0 ff ff ff          jmp    80482a0 <_init+0x2c>
 80483ab:       eb 93                   jmp    8048340 <register_tm_clones>
 80483c6:       e9 75 ff ff ff          jmp    8048340 <register_tm_clones>
 8048448:       eb 8d                   jmp    80483d7 <bug+0x2>
 80484b1:       eb 0d                   jmp    80484c0 <__libc_csu_fini>

We can see that "eb 8b" has been transformed to "eb 8d".

This appears to be a bug of ld. The last command can be replaced by

ld -m elf_i386 -o main main.o bug-ld.o
/usr/lib/gcc/x86_64-linux-gnu/4.9/32/crtend.o /usr/lib32/crtn.o
/usr/lib32/crt1.o /usr/lib32/crti.o
/usr/lib/gcc/x86_64-linux-gnu/4.9/32/crtbegin.o -lc

The bug is diffult to trigger: if you replace in bug-ld.s 0xeb, 0x8b by
something else, e.g. 0xeb, 0x8c, then the bug is not triggered.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]