| 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 |
| 31 |
L_.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 |