1 # RUN: rm -rf %t && mkdir -p %t
2 # RUN: llvm-mc -triple=x86_64-unknown-linux -position-independent -filetype=obj \
3 # RUN: -o %t/elf_sm_pic_reloc.o %s
4 # RUN: llvm-jitlink -noexec -slab-allocate 100Kb -slab-address 0xfff00000 \
5 # RUN: -define-abs extern_in_range32=0xffe00000 \
6 # RUN: -check %s %t/elf_sm_pic_reloc.o
13 # Empty main entry point.
22 # Test optimization of transforming "call *foo@GOTPCREL(%rip)" to "addr call foo"
23 # We need check both the target address and the instruction opcodes
24 # jitlink-check: decode_operand(test_call_gotpcrelx, 0)[31:0] = extern_in_range32
25 # jitlink-check: *{1}test_call_gotpcrelx = 0x67
26 # jitlink-check: *{1}test_call_gotpcrelx+1 = 0xe8
27 .globl test_call_gotpcrelx
29 .type test_call_gotpcrelx,@function
31 call
*extern_in_range32@GOTPCREL
(%rip
)
33 .size test_call_gotpcrelx, .-test_call_gotpcrelx
36 # Test optimization of transforming "jmp *foo@GOTPCREL(%rip)" to "jmp foo ; nop"
37 # We need check both the target address and the instruction opcodes
38 # jitlink-check: decode_operand(test_call_gotpcrelx, 0)[31:0] = extern_in_range32
39 # jitlink-check: *{1}test_jmp_gotpcrelx = 0xe9
40 # jitlink-check: *{1}test_jmp_gotpcrelx+5 = 0x90
41 .globl test_jmp_gotpcrelx
43 .type test_jmp_gotpcrelx,@function
45 jmp
*extern_in_range32@GOTPCREL
(%rip
)
47 .size test_jmp_gotpcrelx, .-test_jmp_gotpcrelx
49 # Check R_X86_64_PLT32 handling with a call to an external. This produces a
50 # Branch32ToStub edge, because externals are not defined locally. During
51 # resolution, the target turns out to be in-range from the callsite and so the
52 # edge is relaxed in post-allocation optimization.
54 # jitlink-check: decode_operand(test_call_extern, 0) = \
55 # jitlink-check: extern_in_range32 - next_pc(test_call_extern)
56 .globl test_call_extern
58 .type test_call_extern,@function
60 callq extern_in_range32@plt
62 .size test_call_extern, .-test_call_extern