From 3aa0dbdc85f9a4cadac0152ed1bfb4cad7c3174b Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Tue, 5 Nov 2024 12:21:36 +0900 Subject: Use C++ preprocessor in build recipe Also add uninstall target --- afl-dyninst.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'afl-dyninst.cc') diff --git a/afl-dyninst.cc b/afl-dyninst.cc index 8e3389d..5fb3d38 100644 --- a/afl-dyninst.cc +++ b/afl-dyninst.cc @@ -7,8 +7,6 @@ // SPDX-FileCopyrightText: 2024 Nguyễn Gia Phong // SPDX-License-Identifier: AGPL-3.0-or-later -#include "afl-dyninst.h" - // DyninstAPI includes #include "BPatch.h" #include "BPatch_flowGraph.h" @@ -336,16 +334,16 @@ int main(int argc, char **argv) { bpatch.setTrampRecursive(true); } - const char *dyninstapi_rt_lib_old = getenv("DYNINSTAPI_RT_LIB"); - if (setenv("DYNINSTAPI_RT_LIB", dyninstapi_rt_lib, true) != 0) { + const char *dyninstapi_rt_lib = getenv("DYNINSTAPI_RT_LIB"); + if (setenv("DYNINSTAPI_RT_LIB", DYNINSTAPI_RT_LIB, true) != 0) { cerr << "Failed to set DYNINSTAPI_RT_LIB\n"; // TODO: explain return EXIT_FAILURE; } - BPatch_addressSpace *appBin = bpatch.openBinary(originalBinary, instrumentLibraries.size() != 1); - if (dyninstapi_rt_lib_old == NULL) + BPatch_addressSpace *appBin = bpatch.openBinary(originalBinary, false); + if (dyninstapi_rt_lib == NULL) unsetenv("DYNINSTAPI_RT_LIB"); else - setenv("DYNINSTAPI_RT_LIB", dyninstapi_rt_lib_old, true); + setenv("DYNINSTAPI_RT_LIB", dyninstapi_rt_lib, true); if (appBin == NULL) { cerr << "Failed to open binary" << endl; return EXIT_FAILURE; @@ -402,8 +400,8 @@ int main(int argc, char **argv) { if (defaultModule == NULL) defaultModule = firstModule; - if (!appBin->loadLibrary(afl_dyninst_lib)) { - cerr << "Failed to open instrumentation library " << afl_dyninst_lib << endl; + if (!appBin->loadLibrary(AFL_DYNINST_LIB)) { + cerr << "Failed to open instrumentation library " << AFL_DYNINST_LIB << endl; cerr << "It needs to be located in the current working directory." << endl; return EXIT_FAILURE; } -- cgit 1.4.1