preinit_array

#include <stdio.h>
void ctors()
{
printf(".ctors");
}
void ctors1()
{
printf(".ctors1");
}
void init_array()
{
printf(".init_array");
}
void pre_array()
{
printf(".pre_array");
}

typedef void (*ctor_t)(void);
typedef void (*init_array_t)(void);

ctor_t __attribute__ ((section(".ctors"))) my_init_p1 = ctors1;
ctor_t __attribute__ ((section(".ctors"))) my_init_p = ctors;
init_array_t __attribute__ ((section(".init_array"))) my_init_a = init_array;
init_array_t __attribute__ ((section(".preinit_array"))) my_init_a1 = pre_array;

int main()
{
printf("world \n");
return 0;
}

posted @ 2021-07-28 15:43  通杀  阅读(210)  评论(0编辑  收藏  举报