[PATCH] D55857: [asan] Prevent folding of globals with redzones
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 19 11:34:46 PST 2018
vitalybuka updated this revision to Diff 178929.
vitalybuka marked an inline comment as done.
vitalybuka added a comment.
updated comment
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55857/new/
https://reviews.llvm.org/D55857
Files:
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/test/Instrumentation/AddressSanitizer/global_cstring_darwin.ll
llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
llvm/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
llvm/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
Index: llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
===================================================================
--- llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
+++ llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
@@ -7,7 +7,7 @@
; CHECK: $"??_C at _04JIHMPGLA@asdf?$AA@" = comdat any
; CHECK: @"??_C at _04JIHMPGLA@asdf?$AA@" =
-; CHECK-SAME: linkonce_odr dso_local unnamed_addr constant { [5 x i8], [59 x i8] }
+; CHECK-SAME: linkonce_odr dso_local constant { [5 x i8], [59 x i8] }
; CHECK-SAME: { [5 x i8] c"asdf\00", [59 x i8] zeroinitializer }, comdat, align 32
; CHECK: @"__asan_global_??_C at _04JIHMPGLA@asdf?$AA@" =
Index: llvm/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
===================================================================
--- llvm/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
+++ llvm/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
@@ -14,8 +14,8 @@
; CHECK: $dead_global = comdat noduplicates
; CHECK: $private_str = comdat noduplicates
-; CHECK: @dead_global = local_unnamed_addr global { i32, [60 x i8] } { i32 42, [60 x i8] zeroinitializer }, comdat, align 32
-; CHECK: @private_str = internal unnamed_addr constant { [8 x i8], [56 x i8] } { [8 x i8] c"private\00", [56 x i8] zeroinitializer }, comdat, align 32
+; CHECK: @dead_global = global { i32, [60 x i8] } { i32 42, [60 x i8] zeroinitializer }, comdat, align 32
+; CHECK: @private_str = internal constant { [8 x i8], [56 x i8] } { [8 x i8] c"private\00", [56 x i8] zeroinitializer }, comdat, align 32
; CHECK: @__asan_global_dead_global = private global { {{.*}} }, section ".ASAN$GL", comdat($dead_global), align 64
; CHECK: @__asan_global_private_str = private global { {{.*}} }, section ".ASAN$GL", comdat($private_str), align 64
Index: llvm/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
===================================================================
--- llvm/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
+++ llvm/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
@@ -15,7 +15,7 @@
; Check that globals were instrumented:
; CHECK: @global = global { i32, [60 x i8] } zeroinitializer, align 32
-; CHECK: @.str = internal unnamed_addr constant { [14 x i8], [50 x i8] } { [14 x i8] c"Hello, world!\00", [50 x i8] zeroinitializer }{{.*}}, align 32
+; CHECK: @.str = internal constant { [14 x i8], [50 x i8] } { [14 x i8] c"Hello, world!\00", [50 x i8] zeroinitializer }{{.*}}, align 32
; Check emitted location descriptions:
; CHECK: [[VARNAME:@___asan_gen_.[0-9]+]] = private unnamed_addr constant [7 x i8] c"global\00", align 1
Index: llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
===================================================================
--- llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
+++ llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
@@ -15,7 +15,7 @@
; Check that globals were instrumented:
; CHECK: @global = global { i32, [60 x i8] } zeroinitializer, comdat, align 32
-; CHECK: @.str = internal unnamed_addr constant { [14 x i8], [50 x i8] } { [14 x i8] c"Hello, world!\00", [50 x i8] zeroinitializer }, comdat($".str${{[01-9a-f]+}}"), align 32
+; CHECK: @.str = internal constant { [14 x i8], [50 x i8] } { [14 x i8] c"Hello, world!\00", [50 x i8] zeroinitializer }, comdat($".str${{[01-9a-f]+}}"), align 32
; Check emitted location descriptions:
; CHECK: [[VARNAME:@___asan_gen_.[0-9]+]] = private unnamed_addr constant [7 x i8] c"global\00", align 1
Index: llvm/test/Instrumentation/AddressSanitizer/global_cstring_darwin.ll
===================================================================
--- llvm/test/Instrumentation/AddressSanitizer/global_cstring_darwin.ll
+++ llvm/test/Instrumentation/AddressSanitizer/global_cstring_darwin.ll
@@ -8,14 +8,14 @@
@.str.1 = private unnamed_addr constant [13 x i8] c"Hello world.\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
-; CHECK: @.str.1 = internal unnamed_addr constant { [13 x i8], [51 x i8] } { [13 x i8] c"Hello world.\00", [51 x i8] zeroinitializer }, section "__TEXT,__asan_cstring,regular", align 32
-; CHECK: @.str.2 = internal unnamed_addr constant { [4 x i8], [60 x i8] } { [4 x i8] c"%s\0A\00", [60 x i8] zeroinitializer }, section "__TEXT,__asan_cstring,regular", align 32
+; CHECK: @.str.1 = internal constant { [13 x i8], [51 x i8] } { [13 x i8] c"Hello world.\00", [51 x i8] zeroinitializer }, section "__TEXT,__asan_cstring,regular", align 32
+; CHECK: @.str.2 = internal constant { [4 x i8], [60 x i8] } { [4 x i8] c"%s\0A\00", [60 x i8] zeroinitializer }, section "__TEXT,__asan_cstring,regular", align 32
; Shouldn't be put into special section:
@.str.3 = private unnamed_addr constant [4 x i8] c"\00\01\02\03", align 1
@.str.4 = private unnamed_addr global [7 x i8] c"Hello.\00", align 1
@.str.5 = private unnamed_addr constant [8 x i8] c"Hello.\00\00", align 1
-; CHECK: @.str.3 = internal unnamed_addr constant { [4 x i8], [60 x i8] } { [4 x i8] c"\00\01\02\03", [60 x i8] zeroinitializer }, align 32
-; CHECK: @.str.4 = private unnamed_addr global { [7 x i8], [57 x i8] } { [7 x i8] c"Hello.\00", [57 x i8] zeroinitializer }, align 32
-; CHECK: @.str.5 = internal unnamed_addr constant { [8 x i8], [56 x i8] } { [8 x i8] c"Hello.\00\00", [56 x i8] zeroinitializer }, align 32
+; CHECK: @.str.3 = internal constant { [4 x i8], [60 x i8] } { [4 x i8] c"\00\01\02\03", [60 x i8] zeroinitializer }, align 32
+; CHECK: @.str.4 = private global { [7 x i8], [57 x i8] } { [7 x i8] c"Hello.\00", [57 x i8] zeroinitializer }, align 32
+; CHECK: @.str.5 = internal constant { [8 x i8], [56 x i8] } { [8 x i8] c"Hello.\00\00", [56 x i8] zeroinitializer }, align 32
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -2150,6 +2150,10 @@
NewGlobal->copyAttributesFrom(G);
NewGlobal->setComdat(G->getComdat());
NewGlobal->setAlignment(MinRZ);
+ // Don't fold globals with redzones. ODR violation detector and redzone
+ // poisoning implicitly creates a dependence on the global's address, so it
+ // is no longer valid for it to be marked unnamed_addr.
+ NewGlobal->setUnnamedAddr(GlobalValue::UnnamedAddr::None);
// Move null-terminated C strings to "__asan_cstring" section on Darwin.
if (TargetTriple.isOSBinFormatMachO() && !G->hasSection() &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55857.178929.patch
Type: text/x-patch
Size: 6654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181219/5239b202/attachment.bin>
More information about the llvm-commits
mailing list