fix llvm and afl-showmap
MODIFY
docs/Changelog.md
docs/Changelog.md
@@ -29,6 +29,7 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
- added neverzero counting to trace-pc/pcgard
- fixes for laf-intel float splitting (thanks to mark-griffin for
reporting)
+ - fixes for llvm 4.0
- skipping ctors and ifuncs for instrumentation
- LTO: switch default to the dynamic memory map, set AFL_LLVM_MAP_ADDR
for a fixed map address (eg. 0x10000)

MODIFY
llvm_mode/LLVMInsTrim.so.cc
llvm_mode/LLVMInsTrim.so.cc
@@ -94,7 +94,7 @@ struct InsTrim : public ModulePass {
}
-#if LLVM_VERSION_MAJOR >= 4 || \
+#if LLVM_VERSION_MAJOR > 4 || \
(LLVM_VERSION_MAJOR == 4 && LLVM_VERSION_PATCH >= 1)
#define AFL_HAVE_VECTOR_INTRINSICS 1
#endif

MODIFY
llvm_mode/afl-clang-fast.c
llvm_mode/afl-clang-fast.c
@@ -371,8 +371,12 @@ static void edit_params(u32 argc, char **argv, char **envp) {
if (instrument_mode == INSTRUMENT_PCGUARD) {
+#if LLVM_VERSION_MAJOR >= 4
cc_params[cc_par_cnt++] =
"-fsanitize-coverage=trace-pc-guard"; // edge coverage by default
+#else
+ FATAL("pcguard instrumentation requires llvm 4.0.1+");
+#endif
} else {

MODIFY
llvm_mode/afl-llvm-common.cc
llvm_mode/afl-llvm-common.cc
@@ -260,6 +260,8 @@ void scanForDangerousFunctions(llvm::Module *M) {
if (!M) return;
+#if LLVM_VERSION_MAJOR >= 4
+
for (GlobalIFunc &IF : M->ifuncs()) {
StringRef ifunc_name = IF.getName();
@@ -325,6 +327,8 @@ void scanForDangerousFunctions(llvm::Module *M) {
}
+#endif
+
}
static std::string getSourceName(llvm::Function *F) {

MODIFY
llvm_mode/afl-llvm-pass.so.cc
llvm_mode/afl-llvm-pass.so.cc
@@ -112,7 +112,7 @@ uint64_t PowerOf2Ceil(unsigned in) {
#endif
/* #if LLVM_VERSION_STRING >= "4.0.1" */
-#if LLVM_VERSION_MAJOR >= 4 || \
+#if LLVM_VERSION_MAJOR > 4 || \
(LLVM_VERSION_MAJOR == 4 && LLVM_VERSION_PATCH >= 1)
#define AFL_HAVE_VECTOR_INTRINSICS 1
#endif

MODIFY
src/afl-showmap.c
src/afl-showmap.c
@@ -963,7 +963,7 @@ int main(int argc, char **argv_orig, char **envp) {
// if a queue subdirectory exists switch to that
u8 *dn = alloc_printf("%s/queue", in_dir);
- if ((dir_in = opendir(in_dir))) {
+ if ((dir_in = opendir(dn)) != NULL) {
closedir(dir_in);
in_dir = dn;

fix llvm and afl-showmap