Last active
October 6, 2018 04:19
-
-
Save k3170makan/400b7d9a41a90a580bf1a8dada546a81 to your computer and use it in GitHub Desktop.
Example of a constructor function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void never_call(void){ | |
printf("[*] success!! call to function never_call!!!\n\n"); | |
} | |
void __attribute__ ((destructor)) foo_destructor(void){ | |
printf("[*] hay! you called by destructor!! \n"); | |
return; | |
} | |
void __attribute__ ((constructor)) foo_constructor(void){ | |
printf("[*] hay! you called by constructor!! \n"); | |
return; | |
} | |
int main(int argc, char **argv){ | |
printf("[*] call to main function\n"); | |
return 0; | |
} | |
/* | |
> ./init_fini.elf | |
[*] hay! you called by constructor!! | |
[*] call to main function | |
[*] hay! you called by destructor!! | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment