From a69b1311b28ba80fc122fc0837ec149d1b2999e6 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Tue, 14 Jul 2015 16:27:16 +0000 Subject: [PATCH] Allocate the IntervalMap in ELF.h on the heap to work around MSVC alignment bug (PR24113) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242157 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELF.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 2f4b38b09e3..cc271851e6b 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -731,7 +731,9 @@ void ELFFile::scanDynamicTable() { IntervalMapImpl::NodeSizer::LeafSize, IntervalMapHalfOpenInfo> LoadMapT; typename LoadMapT::Allocator Alloc; - LoadMapT LoadMap(Alloc); + // Allocate the IntervalMap on the heap to work around MSVC bug where the + // stack doesn't get realigned despite LoadMap having alignment 8 (PR24113). + std::unique_ptr LoadMap(new LoadMapT(Alloc)); for (Elf_Phdr_Iter PhdrI = program_header_begin(), PhdrE = program_header_end(); @@ -746,13 +748,13 @@ void ELFFile::scanDynamicTable() { continue; if (PhdrI->p_filesz == 0) continue; - LoadMap.insert(PhdrI->p_vaddr, PhdrI->p_vaddr + PhdrI->p_filesz, - PhdrI->p_offset); + LoadMap->insert(PhdrI->p_vaddr, PhdrI->p_vaddr + PhdrI->p_filesz, + PhdrI->p_offset); } auto toMappedAddr = [&](uint64_t VAddr) -> const uint8_t * { - auto I = LoadMap.find(VAddr); - if (I == LoadMap.end()) + auto I = LoadMap->find(VAddr); + if (I == LoadMap->end()) return nullptr; return this->base() + I.value() + (VAddr - I.start()); }; -- 2.34.1