diff options
Diffstat (limited to 'lib/MC/MCObjectSymbolizer.cpp')
-rw-r--r-- | lib/MC/MCObjectSymbolizer.cpp | 42 |
1 files changed, 7 insertions, 35 deletions
diff --git a/lib/MC/MCObjectSymbolizer.cpp b/lib/MC/MCObjectSymbolizer.cpp index ba80d15..b149596 100644 --- a/lib/MC/MCObjectSymbolizer.cpp +++ b/lib/MC/MCObjectSymbolizer.cpp @@ -215,11 +215,11 @@ const SectionRef *MCObjectSymbolizer::findSectionContaining(uint64_t Addr) { It = std::lower_bound(SortedSections.begin(), EndIt, Addr, SectionStartsBefore); if (It == EndIt) - return 0; + return nullptr; uint64_t SAddr; It->getAddress(SAddr); uint64_t SSize; It->getSize(SSize); if (Addr >= SAddr + SSize) - return 0; + return nullptr; return &*It; } @@ -229,7 +229,7 @@ const RelocationRef *MCObjectSymbolizer::findRelocationAt(uint64_t Addr) { AddrToRelocMap::const_iterator RI = AddrToReloc.find(Addr); if (RI == AddrToReloc.end()) - return 0; + return nullptr; return &RI->second; } @@ -257,40 +257,12 @@ void MCObjectSymbolizer::buildSectionList() { void MCObjectSymbolizer::buildRelocationByAddrMap() { for (const SectionRef &Section : Obj->sections()) { - section_iterator RelSecI = Section.getRelocatedSection(); - if (RelSecI == Obj->section_end()) - continue; - - uint64_t StartAddr; RelSecI->getAddress(StartAddr); - uint64_t Size; RelSecI->getSize(Size); - bool RequiredForExec; - RelSecI->isRequiredForExecution(RequiredForExec); - if (RequiredForExec == false || Size == 0) - continue; for (const RelocationRef &Reloc : Section.relocations()) { - // FIXME: libObject is inconsistent regarding error handling. The - // overwhelming majority of methods always return object_error::success, - // and assert for simple errors.. Here, ELFObjectFile::getRelocationOffset - // asserts when the file type isn't ET_REL. - // This workaround handles x86-64 elf, the only one that has a relocinfo. - uint64_t Offset; - if (Obj->isELF()) { - const ELF64LEObjectFile *ELFObj = dyn_cast<ELF64LEObjectFile>(Obj); - if (ELFObj == 0) - break; - if (ELFObj->getELFFile()->getHeader()->e_type == ELF::ET_REL) { - Reloc.getOffset(Offset); - Offset += StartAddr; - } else { - Reloc.getAddress(Offset); - } - } else { - Reloc.getOffset(Offset); - Offset += StartAddr; - } + uint64_t Address; + Reloc.getAddress(Address); // At a specific address, only keep the first relocation. - if (AddrToReloc.find(Offset) == AddrToReloc.end()) - AddrToReloc[Offset] = Reloc; + if (AddrToReloc.find(Address) == AddrToReloc.end()) + AddrToReloc[Address] = Reloc; } } } |