1 # RUN: rm -rf %t && mkdir -p %t
2 # RUN: llvm-mc -triple=x86_64-unknown-linux -position-independent \
3 # RUN: -filetype=obj -o %t/elf_got_plt_opt.o %s
4 # 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.o
14 # Empty main entry point.
23 # Test optimization of transforming "call *foo@GOTPCREL(%rip)" to "addr call foo"
24 # We need check both the target address and the instruction opcodes
25 # jitlink-check: decode_operand(test_call_gotpcrelx, 0)[31:0] = extern_in_range32
26 # jitlink-check: *{1}test_call_gotpcrelx = 0x67
27 # jitlink-check: *{1}test_call_gotpcrelx+1 = 0xe8
28 .globl test_call_gotpcrelx
30 .type test_call_gotpcrelx,@function
32 call
*extern_in_range32@GOTPCREL
(%rip
)
34 .size test_call_gotpcrelx, .-test_call_gotpcrelx
37 # Test optimization of transforming "jmp *foo@GOTPCREL(%rip)" to "jmp foo ; nop"
38 # We need check both the target address and the instruction opcodes
39 # jitlink-check: decode_operand(test_call_gotpcrelx, 0)[31:0] = extern_in_range32
40 # jitlink-check: *{1}test_jmp_gotpcrelx = 0xe9
41 # jitlink-check: *{1}test_jmp_gotpcrelx+5 = 0x90
42 .globl test_jmp_gotpcrelx
44 .type test_jmp_gotpcrelx,@function
46 jmp
*extern_in_range32@GOTPCREL
(%rip
)
48 .size test_jmp_gotpcrelx, .-test_jmp_gotpcrelx
50 # Check R_X86_64_PLT32 handling with a call to an external. This produces a
51 # Branch32ToStub edge, because externals are not defined locally. During
52 # resolution, the target turns out to be in-range from the callsite and so the
53 # edge is relaxed in post-allocation optimization.
55 # jitlink-check: decode_operand(test_call_extern, 0) = \
56 # jitlink-check: extern_in_range32 - next_pc(test_call_extern)
57 .globl test_call_extern
59 .type test_call_extern,@function
61 callq extern_in_range32@plt
63 .size test_call_extern, .-test_call_extern