xref: /llvm-project/compiler-rt/test/orc/TestCases/Darwin/x86-64/jit-re-dlopen-data-reset.S (revision b4e19155171edf14412dc4132b7b10a84ac65fc5)
1// Test that __orc_rt_macho_jit_dlopen resets the state of the data sections.
2//
3// RUN: %clang -c -o %t.main.o %p/Inputs/dlopen-dlclose-x2.S
4// RUN: %clang -c -o %t.inits.o %s
5// RUN: %llvm_jitlink \
6// RUN:   -alias Platform:_dlopen=___orc_rt_macho_jit_dlopen \
7// RUN:   -alias Platform:_dlclose=___orc_rt_macho_jit_dlclose \
8// RUN:   %t.main.o -jd inits %t.inits.o -lmain | FileCheck %s
9
10// CHECK: entering main
11// CHECK-NEXT: X = 1, Y = 2
12// CHECK-NEXT: X = 1, Y = 2
13// CHECK-NEXT: leaving main
14
15	.section	__TEXT,__text,regular,pure_instructions
16	.build_version macos, 13, 0	sdk_version 13, 0
17	.section	__TEXT,__StaticInit,regular,pure_instructions
18	.p2align	4, 0x90
19_initializer:
20	movq	_X(%rip), %rsi
21	addq	$1, %rsi
22	movq	%rsi, _X(%rip)
23	movq	_Y(%rip), %rdx
24	addq	$1, %rdx
25	movq	%rdx, _Y(%rip)
26	leaq	L_.str(%rip), %rdi
27	xorl	%eax, %eax
28	jmp	_printf
29
30	.section	__TEXT,__cstring,cstring_literals
31L_.str:
32	.asciz	"X = %zu, Y = %zu\n"
33
34	.globl	_X                              ## @X
35.zerofill __DATA,__common,_X,8,3
36	.section	__DATA,__data
37	.globl	_Y                              ## @Y
38	.p2align	3
39_Y:
40	.quad	1                               ## 0x1
41
42	.section	__DATA,__mod_init_func,mod_init_funcs
43	.p2align	3
44	.quad	_initializer
45
46.subsections_via_symbols
47