[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[BUG] ld -shared resolves strong ref to defined weak sym as 0?
From: |
Roland McGrath |
Subject: |
[BUG] ld -shared resolves strong ref to defined weak sym as 0? |
Date: |
Sun, 21 Dec 2003 15:52:02 -0800 |
This is with mainline cvs binutils from yesterday, on elf32-i386 (i686-linux).
a.s contains:
.type loser,@function
.weak loser
loser: ret
b.s contains:
foobar: call loser
ret
Now do:
magilla 232 % as -o a.o a.s
magilla 233 % as -o b.o b.s
magilla 234 % ld -shared -nostdlib -o x.so a.o b.o
magilla 235 % objdump -rd x.so
x.so: file format elf32-i386
Disassembly of section .text:
00000230 <loser>:
230: c3 ret
231: 90 nop
232: 90 nop
233: 90 nop
00000234 <foobar>:
234: e8 fc ff ff ff call 235 <foobar+0x1>
239: c3 ret
The resolution of the reference to `loser' in b.o is wrong. It was
resolved as if the value of the symbol were zero (or equivalently, as if
there reference were weak and the symbol were undefined). The symbol is in
fact defined. Moreover, the reference is strong (to wit, ld -shared -z
defs of b.o without a.o does indeed barf on the undefined reference). If
the the b.o reference is R_386_PLT32 instead of R_386_PC32 (i.e. b.s says
"call address@hidden"), it works right (creates a PLT entry).
Thanks,
Roland
- [BUG] ld -shared resolves strong ref to defined weak sym as 0?,
Roland McGrath <=