Skip to content

Commit 32f514c

Browse files
lhamesLang Hames
authored andcommitted
[JITLink][i386] Support R_386_GOT32X using existing non-relaxable edge kind.
R_386_GOT32 was already handled by lowering to EdgeKind_i386::RequestGOTAndTransformToDelta32FromGOT. R_386_GOT32X is just an optionally relaxable version of R_386_GOT32, so we can lower to the same edge kind. I've left a TODO to add a relaxable edge kind and update the i386 relaxation optimization in the future, though I'll probably leave this as an exercise for any i386 aficionados out there. ;)
1 parent 934cfa7 commit 32f514c

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ class ELFLinkGraphBuilder_i386 : public ELFLinkGraphBuilder<object::ELF32LE> {
129129
return EdgeKind_i386::PCRel16;
130130
case ELF::R_386_GOT32:
131131
return EdgeKind_i386::RequestGOTAndTransformToDelta32FromGOT;
132+
case ELF::R_386_GOT32X:
133+
// TODO: Add a relaxable edge kind and update relaxation optimization.
134+
return EdgeKind_i386::RequestGOTAndTransformToDelta32FromGOT;
132135
case ELF::R_386_GOTPC:
133136
return EdgeKind_i386::Delta32;
134137
case ELF::R_386_GOTOFF:

llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_got.s

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,28 @@ test_got:
3333
leal named_data2@GOT+5, %eax
3434
.size test_got, .-test_got
3535

36+
# Test R_386_GOT32X handling.
37+
#
38+
# We want to check both the offset to the GOT entry and its contents.
39+
# jitlink-check: decode_operand(test_gotx_load, 4) = got_addr(elf_sm_pic_reloc_got.o, named_data1) - _GLOBAL_OFFSET_TABLE_
40+
# jitlink-check: *{4}(got_addr(elf_sm_pic_reloc_got.o, named_data1)) = named_data1
3641

42+
.globl test_gotx
43+
.p2align 4, 0x90
44+
.type test_gotx,@function
45+
test_gotx:
46+
calll .L0$pb
47+
.L0$pb:
48+
popl %eax
49+
.Ltmp0:
50+
addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %eax
51+
.globl test_gotx_load
52+
test_gotx_load:
53+
movl named_data1@GOT(%eax), %eax
54+
.size test_gotx_load, .-test_gotx_load
55+
movl (%eax), %eax
56+
retl
57+
.size test_gotx, .-test_gotx
3758

3859
# Test GOTOFF64 handling.
3960
# jitlink-check: decode_operand(test_gotoff, 1) = named_func - _GLOBAL_OFFSET_TABLE_ + 99

0 commit comments

Comments
 (0)