Impressed by blog post "Instrumenting binaries using revng and LLVM", so I want play with Nim
Here is original example.
Thanks to @ioncodes for a great article!
Make sure you have orchestra and revng installed.
In order to use scripts provided, ORCHESTRA_ROOT enviroment parameters must be set and point to your orchestra root folder.
# Compile dummy example
> sh compile.sh
# Lifting dummy to LLVM IR
> sh lift.sh
# Process lifted IR w/ Nim
> nimble install https://github.com/ba0f3/llvm.nim
> nim c -r dlsym_hook.nim dummy.translated.ll dummy.translated.processed.ll
...................
Loaded IR: dummy.translated.ll
Verification: 0
Ouput: dummy.translated.processed.ll
# Recompile processed IR
> sh recompile.sh dummy.translated.processed.ll
# Here is the output
> ./dummy.translated
dlsym => 0x1
dlsym => 0x41c10c88
dlsym(???, ��A);
dlsym => 0x41c10c88
dlsym(???, ��A);
dlsym => 0xffff
dlsym => 0x404061
dlsym(???, );
-- test dlsym --
dlsym => 0x4
dlsym => 0x1420dc0
dlsym(???, puts);
dlsym => 0x4
test
That's all!