189 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 .abiversion 215 .globl constructor.10016 .p2align 417 .type constructor.100,@function18constructor.100:19.Lfunc_begin0:20.Lfunc_gep0:21 addis 2, 12, .TOC.-.Lfunc_gep0@ha22 addi 2, 2, .TOC.-.Lfunc_gep0@l23.Lfunc_lep0:24 .localentry constructor.100, .Lfunc_lep0-.Lfunc_gep025 mflr 026 stdu 1, -32(1)27 std 0, 48(1)28 addis 3, 2, .L.str@toc@ha29 addi 3, 3, .L.str@toc@l30 bl puts31 nop32 addi 1, 1, 3233 ld 0, 16(1)34 mtlr 035 blr36 .long 037 .quad 038.Lfunc_end0:39 .size constructor.100, .Lfunc_end0-.Lfunc_begin040 41 .globl constructor.20042 .p2align 443 .type constructor.200,@function44constructor.200:45.Lfunc_begin1:46.Lfunc_gep1:47 addis 2, 12, .TOC.-.Lfunc_gep1@ha48 addi 2, 2, .TOC.-.Lfunc_gep1@l49.Lfunc_lep1:50 .localentry constructor.200, .Lfunc_lep1-.Lfunc_gep151 mflr 052 stdu 1, -32(1)53 std 0, 48(1)54 addis 3, 2, .L.str.1@toc@ha55 addi 3, 3, .L.str.1@toc@l56 bl puts57 nop58 addi 1, 1, 3259 ld 0, 16(1)60 mtlr 061 blr62 .long 063 .quad 064.Lfunc_end1:65 .size constructor.200, .Lfunc_end1-.Lfunc_begin166 67 .globl constructor.6553568 .p2align 469 .type constructor.65535,@function70constructor.65535:71.Lfunc_begin2:72.Lfunc_gep2:73 addis 2, 12, .TOC.-.Lfunc_gep2@ha74 addi 2, 2, .TOC.-.Lfunc_gep2@l75.Lfunc_lep2:76 .localentry constructor.65535, .Lfunc_lep2-.Lfunc_gep277 mflr 078 stdu 1, -32(1)79 std 0, 48(1)80 addis 3, 2, .L.str.2@toc@ha81 addi 3, 3, .L.str.2@toc@l82 bl puts83 nop84 addis 3, 2, destructor@toc@ha85 addi 3, 3, destructor@toc@l86 addis 5, 2, __dso_handle@toc@ha87 addi 5, 5, __dso_handle@toc@l88 li 4, 089 bl __cxa_atexit90 nop91 addi 1, 1, 3292 ld 0, 16(1)93 mtlr 094 blr95 .long 096 .quad 097.Lfunc_end2:98 .size constructor.65535, .Lfunc_end2-.Lfunc_begin299 100 .globl destructor101 .p2align 4102 .type destructor,@function103destructor:104.Lfunc_begin3:105.Lfunc_gep3:106 addis 2, 12, .TOC.-.Lfunc_gep3@ha107 addi 2, 2, .TOC.-.Lfunc_gep3@l108.Lfunc_lep3:109 .localentry destructor, .Lfunc_lep3-.Lfunc_gep3110 mflr 0111 stdu 1, -32(1)112 std 0, 48(1)113 addis 3, 2, .L.str.3@toc@ha114 addi 3, 3, .L.str.3@toc@l115 bl puts116 nop117 addi 1, 1, 32118 ld 0, 16(1)119 mtlr 0120 blr121 .long 0122 .quad 0123.Lfunc_end3:124 .size destructor, .Lfunc_end3-.Lfunc_begin3125 126 .globl main127 .p2align 4128 .type main,@function129main:130.Lfunc_begin4:131.Lfunc_gep4:132 addis 2, 12, .TOC.-.Lfunc_gep4@ha133 addi 2, 2, .TOC.-.Lfunc_gep4@l134.Lfunc_lep4:135 .localentry main, .Lfunc_lep4-.Lfunc_gep4136 mflr 0137 stdu 1, -32(1)138 std 0, 48(1)139 addis 3, 2, .L.str.4@toc@ha140 addi 3, 3, .L.str.4@toc@l141 bl puts142 nop143 li 3, 0144 addi 1, 1, 32145 ld 0, 16(1)146 mtlr 0147 blr148 .long 0149 .quad 0150.Lfunc_end4:151 .size main, .Lfunc_end4-.Lfunc_begin4152 153 .hidden __dso_handle154 .type .L.str,@object155 .section .rodata.str1.1,"aMS",@progbits,1156.L.str:157 .asciz "constructor 100"158 .size .L.str, 16159 160 .type .L.str.1,@object161.L.str.1:162 .asciz "constructor 200"163 .size .L.str.1, 16164 165 .type .L.str.2,@object166.L.str.2:167 .asciz "constructor 65535"168 .size .L.str.2, 18169 170 .type .L.str.3,@object171.L.str.3:172 .asciz "destructor"173 .size .L.str.3, 11174 175 .type .L.str.4,@object176.L.str.4:177 .asciz "main"178 .size .L.str.4, 5179 180 .section .init_array.100,"aw",@init_array181 .p2align 3182 .quad constructor.100183 .section .init_array.200,"aw",@init_array184 .p2align 3185 .quad constructor.200186 .section .init_array,"aw",@init_array187 .p2align 3188 .quad constructor.65535189