https://sourceware.org/bugzilla/show_bug.cgi?id=19177
Bug ID: 19177
Summary: gold doesn't handle R_386_GOT32X relocation without
base register
Product: binutils
Version: 2.26 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: gold
Assignee: ccoutant at gmail dot com
Reporter: hjl.tools at gmail dot com
CC: ian at airs dot com
Target Milestone: ---
The new R_386_GOT32X relocation can have no base register:
movl bar@GOT, %eax
Its calculation is G + A, instead of G + A - GOT, and it can
only used to generate non-PIC executable:
https://github.com/hjl-tools/x86-psABI/wiki/intel386-psABI-20151021.pdf
[hjl@gnu-tools-1 gold]$ cat x.S
.text
movl bar@GOT, %eax
[hjl@gnu-tools-1 gold]$ cat y.S
.data
.globl bar
.type bar, @object
bar:
.byte 1
[hjl@gnu-tools-1 gold]$ make
gcc -m32 -c -o x.o x.S
gcc -m32 -c -o y.o y.S
ld.bfd -m elf_i386 -o liby.so -shared y.o
ld.bfd -m elf_i386 -o x x.o liby.so
ld.bfd: warning: cannot find entry symbol _start; defaulting to
0000000008048190
objdump -dwr x.o
x.o: file format elf32-i386
Disassembly of section .text:
00000000 <.text>:
0: 8b 05 00 00 00 00 mov 0x0,%eax 2: R_386_GOT32X bar
objdump -dwr x
x: file format elf32-i386
Disassembly of section .text:
08048190 <.text>:
8048190: 8b 05 18 92 04 08 mov 0x8049218,%eax
readelf -SW x | grep ".\got "
[ 9] .got PROGBITS 08049218 000218 000004 04 WA 0 0
4
[hjl@gnu-tools-1 gold]$ make libx.so
ld.bfd -m elf_i386 -o libx.so -shared x.o
ld.bfd: x.o: direct GOT relocation R_386_GOT32X against `bar' without base
register can not be used when making a shared object
ld.bfd: failed to set dynamic section sizes: File format not recognized
Makefile:18: recipe for target 'libx.so' failed
make: *** [libx.so] Error 1
Gold doesn't handle it properly:
[hjl@gnu-tools-1 gold]$ make LD=ld.gold
gcc -m32 -c -o x.o x.S
gcc -m32 -c -o y.o y.S
ld.gold -m elf_i386 -o liby.so -shared y.o
ld.gold -m elf_i386 -o x x.o liby.so
objdump -dwr x.o
x.o: file format elf32-i386
Disassembly of section .text:
00000000 <.text>:
0: 8b 05 00 00 00 00 mov 0x0,%eax 2: R_386_GOT32X bar
objdump -dwr x
x: file format elf32-i386
Disassembly of section .text:
08048190 <.text>:
8048190: 8b 05 fc ff ff ff mov 0xfffffffc,%eax
readelf -SW x | grep ".\got "
[ 8] .got PROGBITS 08049220 000220 000004 00 WA 0 0
4
[hjl@gnu-tools-1 gold]$ make LD=ld.gold libx.so
ld.gold -m elf_i386 -o libx.so -shared x.o
[hjl@gnu-tools-1 gold]$
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
bug-binutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-binutils