Hello,
I'm testing addon with LD_PRELOAD hooking.
In the test, I made hooking object for fopen call.
When I test with this example, fopen hooking worked.
#include <stdio.h>
int main()
{}
// ld_preload test
FILE* fd = NULL;
printf("Calling the fopen() function. \n");
fd = fopen("test.txt", "r");
if(!fd) {
printf("ok\n");
}
printf("fopen() succeeded\n");
}
But, if I apply this within node addons, hooking didn't work.
NAN_METHOD(MyObject::New) {
NanScope();
if (args.IsConstructCall()) {
// Invoked as constructor: `new MyObject(...)`
MyObject* obj = new MyObject();
obj->Wrap(args.This());
// ld_preload test
FILE* fd = NULL;
printf("Calling the fopen() function. \n");
fd = fopen("test.txt", "r");
if(!fd) {
printf("null\n");
}
printf("fopen() succeeded\n");
NanReturnValue(args.This());
}
}
Node addon documents say that Node statically compiles all its dependencies into the executable.
Is that why LD_PRELOAD is not working?
Please guide me to solve this problem.