Skip to content

Commit

Permalink
[libFuzzer] Refactor GetNextInstructionPc/GetPreviousInstructionPc
Browse files Browse the repository at this point in the history
Port the change to compiler-rt/lib/fuzzer/FuzzerTracePC.cpp .
Update RISCV to use PC-2: this is coarse (C extension may be disabled) but
sufficient for pure symbolization purpose.

The commit is separate from D120362 so that bisecting/reverting is easier.
  • Loading branch information
MaskRay committed Feb 23, 2022
1 parent 8b83b8f commit fc0bd3c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
Expand Up @@ -133,13 +133,14 @@ inline ALWAYS_INLINE uintptr_t GetPreviousInstructionPc(uintptr_t PC) {
// so we return (pc-2) in that case in order to be safe.
// For A32 mode we return (pc-4) because all instructions are 32 bit long.
return (PC - 3) & (~1);
#elif defined(__powerpc__) || defined(__powerpc64__) || defined(__aarch64__)
// PCs are always 4 byte aligned.
return PC - 4;
#elif defined(__sparc__) || defined(__mips__)
return PC - 8;
#else
#elif defined(__riscv__)
return PC - 2;
#elif defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
return PC - 1;
#else
return PC - 4;
#endif
}

Expand Down

0 comments on commit fc0bd3c

Please sign in to comment.