overriding fclose(2)

vijay nag vijunag@gmail.com
Mon May 12 06:20:00 GMT 2014


Hello glibc,

I'm trying to override/wrap fclose(2) libc call the following way.

#include <stdio.h>

#undef fclose
extern int _IO_new_fclose(_IO_FILE *fp);  /* defined in ./libio/iofclose.c */

int __attribute__((weak)) fclose(FILE *stream)
{
     /* extra actions before libc fclose */

     return _IO_new_fclose(stream);
}

However, linker barfs out "Undefined reference" error for
"_IO_new_fclose" symbol. Am I calling the appropriate libc fclose
function ?



More information about the Libc-help mailing list