[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / test / ExecutionEngine / JITLink / X86 / ELF_x86-64_small_pic_relocations.s
blobb19569304934079b2b4a8fbccf278e4de9da0634
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 external_data=0x1 \
6 # RUN: -define-abs extern_out_of_range32=0x7fff00000000 \
7 # RUN: -check %s %t/elf_sm_pic_reloc.o
9 # Test ELF small/PIC relocations.
11 .text
12 .file "testcase.c"
14 # Empty main entry point.
15 .globl main
16 .p2align 4, 0x90
17 .type main,@function
18 main:
19 retq
21 .size main, .-main
23 # Test PCRel32 / R_X86_64_PC32 handling.
24 # jitlink-check: decode_operand(test_pcrel32, 4) = named_data - next_pc(test_pcrel32)
25 .globl test_pcrel32
26 .p2align 4, 0x90
27 .type test_pcrel32,@function
28 test_pcrel32:
29 movl named_data(%rip), %eax
31 .size test_pcrel32, .-test_pcrel32
33 .globl named_func
34 .p2align 4, 0x90
35 .type named_func,@function
36 named_func:
37 xorq %rax, %rax
39 .size named_func, .-named_func
41 # Check R_X86_64_PLT32 handling with a call to a local function. This produces a
42 # Branch32 edge that is resolved like a regular PCRel32 (no PLT entry created).
44 # jitlink-check: decode_operand(test_call_local, 0) = named_func - next_pc(test_call_local)
45 .globl test_call_local
46 .p2align 4, 0x90
47 .type test_call_local,@function
48 test_call_local:
49 callq named_func
51 .size test_call_local, .-test_call_local
53 # Check R_X86_64_PLT32 handling with a call to an external via PLT. This
54 # produces a Branch32ToStub edge, because externals are not defined locally.
55 # As the target is out-of-range from the callsite, the edge keeps using its PLT
56 # entry.
58 # jitlink-check: decode_operand(test_call_extern_plt, 0) = \
59 # jitlink-check: stub_addr(elf_sm_pic_reloc.o, extern_out_of_range32) - \
60 # jitlink-check: next_pc(test_call_extern_plt)
61 # jitlink-check: *{8}(got_addr(elf_sm_pic_reloc.o, extern_out_of_range32)) = \
62 # jitlink-check: extern_out_of_range32
63 .globl test_call_extern_plt
64 .p2align 4, 0x90
65 .type test_call_extern_plt,@function
66 test_call_extern_plt:
67 callq extern_out_of_range32@plt
69 .size test_call_extern_plt, .-test_call_extern_plt
71 # Test GOTPCREL handling. We want to check both the offset to the GOT entry and its
72 # contents. "movl" will be optimized to "leal" and a non-got access if the pc relative
73 # offset to named_data is in range of 32 bits signed immediate. So use "leal" here to
74 # suppress optimization
75 # jitlink-check: decode_operand(test_gotpcrel, 4) = \
76 # jitlink-check: got_addr(elf_sm_pic_reloc.o, named_data) - next_pc(test_gotpcrel)
77 # jitlink-check: *{8}(got_addr(elf_sm_pic_reloc.o, named_data)) = named_data
79 .globl test_gotpcrel
80 .p2align 4, 0x90
81 .type test_gotpcrel,@function
82 test_gotpcrel:
83 leal named_data@GOTPCREL(%rip), %eax
85 .size test_gotpcrel, .-test_gotpcrel
87 # Test REX_GOTPCRELX handling. We want to check both the offset to the GOT entry and its
88 # contents.
89 # jitlink-check: decode_operand(test_rex_gotpcrelx, 4) = \
90 # jitlink-check: got_addr(elf_sm_pic_reloc.o, external_data) - next_pc(test_rex_gotpcrelx)
92 .globl test_rex_gotpcrelx
93 .p2align 4, 0x90
94 .type test_rex_gotpcrelx,@function
95 test_rex_gotpcrelx:
96 movq external_data@GOTPCREL(%rip), %rax
98 .size test_rex_gotpcrelx, .-test_rex_gotpcrelx
100 # Test GOTOFF64 handling.
101 # jitlink-check: decode_operand(test_gotoff64, 1) = named_func - _GLOBAL_OFFSET_TABLE_
102 .globl test_gotoff64
103 .p2align 4, 0x90
104 .type test_gotoff64,@function
105 test_gotoff64:
106 movabsq $named_func@GOTOFF, %rax
108 .size test_gotoff64, .-test_gotoff64
110 # Test that relocations to anonymous constant pool entries work.
111 .globl test_anchor_LCPI
112 .p2align 4, 0x90
113 .type test_anchor_LCPI,@function
114 test_anchor_LCPI:
115 movq .LCPI0_0(%rip), %rax
117 .size test_anchor_LCPI, .-test_anchor_LCPI
119 .data
121 .type named_data,@object
122 .p2align 3
123 named_data:
124 .quad 42
125 .size named_data, 8
127 # Test BSS / zero-fill section handling.
128 # llvm-jitlink: *{4}bss_variable = 0
130 .type bss_variable,@object
131 .bss
132 .globl bss_variable
133 .p2align 2
134 bss_variable:
135 .long 0
136 .size bss_variable, 4
138 # Constant pool entry with type STT_NOTYPE.
139 .section .rodata.cst8,"aM",@progbits,8
140 .p2align 3
141 .LCPI0_0:
142 .quad 0x400921fb54442d18
144 .ident "clang version 10.0.0-4ubuntu1 "
145 .section ".note.GNU-stack","",@progbits
146 .addrsig