因为我想勾STRCMP,代码是如下:在Linux中使用LD_PRELOAD钩strcmp?
#include <stdio.h>
#include <string.h>
int strcmp(const char *s1, const char *s2)
{
printf("hooked strcmp\n");
return 0;
}
// gcc test.c -shared -fPIC -o libtest.so
#include <stdio.h>
#include <string.h>
#include "test.h"
int main(int argc, char *argv[])
{
strcmp(argv[1], "aba"); // didn't call strcmp in libtest
int i = strcmp(argv[1], "aba"); // call strcmp in libtest
}
// gcc main.c
// LD_PRELOAD=./libtest.so ./a.out 12123
我的问题是:为什么在的strcmp这两个条件的diff?
固有使用? – 0andriy