[PATCH] D39470: [asan] Fix size/alignment issues with non-default shadow scale
Walter Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 16 04:57:37 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318395: [asan] Fix size/alignment issues with non-default shadow scale (authored by waltl).
Changed prior to commit:
https://reviews.llvm.org/D39470?vs=122691&id=123160#toc
Repository:
rL LLVM
https://reviews.llvm.org/D39470
Files:
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/trunk/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
Index: llvm/trunk/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
===================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
@@ -24,6 +24,8 @@
; Check that location descriptors and global names were passed into __asan_register_globals:
; CHECK: i64 ptrtoint ([7 x i8]* [[VARNAME]] to i64)
; CHECK: i64 ptrtoint ({ [22 x i8]*, i32, i32 }* [[LOCDESCR]] to i64)
+; Check alignment of metadata_array.
+; CHECK-S5-SAME: {{align 32$}}
; Function Attrs: nounwind sanitize_address
define internal void @__cxx_global_var_init() #0 section ".text.startup" {
Index: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1978,6 +1978,8 @@
auto AllGlobals = new GlobalVariable(
M, ArrayOfGlobalStructTy, false, GlobalVariable::InternalLinkage,
ConstantArray::get(ArrayOfGlobalStructTy, MetadataInitializers), "");
+ if (Mapping.Scale > 3)
+ AllGlobals->setAlignment(1ULL << Mapping.Scale);
IRB.CreateCall(AsanRegisterGlobals,
{IRB.CreatePointerCast(AllGlobals, IntptrTy),
@@ -2817,9 +2819,10 @@
// Minimal header size (left redzone) is 4 pointers,
// i.e. 32 bytes on 64-bit platforms and 16 bytes in 32-bit platforms.
- size_t MinHeaderSize = ASan.LongSize / 2;
+ size_t Granularity = 1ULL << Mapping.Scale;
+ size_t MinHeaderSize = std::max((size_t)ASan.LongSize / 2, Granularity);
const ASanStackFrameLayout &L =
- ComputeASanStackFrameLayout(SVD, 1ULL << Mapping.Scale, MinHeaderSize);
+ ComputeASanStackFrameLayout(SVD, Granularity, MinHeaderSize);
// Build AllocaToSVDMap for ASanStackVariableDescription lookup.
DenseMap<const AllocaInst *, ASanStackVariableDescription *> AllocaToSVDMap;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39470.123160.patch
Type: text/x-patch
Size: 2061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171116/16fcf3bc/attachment.bin>
More information about the llvm-commits
mailing list