I am trying to use LD_PRELOAD.
original.cpp
void myPuts() {
puts ("Hello myPuts");
}
int main() {
myPuts();
return 0;
}
hacked.cpp
void myPuts() {
std::cout >> "Hello hacked myPuts";
}
I compile the original.cpp file:
g++ original.cpp
And hacked.cpp:
g++ -shared -fPIC hacked.cpp
I'm trying to:
LD_PRELOAD=./hacked.so ./original.out
The string "Hello hacked myPuts" appears, and "Hello myPuts" appears. (If I try to “overwrite” the puts function, it works correctly)
What am I missing?
krisy source
share