[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. ;)
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
index 1273dc1..6e9f6ed 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
@@ -129,6 +129,9 @@
return EdgeKind_i386::PCRel16;
case ELF::R_386_GOT32:
return EdgeKind_i386::RequestGOTAndTransformToDelta32FromGOT;
+ case ELF::R_386_GOT32X:
+ // TODO: Add a relaxable edge kind and update relaxation optimization.
+ return EdgeKind_i386::RequestGOTAndTransformToDelta32FromGOT;
case ELF::R_386_GOTPC:
return EdgeKind_i386::Delta32;
case ELF::R_386_GOTOFF:
diff --git a/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_got.s b/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_got.s
index 080341a..d4cf709 100644
--- a/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_got.s
+++ b/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_small_pic_relocations_got.s
@@ -33,7 +33,28 @@
leal named_data2@GOT+5, %eax
.size test_got, .-test_got
+# Test R_386_GOT32X handling.
+#
+# We want to check both the offset to the GOT entry and its contents.
+# jitlink-check: decode_operand(test_gotx_load, 4) = got_addr(elf_sm_pic_reloc_got.o, named_data1) - _GLOBAL_OFFSET_TABLE_
+# jitlink-check: *{4}(got_addr(elf_sm_pic_reloc_got.o, named_data1)) = named_data1
+ .globl test_gotx
+ .p2align 4, 0x90
+ .type test_gotx,@function
+test_gotx:
+ calll .L0$pb
+.L0$pb:
+ popl %eax
+.Ltmp0:
+ addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %eax
+ .globl test_gotx_load
+test_gotx_load:
+ movl named_data1@GOT(%eax), %eax
+ .size test_gotx_load, .-test_gotx_load
+ movl (%eax), %eax
+ retl
+ .size test_gotx, .-test_gotx
# Test GOTOFF64 handling.
# jitlink-check: decode_operand(test_gotoff, 1) = named_func - _GLOBAL_OFFSET_TABLE_ + 99