fix issue#63 compilation problem with a workaround

for llvm 6.0 and Ubuntu 18.04
This commit is contained in:
hexcoder-
2019-09-25 07:10:38 +02:00
parent c71fc74248
commit c08f4f5845

View File

@ -221,6 +221,11 @@ bool AFLCoverage::runOnModule(Module &M) {
// cur_loc++; // cur_loc++;
cur_loc = AFL_R(MAP_SIZE); cur_loc = AFL_R(MAP_SIZE);
/* There is a problem with Ubuntu 18.04 and llvm 6.0 (see issue #63).
The inline function successors() is not inlined and also not found at runtime :-(
As I am unable to detect Ubuntu18.04 heree, the next best thing is to disable
this optional optimization for LLVM 6.0.0 and Linux */
#if !(LLVM_VERSION_MAJOR == 6 && LLVM_VERSION_MINOR == 0) || !defined __linux__
// only instrument if this basic block is the destination of a previous // only instrument if this basic block is the destination of a previous
// basic block that has multiple successors // basic block that has multiple successors
// this gets rid of ~5-10% of instrumentations that are unnecessary // this gets rid of ~5-10% of instrumentations that are unnecessary
@ -232,6 +237,7 @@ bool AFLCoverage::runOnModule(Module &M) {
int count = 0; int count = 0;
if (more_than_one == -1) more_than_one = 0; if (more_than_one == -1) more_than_one = 0;
// fprintf(stderr, " %p=>", Pred); // fprintf(stderr, " %p=>", Pred);
for (BasicBlock *Succ : successors(Pred)) { for (BasicBlock *Succ : successors(Pred)) {
// if (count > 0) // if (count > 0)
@ -247,7 +253,7 @@ bool AFLCoverage::runOnModule(Module &M) {
// fprintf(stderr, " == %d\n", more_than_one); // fprintf(stderr, " == %d\n", more_than_one);
if (more_than_one != 1) continue; if (more_than_one != 1) continue;
#endif
ConstantInt *CurLoc = ConstantInt::get(Int32Ty, cur_loc); ConstantInt *CurLoc = ConstantInt::get(Int32Ty, cur_loc);
/* Load prev_loc */ /* Load prev_loc */