diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2018-03-30 18:37:55 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2018-03-30 18:37:55 +0000 |
| commit | d03bf12c1bc13f7e75be90d04eeaa38128c9d5e0 (patch) | |
| tree | e4876b4fd24b1302854fed28e79b4c0009b5c659 /llvm/lib/Transforms | |
| parent | 5e3ee945623c1eff6477ae204b1376a4bd55e793 (diff) | |
| download | bcm5719-llvm-d03bf12c1bc13f7e75be90d04eeaa38128c9d5e0.tar.gz bcm5719-llvm-d03bf12c1bc13f7e75be90d04eeaa38128c9d5e0.zip | |
DataFlowSanitizer: wrappers of functions with local linkage should have the same linkage as the function being wrapped
This patch resolves link errors when the address of a static function is taken, and that function is uninstrumented by DFSan.
This change resolves bug 36314.
Patch by Sam Kerner!
Differential Revision: https://reviews.llvm.org/D44784
llvm-svn: 328890
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp index 16199851fb3..0bfe38afe91 100644 --- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -859,9 +859,17 @@ bool DataFlowSanitizer::runOnModule(Module &M) { FunctionType *NewFT = getInstrumentedABI() == IA_Args ? getArgsFunctionType(FT) : FT; + + // If the function being wrapped has local linkage, then preserve the + // function's linkage in the wrapper function. + GlobalValue::LinkageTypes wrapperLinkage = + F.hasLocalLinkage() + ? F.getLinkage() + : GlobalValue::LinkOnceODRLinkage; + Function *NewF = buildWrapperFunction( &F, std::string("dfsw$") + std::string(F.getName()), - GlobalValue::LinkOnceODRLinkage, NewFT); + wrapperLinkage, NewFT); if (getInstrumentedABI() == IA_TLS) NewF->removeAttributes(AttributeList::FunctionIndex, ReadOnlyNoneAttrs); |

