112 lines · plain
1// Test that ELF static initializers with different constructor priorities work2// and are executed in the proper order.3//4// RUN: %clang -c -o %t %s5// RUN: %llvm_jitlink %t | FileCheck %s6 7// CHECK: constructor 1008// CHECK-NEXT: constructor 2009// CHECK-NEXT: constructor 6553510// CHECK-NEXT: main11// CHECK-NEXT: destructor12 13 .text14 .globl destructor15 .p2align 216 .type destructor,@function17destructor:18.Ldestructor$local:19 20 adrp x0, .L.str.221 add x0, x0, :lo12:.L.str.222 b puts23 24 .globl main25 .p2align 226 .type main,@function27main:28 29 str x30, [sp, #-16]!30 adrp x0, .L.str31 add x0, x0, :lo12:.L.str32 bl puts33 mov w0, wzr34 ldr x30, [sp], #1635 ret36 37 .p2align 238 .type constructor.65535,@function39constructor.65535:40 41 str x30, [sp, #-16]!42 adrp x0, .L.str.6553543 add x0, x0, :lo12:.L.str.6553544 bl puts45 adrp x0, .Ldestructor$local46 add x0, x0, :lo12:.Ldestructor$local47 adrp x2, __dso_handle48 add x2, x2, :lo12:__dso_handle49 mov x1, xzr50 ldr x30, [sp], #1651 b __cxa_atexit52 53 .p2align 254 .type constructor.100,@function55constructor.100:56 57 str x30, [sp, #-16]!58 adrp x0, .L.str.10059 add x0, x0, :lo12:.L.str.10060 bl puts61 ldr x30, [sp], #1662 ret63 64 .p2align 265 .type constructor.200,@function66constructor.200:67 68 str x30, [sp, #-16]!69 adrp x0, .L.str.20070 add x0, x0, :lo12:.L.str.20071 bl puts72 ldr x30, [sp], #1673 ret74 75 .hidden __dso_handle76 .type .L.str,@object77 .section .rodata.str1.1,"aMS",@progbits,178.L.str:79 .asciz "main"80 .size .L.str, 581 82 .type .L.str.100,@object83.L.str.100:84 .asciz "constructor 100"85 .size .L.str.100, 1686 87 .type .L.str.200,@object88.L.str.200:89 .asciz "constructor 200"90 .size .L.str.200, 1691 92 .type .L.str.65535,@object93.L.str.65535:94 .asciz "constructor 65535"95 .size .L.str.65535, 1896 97 98 .type .L.str.2,@object99.L.str.2:100 .asciz "destructor"101 .size .L.str.2, 11102 103 .section .init_array.100,"aw",@init_array104 .p2align 3105 .xword constructor.100106 .section .init_array.200,"aw",@init_array107 .p2align 3108 .xword constructor.200109 .section .init_array,"aw",@init_array110 .p2align 3111 .xword constructor.65535112