65 lines · plain
1# RUN: rm -rf %t && mkdir -p %t2# RUN: llvm-mc -triple=x86_64-unknown-linux -position-independent \3# RUN: -filetype=obj -o %t/elf_got_plt_opt.o %s4# RUN: llvm-jitlink -noexec \5# RUN: -slab-allocate 100Kb -slab-address 0xfff00000 -slab-page-size 4096 \6# RUN: -abs extern_in_range32=0xffe00000 \7# RUN: -check %s %t/elf_got_plt_opt.o8#9 10 11 .text12 .file "testcase.c"13 14# Empty main entry point.15 .globl main16 .p2align 4, 0x9017 .type main,@function18main:19 retq20 21 .size main, .-main22 23# Test optimization of transforming "call *foo@GOTPCREL(%rip)" to "addr call foo"24# We need check both the target address and the instruction opcodes25# jitlink-check: decode_operand(test_call_gotpcrelx, 0)[31:0] = extern_in_range3226# jitlink-check: *{1}test_call_gotpcrelx = 0x6727# jitlink-check: *{1}test_call_gotpcrelx+1 = 0xe828 .globl test_call_gotpcrelx29 .p2align 4, 0x9030 .type test_call_gotpcrelx,@function31test_call_gotpcrelx:32 call *extern_in_range32@GOTPCREL(%rip)33 34 .size test_call_gotpcrelx, .-test_call_gotpcrelx35 36 37# Test optimization of transforming "jmp *foo@GOTPCREL(%rip)" to "jmp foo ; nop"38# We need check both the target address and the instruction opcodes39# jitlink-check: decode_operand(test_call_gotpcrelx, 0)[31:0] = extern_in_range3240# jitlink-check: *{1}test_jmp_gotpcrelx = 0xe941# jitlink-check: *{1}test_jmp_gotpcrelx+5 = 0x9042 .globl test_jmp_gotpcrelx43 .p2align 4, 0x9044 .type test_jmp_gotpcrelx,@function45test_jmp_gotpcrelx:46 jmp *extern_in_range32@GOTPCREL(%rip)47 48 .size test_jmp_gotpcrelx, .-test_jmp_gotpcrelx49 50# Check R_X86_64_PLT32 handling with a call to an external. This produces a51# Branch32ToStub edge, because externals are not defined locally. During52# resolution, the target turns out to be in-range from the callsite and so the53# edge is relaxed in post-allocation optimization.54#55# jitlink-check: decode_operand(test_call_extern, 0) = \56# jitlink-check: extern_in_range32 - next_pc(test_call_extern)57 .globl test_call_extern58 .p2align 4, 0x9059 .type test_call_extern,@function60test_call_extern:61 callq extern_in_range32@plt62 63 .size test_call_extern, .-test_call_extern64 65