fuzzland / luning

[WIP] Generate Foundry-style Call Trace for LLVM Targets (C/C++)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Luning

Generates Foundry-style call trace for LLVM targets (C/C++).

Screenshot 2024-05-15 at 3 08 06 PM

Setup LLVM Environment

export ICWD=`pwd`
# Change paths based on your LLVM installation locations
./env.sh

Build Pass

First time build:

mkdir build
cd build
cmake ..
make
cd ..

Rebuild:

cd build
make
cd ..

Compile with Pass

Simple way:

$CC -fpass-plugin=`build/instrumentation/InstrPass.so` test.c hooks.c -g3

CMake Project:

# Compile the hook to so
$CC -shared -fPIC hooks.c -o libhooks.so

CXXFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" CFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" LDFLAGS="-L$ICWD -lhooks" LD_LIBRARY_PATH=$ICWD cmake ..
CXXFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" CFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" LDFLAGS="-L$ICWD -lhooks" LD_LIBRARY_PATH=$ICWD make

PHP:

$CC -shared -fPIC hooks.c -o libhooks.so

git clone https://github.com/php/php-src
cd php-src

./buildconf

CXXFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" CFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" LDFLAGS="-L$ICWD -lhooks" LD_LIBRARY_PATH=$ICWD ./configure
CXXFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" CFLAGS="-fpass-plugin=$ICWD/build/instrumentation/InstrPass.so" LDFLAGS="-L$ICWD -lhooks" LD_LIBRARY_PATH=$ICWD make -j100

Run

PHP:

# dump calls
LD_LIBRARY_PATH=$ICWD ./sapi/cli/php -r 'echo "Hello World\n";' | python3 ../parser_1.py  > callgraph.txt

About

[WIP] Generate Foundry-style Call Trace for LLVM Targets (C/C++)


Languages

Language:C++ 46.5%Language:C 27.5%Language:Python 17.2%Language:CMake 8.0%Language:Shell 0.8%