From aaa0856934a3eee9f5a9c3863b85339ea9db9564 Mon Sep 17 00:00:00 2001 From: Anh <zenpoems@gmail.com> Date: Fri, 17 Aug 2018 18:17:37 +0000 Subject: [PATCH] Add tests to verify specification of entry point Test gzip with --entrypoint=main Test gzip with --entrypoint=<addressOfMain> --- afl_transforms/tools/zafl/zafl.cpp | 3 +-- test/gzip/test_gzip.sh | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/afl_transforms/tools/zafl/zafl.cpp b/afl_transforms/tools/zafl/zafl.cpp index d69f336..ebda0ec 100644 --- a/afl_transforms/tools/zafl/zafl.cpp +++ b/afl_transforms/tools/zafl/zafl.cpp @@ -455,10 +455,9 @@ void Zafl_t::insertForkServer(string p_forkServerEntry) if (std::isdigit(p_forkServerEntry[0])) { // find instruction to insert fork server based on address - const auto fileid = getFileIR()->GetFile()->GetBaseID(); const auto voffset = (virtual_offset_t) std::strtoul(p_forkServerEntry.c_str(), NULL, 16); auto instructions=find_if(getFileIR()->GetInstructions().begin(), getFileIR()->GetInstructions().end(), [&](const Instruction_t* i) { - return i->GetAddress()->GetFileID()==fileid && i->GetAddress()->GetVirtualOffset()==voffset; + return i->GetAddress()->GetVirtualOffset()==voffset; }); if (instructions==getFileIR()->GetInstructions().end()) diff --git a/test/gzip/test_gzip.sh b/test/gzip/test_gzip.sh index 56c47ac..ff5b34d 100755 --- a/test/gzip/test_gzip.sh +++ b/test/gzip/test_gzip.sh @@ -62,6 +62,19 @@ test_zafl() pushd /tmp +# test setting of entry point via address +setup +ep=$( objdump -Mintel -d /bin/gzip | grep text | grep -v -i disassembly | cut -d' ' -f1 | sed 's/^00000000//g' ) +build_zafl gzip.stars.entrypoint.${ep}.zafl -o zafl:--stars -o "zafl:--entrypoint=$ep" +test_zafl ./gzip.stars.entrypoint.${ep}.zafl --fast +cleanup + +# test setting of entry point via function name +setup +build_zafl gzip.entrypoint.zafl -o "zafl:--entrypoint=main" +test_zafl ./gzip.entrypoint.zafl --slow +cleanup + # test STARS version setup build_zafl gzip.stars.zafl -o zafl:--stars @@ -78,6 +91,7 @@ test_zafl ./gzip.nostars.zafl --fast test_zafl ./gzip.nostars.zafl --best cleanup + log_success "all tests passed: zafl instrumentation operational on gzip" popd -- GitLab