summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCObjectSymbolizer.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-04-03 23:54:35 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-04-03 23:54:35 +0000
commit7e91bc9e324c65b676d8926082edb8b409a6640f (patch)
treeef11f96d108e87d1b107489e1e075802422c8bb7 /llvm/lib/MC/MCObjectSymbolizer.cpp
parent128b8111d7b6e7bb002b1867cc7a2fbf6b7d0ebd (diff)
downloadbcm5719-llvm-7e91bc9e324c65b676d8926082edb8b409a6640f.tar.gz
bcm5719-llvm-7e91bc9e324c65b676d8926082edb8b409a6640f.zip
Implement getRelocationAddress for MachO and ET_REL elf files.
With that, fix the symbolizer to work with any ELF file. llvm-svn: 205588
Diffstat (limited to 'llvm/lib/MC/MCObjectSymbolizer.cpp')
-rw-r--r--llvm/lib/MC/MCObjectSymbolizer.cpp36
1 files changed, 4 insertions, 32 deletions
diff --git a/llvm/lib/MC/MCObjectSymbolizer.cpp b/llvm/lib/MC/MCObjectSymbolizer.cpp
index ba80d156532..52d66b8d406 100644
--- a/llvm/lib/MC/MCObjectSymbolizer.cpp
+++ b/llvm/lib/MC/MCObjectSymbolizer.cpp
@@ -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;
}
}
}
OpenPOWER on IntegriCloud