mr4th-dynamic-linking/linux_before_main/linux_before_main.c

14 lines
210 B
C

// define the "before main" function
int x = 0;
__attribute__((constructor))
static void run_before_main_func(void){
x = 100;
}
// main
#include <stdio.h>
int main(){
printf("x = %d\n", x);
return(0);
}