mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-11 21:56:15 +00:00
[asan] Fix size/alignment issues with non-default shadow scale
Fix a couple places where the minimum alignment/size should be a function of the shadow granularity: - alignment of AllGlobals - the minimum left redzone size on the stack Added a test to verify that the metadata_array is properly aligned for shadow scale of 5, to be enabled when we add build support for testing shadow scale of 5. Differential Revision: https://reviews.llvm.org/D39470 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318395 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
73d6c71188
commit
2746bda55f
@ -1978,6 +1978,8 @@ void AddressSanitizerModule::InstrumentGlobalsWithMetadataArray(
|
||||
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 @@ void FunctionStackPoisoner::processStaticAllocas() {
|
||||
|
||||
// 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;
|
||||
|
@ -24,6 +24,8 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
; 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" {
|
||||
|
Loading…
Reference in New Issue
Block a user