diff --git a/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_absolute_relocations_16.s b/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_absolute_relocations_16.s new file mode 100644 --- /dev/null +++ b/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,@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,@object # @a + .data + .p2align 1 +a: + .short 42 # 0x2a + .size a, 2 \ No newline at end of file diff --git a/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_pc_relative_relocations_32.s b/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_pc_relative_relocations_32.s --- a/llvm/test/ExecutionEngine/JITLink/i386/ELF_i386_pc_relative_relocations_32.s +++ b/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,@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,@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