[PATCH] D53040: [libFuzzer] Generalize the code for getting the previous offset for different architectures

George Karpenkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 9 14:53:07 PDT 2018


george.karpenkov added inline comments.


================
Comment at: compiler-rt/lib/fuzzer/FuzzerTracePC.cpp:202
+  // 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__)
----------------
Dor1s wrote:
> Are you sure you need `-3` here, not `-2`? I'm definitely not an expert here, so it's more like a sanity check question :)
> 
> ```
> >>> hex((0x122 - 3) & (~1))
> '0x11e'
> >>> hex((0x122 - 2) & (~1))
> '0x120'
> ```
> 
I've copied this code from `sanitizer_common/sanitizer_stracktrace.h`.

Another possibility is to link to sanitizer_common instead, but I think at one point @kcc was against that (has that changed?)


https://reviews.llvm.org/D53040





More information about the llvm-commits mailing list