[PATCH] D53113: [SanitizerCoverage] Make Inline8bit and TracePC counters dead stripping resistant.

Max Moroz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 10 15:42:36 PDT 2018


Dor1s created this revision.
Dor1s added reviewers: morehouse, kcc, george.karpenkov.

Otherwise, at least on Mac, the linker eliminates unused symbols which
causes libFuzzer to error out due to a mismatch of the sizes of coverage tables.

Issue in Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=892167


Repository:
  rL LLVM

https://reviews.llvm.org/D53113

Files:
  lib/Transforms/Instrumentation/SanitizerCoverage.cpp


Index: lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===================================================================
--- lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -636,11 +636,15 @@
         AllBlocks.size(), F, Int32Ty, SanCovGuardsSectionName);
     GlobalsToAppendToUsed.push_back(FunctionGuardArray);
   }
-  if (Options.Inline8bitCounters)
+  if (Options.Inline8bitCounters) {
     Function8bitCounterArray = CreateFunctionLocalArrayInSection(
         AllBlocks.size(), F, Int8Ty, SanCovCountersSectionName);
-  if (Options.PCTable)
+    GlobalsToAppendToUsed.push_back(Function8bitCounterArray);
+  }
+  if (Options.PCTable) {
     FunctionPCsArray = CreatePCArray(F, AllBlocks);
+    GlobalsToAppendToUsed.push_back(FunctionPCsArray);
+  }
 }
 
 bool SanitizerCoverageModule::InjectCoverage(Function &F,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53113.169115.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181010/3c425430/attachment.bin>


More information about the llvm-commits mailing list