[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/19601] New: Wrong GOT offset used with GOT relocation
From: |
hjl.tools at gmail dot com |
Subject: |
[Bug ld/19601] New: Wrong GOT offset used with GOT relocation |
Date: |
Wed, 10 Feb 2016 18:21:22 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=19601
Bug ID: 19601
Summary: Wrong GOT offset used with GOT relocation
Product: binutils
Version: 2.26
Status: NEW
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: hjl.tools at gmail dot com
Target Milestone: ---
Target: i386
address@hidden lea-5]$ cat main.c
extern void foo1 (void);
extern void foo2 (void);
typedef void (* func) (void);
extern func func_p (void);
int
_start ()
{
func f = func_p ();
foo1 ();
foo2 ();
if (f)
f ();
return 0;
}
address@hidden lea-5]$ cat foo1.c
extern void bar (void) __attribute__((weak));
void
foo1 (void)
{
if (bar)
bar ();
}
address@hidden lea-5]$ cat foo2.c
extern void bar (void) __attribute__((weak));
void
foo2 (void)
{
if (bar)
bar ();
}
address@hidden lea-5]$ make
gcc -B./ -m32 -O2 -fPIC -c -o main.o main.c
gcc -B./ -m32 -O2 -fPIC -c -o foo1.o foo1.c
gcc -B./ -m32 -O2 -fPIC -Wa,-mrelax-relocations=no -c -o bar.o bar.c
gcc -B./ -m32 -O2 -fPIC -c -o foo2.o foo2.c
./ld -m elf_i386 -static -o x main.o foo1.o bar.o foo2.o
objdump -dw x
x: file format elf32-i386
Disassembly of section .text:
080480a0 <_start>:
80480a0: 56 push %esi
80480a1: 53 push %ebx
80480a2: e8 28 00 00 00 call 80480cf <__x86.get_pc_thunk.bx>
80480a7: 81 c3 71 11 00 00 add $0x1171,%ebx
80480ad: 83 ec 04 sub $0x4,%esp
80480b0: e8 5b 00 00 00 call 8048110 <func_p>
80480b5: 89 c6 mov %eax,%esi
80480b7: e8 24 00 00 00 call 80480e0 <foo1>
80480bc: e8 6f 00 00 00 call 8048130 <foo2>
80480c1: 85 f6 test %esi,%esi
80480c3: 74 02 je 80480c7 <_start+0x27>
80480c5: ff d6 call *%esi
80480c7: 83 c4 04 add $0x4,%esp
80480ca: 31 c0 xor %eax,%eax
80480cc: 5b pop %ebx
80480cd: 5e pop %esi
80480ce: c3 ret
080480cf <__x86.get_pc_thunk.bx>:
80480cf: 8b 1c 24 mov (%esp),%ebx
80480d2: c3 ret
80480d3: 66 90 xchg %ax,%ax
80480d5: 66 90 xchg %ax,%ax
80480d7: 66 90 xchg %ax,%ax
80480d9: 66 90 xchg %ax,%ax
80480db: 66 90 xchg %ax,%ax
80480dd: 66 90 xchg %ax,%ax
80480df: 90 nop
080480e0 <foo1>:
80480e0: 53 push %ebx
80480e1: e8 e9 ff ff ff call 80480cf <__x86.get_pc_thunk.bx>
80480e6: 81 c3 32 11 00 00 add $0x1132,%ebx
80480ec: 83 ec 08 sub $0x8,%esp
80480ef: 8b 83 fc ff ff ff mov -0x4(%ebx),%eax
80480f5: 85 c0 test %eax,%eax
80480f7: 74 05 je 80480fe <foo1+0x1e>
80480f9: e8 02 7f fb f7 call 0 <_start-0x80480a0>
80480fe: 83 c4 08 add $0x8,%esp
8048101: 5b pop %ebx
8048102: c3 ret
8048103: 66 90 xchg %ax,%ax
8048105: 66 90 xchg %ax,%ax
8048107: 66 90 xchg %ax,%ax
8048109: 66 90 xchg %ax,%ax
804810b: 66 90 xchg %ax,%ax
804810d: 66 90 xchg %ax,%ax
804810f: 90 nop
08048110 <func_p>:
8048110: e8 0c 00 00 00 call 8048121 <__x86.get_pc_thunk.ax>
8048115: 05 03 11 00 00 add $0x1103,%eax
804811a: 8b 80 fc ff ff ff mov -0x4(%eax),%eax
8048120: c3 ret
08048121 <__x86.get_pc_thunk.ax>:
8048121: 8b 04 24 mov (%esp),%eax
8048124: c3 ret
8048125: 66 90 xchg %ax,%ax
8048127: 66 90 xchg %ax,%ax
8048129: 66 90 xchg %ax,%ax
804812b: 66 90 xchg %ax,%ax
804812d: 66 90 xchg %ax,%ax
804812f: 90 nop
08048130 <foo2>:
8048130: 53 push %ebx
8048131: e8 99 ff ff ff call 80480cf <__x86.get_pc_thunk.bx>
8048136: 81 c3 e2 10 00 00 add $0x10e2,%ebx
804813c: 83 ec 08 sub $0x8,%esp
804813f: 8b 83 fd ff ff ff mov -0x3(%ebx),%eax
^^^^^ This is wrong.
8048145: 85 c0 test %eax,%eax
8048147: 74 05 je 804814e <foo2+0x1e>
8048149: e8 b2 7e fb f7 call 0 <_start-0x80480a0>
804814e: 83 c4 08 add $0x8,%esp
8048151: 5b pop %ebx
8048152: c3 ret
address@hidden lea-5]$
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/19601] New: Wrong GOT offset used with GOT relocation,
hjl.tools at gmail dot com <=
- [Bug ld/19601] Wrong GOT offset used with GOT relocation, cvs-commit at gcc dot gnu.org, 2016/02/10
- [Bug ld/19601] Wrong GOT offset used with GOT relocation, cvs-commit at gcc dot gnu.org, 2016/02/10
- [Bug ld/19601] Wrong GOT offset used with GOT relocation, hjl.tools at gmail dot com, 2016/02/10
- [Bug ld/19601] Wrong GOT offset used with GOT relocation, hjl.tools at gmail dot com, 2016/02/13
- [Bug ld/19601] Wrong GOT offset used with GOT relocation, hjl.tools at gmail dot com, 2016/02/26