-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
The basic block which writes to the coverage map also has to set the previous location.
There are two issues with how this is implemented in InsTrim:
- the algorithm for this in afl is:
index = curr_location ^ (prev_location >> 1);
map[index]++;
In the InsTrim code the right shift of the prev_location is never performed.
- the prev_location written is always a specific one and not the one that was actually the path.
e.g.
EntryBlock
/ | \
A B C
\ | /
ExitBlock
The writing to the map will happen in the ExitBlock, and the prev_location written will always be the ID of block A, and not depend on which actual path was taken.
In the code this is visible in the following line:
IRB.CreateStore(ConstantInt::get(Int32Ty, genLabel()), OldPrev);
Two fix both issues, in afl++ we removed that CreateStore() and added after IRB.CreateStore(Incr, MapPtrIdx);:
Value *Shr = IRB.CreateLShr(L, One32);
IRB.CreateStore(Shr, OldPrev)->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
Note that this also needs a ConstantInt *One32 = ConstantInt::get(Int32Ty, 1); definition after IntegerType *Int32Ty ...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels