summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
diff options
context:
space:
mode:
authorMatt Morehouse <mascasa@google.com>2018-08-14 22:04:34 +0000
committerMatt Morehouse <mascasa@google.com>2018-08-14 22:04:34 +0000
commit0f22fac2742bd3e382bba577671c19841ac2b5f7 (patch)
treeec02544706d7b556cca539554efe29b08fd14146 /llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
parentcd4056c8810c1336d6059e1338b7af9400a141d5 (diff)
downloadbcm5719-llvm-0f22fac2742bd3e382bba577671c19841ac2b5f7.tar.gz
bcm5719-llvm-0f22fac2742bd3e382bba577671c19841ac2b5f7.zip
[SanitizerCoverage] Add associated metadata to PC guards.
Summary: Without this metadata LLD strips unused PC table entries but won't strip unused guards. This metadata also seems to influence the linker to change the ordering in the PC guard section to match that of the PC table section. The libFuzzer runtime library depends on the ordering of the PC table and PC guard sections being the same. This is not generally guaranteed, so we may need to redesign PC tables/guards/counters in the future. Reviewers: eugenis Reviewed By: eugenis Subscribers: kcc, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D50483 llvm-svn: 339733
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp')
-rw-r--r--llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
index a4dd48c8dd6..c0b219d1d1b 100644
--- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -591,6 +591,9 @@ void SanitizerCoverageModule::CreateFunctionLocalArrays(
FunctionGuardArray = CreateFunctionLocalArrayInSection(
AllBlocks.size(), F, Int32Ty, SanCovGuardsSectionName);
GlobalsToAppendToUsed.push_back(FunctionGuardArray);
+ GlobalsToAppendToCompilerUsed.push_back(FunctionGuardArray);
+ MDNode *MD = MDNode::get(F.getContext(), ValueAsMetadata::get(&F));
+ FunctionGuardArray->addMetadata(LLVMContext::MD_associated, *MD);
}
if (Options.Inline8bitCounters) {
Function8bitCounterArray = CreateFunctionLocalArrayInSection(
OpenPOWER on IntegriCloud