[PATCH] D44784: DataFlowSanitizer: do not allow wrapper functions with non-local linkage to have dso_local set.
Sam Kerner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 23 10:39:30 PDT 2018
skerner updated this revision to Diff 139610.
skerner added a comment.
Address review comment: Wrappers of local functions should have the same linkage as the function being wrapped.
Repository:
rL LLVM
https://reviews.llvm.org/D44784
Files:
lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
test/Instrumentation/DataFlowSanitizer/uninstrumented_local_functions.ll
Index: test/Instrumentation/DataFlowSanitizer/uninstrumented_local_functions.ll
===================================================================
--- /dev/null
+++ test/Instrumentation/DataFlowSanitizer/uninstrumented_local_functions.ll
@@ -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"
Index: test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
===================================================================
--- test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
+++ test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
@@ -6,3 +6,5 @@
fun:custom*=uninstrumented
fun:custom*=custom
+
+fun:uninstrumented*=uninstrumented
Index: lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -859,9 +859,17 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44784.139610.patch
Type: text/x-patch
Size: 2477 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180323/ca2980ea/attachment.bin>
More information about the llvm-commits
mailing list