brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 20fa0cc Raw
46 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    pcalau12i    $a0, %pc_hi20(x)17    ld.w    $a0, $a0, %pc_lo12(x)18    ret19.Lfunc_end0:20    .size    main, .Lfunc_end0-main21 22// static initializer sets the value of 'x' to zero.23 24    .section    .text.startup,"ax",@progbits25    .p2align    226    .type    static_init,@function27static_init:28 29    pcalau12i    $a0, %pc_hi20(x)30    st.w    $zero, $a0, %pc_lo12(x)31    ret32.Lfunc_end1:33    .size    static_init, .Lfunc_end1-static_init34 35    .type    x,@object36    .data37    .globl    x38    .p2align    239x:40    .word    141    .size    x, 442 43    .section    .init_array,"aw",@init_array44    .p2align    345    .dword    static_init46