48 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 10 .text11 .globl main12 .p2align 213 .type main,@function14main:15 16 adrp x8, :got:x17 ldr x8, [x8, :got_lo12:x]18 ldr w0, [x8]19 ret20.Lfunc_end0:21 .size main, .Lfunc_end0-main22 23// static initializer sets the value of 'x' to zero.24 25 .section .text.startup,"ax",@progbits26 .p2align 227 .type static_init,@function28static_init:29 30 adrp x8, :got:x31 ldr x8, [x8, :got_lo12:x]32 str wzr, [x8]33 ret34.Lfunc_end1:35 .size static_init, .Lfunc_end1-static_init36 37 .type x,@object38 .data39 .globl x40 .p2align 241x:42 .word 143 .size x, 444 45 .section .init_array,"aw",@init_array46 .p2align 347 .xword static_init48