RCF: Add R_386_GOT32X

264 views
Skip to first unread message

H.J. Lu

unread,
Oct 15, 2015, 11:54:48 AM10/15/15
to IA32 System V Application Binary Interface
X86 instruction encoding supports converting some instructions on memory
operand with GOT32 relocation against symbol, foo, into a different
form on immediate operand if foo is defined locally. Those instructions
are:

call *foo@GOT[(%reg)] => nop call foo or call foo nop
jmp *foo@GOT[(%reg)] => jmp foo nop
mov foo@GOT[(%reg1)], %reg2 => lea foo[@GOTOFF(%reg1)], %reg2

When osition-independent code is disable,

test %reg1, foo@GOT[(%reg2)] => test $foo, %reg1
binop foo@GOT[(%reg1)], %reg2 => binop $foo, %reg2

where binop is one of adc, add, and, cmp, or, sbb, sub, xor instructions.

I am proposing to add a new relocation, R_386_GOT32X, to i386 psABI.
Instead of generating R_386_GOT32 relocation agasint foo for
foo@GOT(%reg), we generate R_386_GOT32X. R_386_GOT32X relocation can
also be used without the base register for the global offset table,
foo@GOT, when position-independent code is disable. In this case, the
static base address of the global offset table will be used instead.
Linker can treat R_386_GOT32X the same as R_386_GOT32 or it can perform
the transformations listed above.


--
H.J.

H.J. Lu

unread,
Oct 20, 2015, 5:04:19 PM10/20/15
to IA32 System V Application Binary Interface
Here are 3 patches against Intel386 psABI. The updated pdf file is
available from

https://github.com/hjl-tools/x86-psABI/wiki/intel386-psABI-got32x.pdf

They have been implemented on binutils users/hjl/got branch. I
will check it into binutils master branch this week.


--
H.J.
0001-Add-R_386_GOT32X.patch
0002-Combine-GOTPLT-and-GOT-Slots.patch
0003-Optimize-R_386_GOT32X-relocation.patch
Reply all
Reply to author
Forward
0 new messages