diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-08-13 18:31:43 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-08-13 18:31:43 +0000 |
commit | d7fafa0ffce2bca2f9214ad6cd2501c87de812d5 (patch) | |
tree | f3acebae5c06e095382b8a419f2560f29473f742 /llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp | |
parent | be9b6c75c3e654e1021f6534c9dd46e8197c00ed (diff) | |
download | bcm5719-llvm-d7fafa0ffce2bca2f9214ad6cd2501c87de812d5.tar.gz bcm5719-llvm-d7fafa0ffce2bca2f9214ad6cd2501c87de812d5.zip |
[llvm-cxxdump] Correctly process relocations when given multiple files
Archive files wouldn't lead to us reprocessing the section relocations
for the new object files.
llvm-svn: 244932
Diffstat (limited to 'llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp')
-rw-r--r-- | llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp index b2a653700b4..ede13f7aca5 100644 --- a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp +++ b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp @@ -64,20 +64,7 @@ static void reportError(StringRef Input, std::error_code EC) { reportError(Input, EC.message()); } -static SmallVectorImpl<SectionRef> &getRelocSections(const ObjectFile *Obj, - const SectionRef &Sec) { - static bool MappingDone = false; - static std::map<SectionRef, SmallVector<SectionRef, 1>> SectionRelocMap; - if (!MappingDone) { - for (const SectionRef &Section : Obj->sections()) { - section_iterator Sec2 = Section.getRelocatedSection(); - if (Sec2 != Obj->section_end()) - SectionRelocMap[*Sec2].push_back(Section); - } - MappingDone = true; - } - return SectionRelocMap[Sec]; -} +static std::map<SectionRef, SmallVector<SectionRef, 1>> SectionRelocMap; static void collectRelocatedSymbols(const ObjectFile *Obj, const SectionRef &Sec, uint64_t SecAddress, @@ -85,7 +72,7 @@ static void collectRelocatedSymbols(const ObjectFile *Obj, StringRef *I, StringRef *E) { uint64_t SymOffset = SymAddress - SecAddress; uint64_t SymEnd = SymOffset + SymSize; - for (const SectionRef &SR : getRelocSections(Obj, Sec)) { + for (const SectionRef &SR : SectionRelocMap[Sec]) { for (const object::RelocationRef &Reloc : SR.relocations()) { if (I == E) break; @@ -109,7 +96,7 @@ static void collectRelocationOffsets( std::map<std::pair<StringRef, uint64_t>, StringRef> &Collection) { uint64_t SymOffset = SymAddress - SecAddress; uint64_t SymEnd = SymOffset + SymSize; - for (const SectionRef &SR : getRelocSections(Obj, Sec)) { + for (const SectionRef &SR : SectionRelocMap[Sec]) { for (const object::RelocationRef &Reloc : SR.relocations()) { const object::symbol_iterator RelocSymI = Reloc.getSymbol(); if (RelocSymI == Obj->symbol_end()) @@ -173,6 +160,13 @@ static void dumpCXXData(const ObjectFile *Obj) { std::map<std::pair<StringRef, uint64_t>, StringRef> VTTEntries; std::map<StringRef, StringRef> TINames; + SectionRelocMap.clear(); + for (const SectionRef &Section : Obj->sections()) { + section_iterator Sec2 = Section.getRelocatedSection(); + if (Sec2 != Obj->section_end()) + SectionRelocMap[*Sec2].push_back(Section); + } + uint8_t BytesInAddress = Obj->getBytesInAddress(); std::vector<std::pair<SymbolRef, uint64_t>> SymAddr = |