Files
  • main.sh
  • inject.c
  • inject.so
  • main.c
  • out
main.sh
1
2
3
4
5
6
7
8
gcc -shared -fPIC -o inject.so inject.c
gcc main.c -o out
echo "without LD_PRELOAD"
./out
echo "with LD_PRELOAD"
LD_PRELOAD=$PWD/inject.so ./out

# see http://www.goldsborough.me/c/low-level/kernel/2016/08/29/16-48-53-the_-ld_preload-_trick/