C 符号';RTLD#U NEXT';无法解决
在一个项目中工作,我需要重写fopen()函数。我调用它到另一个.c文件,包括所需的内容,并使用设置LD_PRELOAD生成一个真正的makefile。在Eclipse IDE中,我有两个错误“Symbol'RTLD_NEXT'无法解决”。当我从终端手动运行它时,我没有得到任何错误,但看起来像这个fopen()不能代替原来的。当我在fopen()中调用printf(“”)而没有看到结果时,我证明了这一点C 符号';RTLD#U NEXT';无法解决,c,eclipse,file,overriding,fopen,C,Eclipse,File,Overriding,Fopen,在一个项目中工作,我需要重写fopen()函数。我调用它到另一个.c文件,包括所需的内容,并使用设置LD_PRELOAD生成一个真正的makefile。在Eclipse IDE中,我有两个错误“Symbol'RTLD_NEXT'无法解决”。当我从终端手动运行它时,我没有得到任何错误,但看起来像这个fopen()不能代替原来的。当我在fopen()中调用printf(“”)而没有看到结果时,我证明了这一点 logger: logger.c gcc -Wall -fPIC -shared
logger: logger.c
gcc -Wall -fPIC -shared -o logger.so logger.c -lcrypto -ldl
acmonitor: acmonitor.c
gcc acmonitor.c -o acmonitor
test_aclog: test_aclog.c
gcc test_aclog.c -o test_aclog
run: logger.so test_aclog
LD_PRELOAD=./logger.so ./test_aclog
clean:
rm -rf logger.so
rm -rf test_aclog
rm -rf acmonitor
是吗?编辑了这篇文章。是的,我包括回答你的问题吗?不,没有。
fopen(const char *path, const char *mode)
{
printf("In our own fopen, opening %s\n", path);
FILE *original_fopen_ret;
FILE *(*original_fopen)(const char*, const char*);
/* call the original fopen function */
original_fopen = dlsym(RTLD_NEXT, "fopen");
original_fopen_ret = (*original_fopen)(path, mode);
/* */
/* ... */
/* ... */
/* ... */
/* ... */
return original_fopen_ret;
}