diff options
Diffstat (limited to 'llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp')
-rw-r--r-- | llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp index 4e1caa0400f..75345de5028 100644 --- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp +++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp @@ -486,10 +486,7 @@ static int checkAllExpressions(RuntimeDyldChecker &Checker) { return 0; } -static std::map<void *, uint64_t> -applySpecificSectionMappings(RuntimeDyldChecker &Checker) { - - std::map<void*, uint64_t> SpecificMappings; +void applySpecificSectionMappings(RuntimeDyldChecker &Checker) { for (StringRef Mapping : SpecificSectionMappings) { @@ -522,10 +519,7 @@ applySpecificSectionMappings(RuntimeDyldChecker &Checker) { "'."); Checker.getRTDyld().mapSectionAddress(OldAddr, NewAddr); - SpecificMappings[OldAddr] = NewAddr; } - - return SpecificMappings; } // Scatter sections in all directions! @@ -554,8 +548,7 @@ static void remapSectionsAndSymbols(const llvm::Triple &TargetTriple, // Apply any section-specific mappings that were requested on the command // line. - typedef std::map<void*, uint64_t> AppliedMappingsT; - AppliedMappingsT AppliedMappings = applySpecificSectionMappings(Checker); + applySpecificSectionMappings(Checker); // Keep an "already allocated" mapping of section target addresses to sizes. // Sections whose address mappings aren't specified on the command line will @@ -563,15 +556,19 @@ static void remapSectionsAndSymbols(const llvm::Triple &TargetTriple, // minimum separation. std::map<uint64_t, uint64_t> AlreadyAllocated; - // Move the previously applied mappings into the already-allocated map. + // Move the previously applied mappings (whether explicitly specified on the + // command line, or implicitly set by RuntimeDyld) into the already-allocated + // map. for (WorklistT::iterator I = Worklist.begin(), E = Worklist.end(); I != E;) { WorklistT::iterator Tmp = I; ++I; - AppliedMappingsT::iterator AI = AppliedMappings.find(Tmp->first); + auto LoadAddr = Checker.getSectionLoadAddress(Tmp->first); - if (AI != AppliedMappings.end()) { - AlreadyAllocated[AI->second] = Tmp->second; + if (LoadAddr && + *LoadAddr != static_cast<uint64_t>( + reinterpret_cast<uintptr_t>(Tmp->first))) { + AlreadyAllocated[*LoadAddr] = Tmp->second; Worklist.erase(Tmp); } } |