fix for new llvm 13 change
MODIFY
docs/Changelog.md
docs/Changelog.md
@@ -9,6 +9,8 @@ Want to stay in the loop on major new features? Join our mailing list by
sending a mail to <afl-users+subscribe@googlegroups.com>.
### Version ++3.12a (dev)
+ - afl-fuzz:
+ - better map detection, AFL_MAP_SIZE not needed anymore for most cases
- afl-cc:
- fix cmplog rtn (rare crash and not being able to gather ptr data)
- link runtime not to shared libs
@@ -16,6 +18,8 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
- qemu_mode (thanks @realmadsci):
- move AFL_PRELOAD and AFL_USE_QASAN logic inside afl-qemu-trace
- add AFL_QEMU_CUSTOM_BIN
+ - unicorn_mode
+ - accidently removed the subfolder from github, re-added
### Version ++3.11c (release)
- afl-fuzz:

MODIFY
instrumentation/README.lto.md
instrumentation/README.lto.md
@@ -113,7 +113,7 @@ cmake \
-DLLVM_LINK_LLVM_DYLIB="ON" \
-DLLVM_TARGETS_TO_BUILD="host" \
../llvm/
-cmake --build . --parallel
+cmake --build . -j4
export PATH="$(pwd)/bin:$PATH"
export LLVM_CONFIG="$(pwd)/bin/llvm-config"
export LD_LIBRARY_PATH="$(llvm-config --libdir)${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"

MODIFY
instrumentation/SanitizerCoverageLTO.so.cc
instrumentation/SanitizerCoverageLTO.so.cc
@@ -1291,10 +1291,17 @@ GlobalVariable *ModuleSanitizerCoverage::CreateFunctionLocalArrayInSection(
*CurModule, ArrayTy, false, GlobalVariable::PrivateLinkage,
Constant::getNullValue(ArrayTy), "__sancov_gen_");
+#if LLVM_VERSION_MAJOR > 12
+ if (TargetTriple.supportsCOMDAT() &&
+ (TargetTriple.isOSBinFormatELF() || !F.isInterposable()))
+ if (auto Comdat = getOrCreateFunctionComdat(F, TargetTriple))
+ Array->setComdat(Comdat);
+#else
if (TargetTriple.supportsCOMDAT() && !F.isInterposable())
if (auto Comdat =
GetOrCreateFunctionComdat(F, TargetTriple, CurModuleUniqueId))
Array->setComdat(Comdat);
+#endif
Array->setSection(getSectionName(Section));
Array->setAlignment(Align(DL->getTypeStoreSize(Ty).getFixedSize()));
GlobalsToAppendToUsed.push_back(Array);

MODIFY
instrumentation/SanitizerCoveragePCGUARD.so.cc
instrumentation/SanitizerCoveragePCGUARD.so.cc
@@ -769,10 +769,18 @@ GlobalVariable *ModuleSanitizerCoverage::CreateFunctionLocalArrayInSection(
*CurModule, ArrayTy, false, GlobalVariable::PrivateLinkage,
Constant::getNullValue(ArrayTy), "__sancov_gen_");
+#if LLVM_VERSION_MAJOR > 12
+ if (TargetTriple.supportsCOMDAT() &&
+ (TargetTriple.isOSBinFormatELF() || !F.isInterposable()))
+ if (auto Comdat = getOrCreateFunctionComdat(F, TargetTriple))
+ Array->setComdat(Comdat);
+#else
if (TargetTriple.supportsCOMDAT() && !F.isInterposable())
if (auto Comdat =
GetOrCreateFunctionComdat(F, TargetTriple, CurModuleUniqueId))
Array->setComdat(Comdat);
+#endif
+
Array->setSection(getSectionName(Section));
#if LLVM_MAJOR > 10 || (LLVM_MAJOR == 10 && LLVM_MINOR > 0)
Array->setAlignment(Align(DL->getTypeStoreSize(Ty).getFixedSize()));

MODIFY
instrumentation/afl-compiler-rt.o.c
instrumentation/afl-compiler-rt.o.c
@@ -1681,6 +1681,7 @@ void __sanitizer_cov_trace_const_cmp16(uint128_t arg1, uint128_t arg2) {
__cmplog_ins_hook16(arg1, arg2, 0);
}
+
#endif
void __sanitizer_cov_trace_switch(uint64_t val, uint64_t *cases) {

MODIFY
instrumentation/afl-llvm-common.cc
instrumentation/afl-llvm-common.cc
@@ -96,17 +96,9 @@ bool isIgnoreFunction(const llvm::Function *F) {
static const char *ignoreSubstringList[] = {
- "__asan",
- "__msan",
- "__ubsan",
- "__lsan",
- "__san",
- "__sanitize",
- "__cxx",
- "_GLOBAL__",
- "DebugCounter",
- "DwarfDebug",
- "DebugLoc"
+ "__asan", "__msan", "__ubsan", "__lsan",
+ "__san", "__sanitize", "__cxx", "_GLOBAL__",
+ "DebugCounter", "DwarfDebug", "DebugLoc"
};

MODIFY
test/test-dlopen.c
test/test-dlopen.c
int main(int argc, char **argv) {
- if (!getenv("TEST_DLOPEN_TARGET"))
- return 1;
+ if (!getenv("TEST_DLOPEN_TARGET")) return 1;
void *lib = dlopen(getenv("TEST_DLOPEN_TARGET"), RTLD_LAZY);
if (!lib) {
+
perror(dlerror());
return 2;
+
}
+
int (*func)(int, char **) = dlsym(lib, "main_exported");
- if (!func)
- return 3;
+ if (!func) return 3;
return func(argc, argv);
}
+

DELETE
test/travis/bionic/Dockerfile
-# This is the Dockerfile for testing problems in Travis build
-# configuration #1.
-# This needs not to be rebuild everytime, most of the time it needs just to
-# be build once and then started when debugging issues and execute:
-# cd /AFLplusplus/
-# git pull
-# make distrib
-#
-FROM ubuntu:bionic
-LABEL "about"="travis image 1"
-RUN apt-get update && apt-get -y install \
- automake \
- bison \
- build-essential \
- clang \
- flex \
- git \
- python3.7 python3.7-dev \
- python3-setuptools \
- libtool libtool-bin \
- libglib2.0-dev \
- python-setuptools \
- wget \
- ca-certificates \
- libpixman-1-dev \
- gcc-7 gcc-7-plugin-dev libc++-7-dev \
- findutils \
- libcmocka-dev \
- joe nano vim locate \
- && rm -rf /var/lib/apt/lists/*
-
-ENV AFL_NO_UI=1
-ENV AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1
-ENV LLVM_CONFIG=llvm-config-6.0
-
-RUN cd / && \
- git clone https://github.com/AFLplusplus/AFLplusplus && \
- cd AFLplusplus && \
- git checkout dev && \
- cd qemu_mode && wget http://download.qemu-project.org/qemu-3.1.1.tar.xz && \
- cd ../unicorn_mode && git submodule init && git submodule update || true && \
- cd /AFLplusplus && ASAN_BUILD=1 make source-only || true
-
-WORKDIR /AFLplusplus
-CMD ["/bin/bash"]

DELETE
test/travis/focal/Dockerfile
-# This is the Dockerfile for testing problems in Travis build
-# configuration #1.
-# This needs not to be rebuild everytime, most of the time it needs just to
-# be build once and then started when debugging issues and execute:
-# cd /AFLplusplus/
-# git pull
-# make distrib
-#
-FROM ubuntu:focal
-LABEL "about"="travis image 4"
-ARG DEBIAN_FRONTEND=noninteractive
-RUN apt-get update && apt-get -y install \
- automake \
- bison \
- build-essential \
- clang \
- flex \
- git \
- python3 python3-dev \
- python3-setuptools \
- libtool libtool-bin \
- libglib2.0-dev \
- python-setuptools \
- wget \
- ca-certificates \
- libpixman-1-dev \
- gcc-9 gcc-9-plugin-dev libc++-9-dev \
- findutils \
- libcmocka-dev \
- joe nano vim locate \
- && rm -rf /var/lib/apt/lists/*
-
-ENV AFL_NO_UI=1
-ENV AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1
-
-RUN cd / && \
- git clone https://github.com/AFLplusplus/AFLplusplus && \
- cd AFLplusplus && \
- git checkout dev && \
- cd qemu_mode && wget http://download.qemu-project.org/qemu-3.1.1.tar.xz && \
- cd ../unicorn_mode && git submodule init && git submodule update || true && \
- cd /AFLplusplus && ASAN_BUILD=1 make source-only || true
-
-WORKDIR /AFLplusplus
-CMD ["/bin/bash"]

DELETE
test/travis/trusty/Dockerfile
-# This is the Dockerfile for testing problems in Travis builds
-# configuration #3.
-# This needs not to be rebuild everytime, most of the time it needs just to
-# be build once and then started when debugging issues and execute:
-# cd /AFLplusplus/
-# git pull
-# make distrib
-#
-FROM ubuntu:trusty
-LABEL "about"="travis image 3"
-RUN apt-get update && apt-get -y install \
- automake \
- bison \
- build-essential \
- clang \
- flex \
- git \
- python2.7 python2.7-dev \
- python3-setuptools \
- libtool \
- libglib2.0-dev \
- python-setuptools \
- wget \
- ca-certificates \
- libpixman-1-dev \
- gcc-4.8 gcc-4.8-plugin-dev \
- libc++-dev \
- findutils \
- libcmocka-dev \
- joe nano vim locate \
- && rm -rf /var/lib/apt/lists/*
-
-ENV TERM linux
-ENV DEBIAN_FRONTEND noninteractive
-ENV LLVM_CONFIG=llvm-config-3.4
-ENV AFL_NO_UI=1
-ENV AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1
-
-RUN cd / && \
- git clone https://github.com/AFLplusplus/AFLplusplus && \
- cd AFLplusplus && \
- git checkout dev && \
- cd qemu_mode && wget http://download.qemu-project.org/qemu-3.1.1.tar.xz && \
- cd ../unicorn_mode && git submodule init && git submodule update || true && \
- cd /AFLplusplus && ASAN_BUILD=1 make source-only || true
-
-WORKDIR /AFLplusplus
-CMD ["/bin/bash"]
-

DELETE
test/travis/xenial/Dockerfile
-# This is the Dockerfile for testing problems in Travis builds
-# configuration #2.
-# This needs not to be rebuild everytime, most of the time it needs just to
-# be build once and then started when debugging issues and execute:
-# cd /AFLplusplus/
-# git pull
-# make distrib
-#
-FROM ubuntu:xenial
-LABEL "about"="travis image 2"
-RUN apt-get update && apt-get -y install \
- automake \
- bison \
- build-essential \
- clang-6.0 \
- flex \
- git \
- python3 python3-dev \
- python3-setuptools \
- libtool libtool-bin \
- libglib2.0-dev \
- python-setuptools \
- wget \
- ca-certificates \
- libpixman-1-dev \
- gcc-5 gcc-5-plugin-dev \
- libc++-dev \
- findutils \
- libcmocka-dev \
- joe nano vim locate \
- && rm -rf /var/lib/apt/lists/*
-
-ENV LLVM_CONFIG=llvm-config-6.0
-ENV AFL_NO_UI=1
-ENV AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1
-
-RUN cd / && \
- git clone https://github.com/AFLplusplus/AFLplusplus && \
- cd AFLplusplus && \
- git checkout dev && \
- cd qemu_mode && wget http://download.qemu-project.org/qemu-3.1.1.tar.xz && \
- cd ../unicorn_mode && git submodule init && git submodule update || true && \
- cd /AFLplusplus && ASAN_BUILD=1 make source-only || true
-
-WORKDIR /AFLplusplus
-CMD ["/bin/bash"]

fix for new llvm 13 change