[PATCH] D138372: Updates and adds tests for i386/ELF JITLink backend

Kshitij Jain via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 19 20:17:28 PST 2022


jain98 created this revision.
Herald added a project: All.
jain98 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This CR modifies the existing 32 bit pcrel relocation test to
include the case when the relocation target might be present at
a smaller address than the address of the location that needs to be
patched.

Additionally, it adds a test for 16 bit absolute relocation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138372

Files:
  llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_absolute_relocations_16.s
  llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_pc_relative_relocations_32.s


Index: llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_pc_relative_relocations_32.s
===================================================================
--- llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_pc_relative_relocations_32.s
+++ llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_pc_relative_relocations_32.s
@@ -1,6 +1,9 @@
-# RUN: llvm-mc -triple=i386-unknown-linux-gnu -filetype=obj -o %t.o %s
-# RUN: llvm-jitlink -noexec %t.o
+# RUN: split-file %s %t
 
+//--- positive_offset.s
+# RUN: llvm-mc -triple=i386-unknown-linux-gnu -filetype=obj -o %t.o %t/positive_offset.s
+# RUN: llvm-jitlink -noexec %t.o
+# Tests PC relative relocation for positive offset from PC
         .text
         .section        .text.main
         .globl  main
@@ -28,4 +31,38 @@
     popl    %ebp
     retl
 
-    .size       foo, .-foo
\ No newline at end of file
+    .size       foo, .-foo
+
+//--- negative_offset.s
+# RUN: llvm-mc -triple=i386-unknown-linux-gnu -filetype=obj -o %t.o %t/negative_offset.s
+# RUN: llvm-jitlink -noexec %t.o
+# Tests PC relative relocation for negative offset from PC
+
+        .text
+        .section        .text.bar
+        .p2align        4
+        .type   bar, at function
+bar:
+    pushl   %ebp
+    movl    %esp, %ebp
+    movl    $42, %eax
+    popl    %ebp
+    retl
+
+        .size       bar, .-bar
+
+        .section        .text.main
+        .globl  main
+        .p2align        4
+        .type   main, at function
+main:
+    pushl   %ebp
+    movl    %esp, %ebp
+    subl    $8, %esp
+    movl    $0, -4(%ebp)
+    calll   bar
+    addl    $8, %esp
+    popl    %ebp
+    retl
+
+        .size   main, .-main
\ No newline at end of file
Index: llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_absolute_relocations_16.s
===================================================================
--- /dev/null
+++ llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_absolute_relocations_16.s
@@ -0,0 +1,28 @@
+# RUN: llvm-mc -triple=i386-unknown-linux-gnu -filetype=obj -o %t.o %s
+# RUN: llvm-jitlink -slab-allocate 1Kb -slab-address 0x02 -slab-page-size 16 \
+# RUN:      -noexec %t.o
+
+        .text
+        .code16
+        .globl  main     
+        .p2align        4, 0x90
+        .type   main, at function
+main:                                   # @main
+# %bb.0:
+        pushl   %ebp
+        movl    %esp, %ebp
+        pushl   %eax
+        movl    $0, -4(%ebp)
+        movswl  a, %eax
+        addl    $4, %esp
+        popl    %ebp
+        retl
+
+        .size   main, .-main
+                                        # -- End function
+        .type   a, at object                       # @a
+        .data
+        .p2align        1
+a:
+        .short  42                              # 0x2a
+        .size   a, 2
\ No newline at end of file


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138372.476723.patch
Type: text/x-patch
Size: 2782 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221120/b9f6f0af/attachment-0001.bin>


More information about the llvm-commits mailing list