60 lines · plain
1// Test that basic ELF static initializers work. The main function in this2// test returns the value of 'x', which is initially 1 in the data section,3// and reset to 0 if the _static_init function is run. If the static initializer4// does not run then main will return 1, causing the test to be treated as a5// failure.6//7// RUN: %clang -c -o %t %s8// RUN: %llvm_jitlink %t9 .text10 .abiversion 211 .file "init.c"12 .globl static_init13 .p2align 414 .type static_init,@function15static_init:16.Lfunc_begin0:17.Lfunc_gep0:18 addis 2, 12, .TOC.-.Lfunc_gep0@ha19 addi 2, 2, .TOC.-.Lfunc_gep0@l20.Lfunc_lep0:21 .localentry static_init, .Lfunc_lep0-.Lfunc_gep022 addis 3, 2, x@toc@ha23 li 4, 024 stw 4, x@toc@l(3)25 blr26 .long 027 .quad 028.Lfunc_end0:29 .size static_init, .Lfunc_end0-.Lfunc_begin030 31 .globl main32 .p2align 433 .type main,@function34main:35.Lfunc_begin1:36.Lfunc_gep1:37 addis 2, 12, .TOC.-.Lfunc_gep1@ha38 addi 2, 2, .TOC.-.Lfunc_gep1@l39.Lfunc_lep1:40 .localentry main, .Lfunc_lep1-.Lfunc_gep141 addis 3, 2, x@toc@ha42 lwa 3, x@toc@l(3)43 blr44 .long 045 .quad 046.Lfunc_end1:47 .size main, .Lfunc_end1-.Lfunc_begin148 49 .type x,@object50 .data51 .globl x52 .p2align 2, 0x053x:54 .long 155 .size x, 456 57 .section .init_array.0,"aw",@init_array58 .p2align 359 .quad static_init60