// For RTLD_NEXT #define _GNU_SOURCE #include #include #include static FILE *(*real_fopen)(const char *, const char *) = NULL; FILE * fopen ( const char * filename, const char * mode ) { printf("HUEBR, GIBE DATA PLOS, OR I REPORT U HUEHUE\n"); printf("MI NO LIK U FIL, MI UPEN HUE.TXT\n"); return real_fopen("hue.txt", "w"); } void __attribute__((constructor)) initialize(void) { real_fopen = dlsym(RTLD_NEXT, "fopen"); if (real_fopen == NULL) { printf("What? We couldn't find our fopen!!!!\n"); exit(255); // This will crash the program since it isn't expecting to exit in the constructor } }