From 37fd800e917269df7824052452bcbd65f5528a3e Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 2 Feb 2021 14:29:04 +0000 Subject: Use mmap for compiled code for gtest. Avoid executing code in memory allocated with malloc() as pointers to that memory can be tagged which interferes with managed stack walk. Test: m test-art-host-gtest. Bug: 177816575 Change-Id: Id376091f82d5686adf3ab18d2980a42e78de57ce --- compiler/optimizing/codegen_test_utils.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'compiler/optimizing/codegen_test_utils.h') diff --git a/compiler/optimizing/codegen_test_utils.h b/compiler/optimizing/codegen_test_utils.h index 9d15f1f294..397e601cee 100644 --- a/compiler/optimizing/codegen_test_utils.h +++ b/compiler/optimizing/codegen_test_utils.h @@ -248,9 +248,17 @@ static void Run(const InternalCodeAllocator& allocator, Expected expected) { InstructionSet target_isa = codegen.GetInstructionSet(); + struct CodeHolder : CommonCompilerTestImpl { + protected: + ClassLinker* GetClassLinker() override { return nullptr; } + Runtime* GetRuntime() override { return nullptr; } + }; + CodeHolder code_holder; + const void* code_ptr = + code_holder.MakeExecutable(allocator.GetMemory(), ArrayRef(), target_isa); + typedef Expected (*fptr)(); - CommonCompilerTest::MakeExecutable(allocator.GetMemory().data(), allocator.GetMemory().size()); - fptr f = reinterpret_cast(reinterpret_cast(allocator.GetMemory().data())); + fptr f = reinterpret_cast(reinterpret_cast(code_ptr)); if (target_isa == InstructionSet::kThumb2) { // For thumb we need the bottom bit set. f = reinterpret_cast(reinterpret_cast(f) + 1); -- cgit v1.2.3