[llvm] r328890 - DataFlowSanitizer: wrappers of functions with local linkage should have the same linkage as the function being wrapped
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 30 11:37:55 PDT 2018
Author: pcc
Date: Fri Mar 30 11:37:55 2018
New Revision: 328890
URL: http://llvm.org/viewvc/llvm-project?rev=328890&view=rev
Log:
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
Added:
llvm/trunk/test/Instrumentation/DataFlowSanitizer/uninstrumented_local_functions.ll
Modified:
llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
llvm/trunk/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
Modified: llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp?rev=328890&r1=328889&r2=328890&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp Fri Mar 30 11:37:55 2018
@@ -859,9 +859,17 @@ bool DataFlowSanitizer::runOnModule(Modu
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);
Modified: llvm/trunk/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt?rev=328890&r1=328889&r2=328890&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt (original)
+++ llvm/trunk/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt Fri Mar 30 11:37:55 2018
@@ -6,3 +6,5 @@ fun:functional=functional
fun:custom*=uninstrumented
fun:custom*=custom
+
+fun:uninstrumented*=uninstrumented
Added: llvm/trunk/test/Instrumentation/DataFlowSanitizer/uninstrumented_local_functions.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/DataFlowSanitizer/uninstrumented_local_functions.ll?rev=328890&view=auto
==============================================================================
--- llvm/trunk/test/Instrumentation/DataFlowSanitizer/uninstrumented_local_functions.ll (added)
+++ llvm/trunk/test/Instrumentation/DataFlowSanitizer/uninstrumented_local_functions.ll Fri Mar 30 11:37:55 2018
@@ -0,0 +1,24 @@
+; RUN: opt < %s -dfsan -dfsan-args-abi -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s
+; RUN: opt < %s -dfsan -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+define internal i8 @uninstrumented_internal_fun(i8 %in) {
+ ret i8 %in
+}
+
+define i8 @call_uninstrumented_internal_fun(i8 %in) {
+ %call = call i8 @uninstrumented_internal_fun(i8 %in)
+ ret i8 %call
+}
+; CHECK: define internal {{(i8|{ i8, i16 })}} @"dfsw$uninstrumented_internal_fun"
+
+define private i8 @uninstrumented_private_fun(i8 %in) {
+ ret i8 %in
+}
+
+define i8 @call_uninstrumented_private_fun(i8 %in) {
+ %call = call i8 @uninstrumented_private_fun(i8 %in)
+ ret i8 %call
+}
+; CHECK: define private {{(i8|{ i8, i16 })}} @"dfsw$uninstrumented_private_fun"
More information about the llvm-commits
mailing list