summaryrefslogtreecommitdiff
path: root/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
commit7df905954106fe2302df36d96e4952b736817298 (patch)
tree12b8012501c0a94fadad86472c55c5f4eafdc4ac /lib/MC/MCObjectSymbolizer.cpp
parent5ca1f954193c8cfe9efa53c888746abbb8edbbbc (diff)
downloadllvm-7df905954106fe2302df36d96e4952b736817298.tar.gz
llvm-7df905954106fe2302df36d96e4952b736817298.tar.bz2
llvm-7df905954106fe2302df36d96e4952b736817298.tar.xz
Implement getRelocationAddress for MachO and ET_REL elf files.
With that, fix the symbolizer to work with any ELF file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205588 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCObjectSymbolizer.cpp')
-rw-r--r--lib/MC/MCObjectSymbolizer.cpp36
1 files changed, 4 insertions, 32 deletions
diff --git a/lib/MC/MCObjectSymbolizer.cpp b/lib/MC/MCObjectSymbolizer.cpp
index ba80d15653..52d66b8d40 100644
--- a/lib/MC/MCObjectSymbolizer.cpp
+++ b/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;
}
}
}