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
This commit is contained in:
Rafael Espindola
2014-04-03 23:54:35 +00:00
parent 5ca1f95419
commit 7df9059541
6 changed files with 44 additions and 37 deletions

View File

@ -555,10 +555,17 @@ ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
template <class ELFT>
error_code ELFObjectFile<ELFT>::getRelocationAddress(DataRefImpl Rel,
uint64_t &Result) const {
assert((EF.getHeader()->e_type == ELF::ET_EXEC ||
EF.getHeader()->e_type == ELF::ET_DYN) &&
"Only executable and shared objects files have relocation addresses");
Result = getROffset(Rel);
uint64_t ROffset = getROffset(Rel);
const Elf_Ehdr *Header = EF.getHeader();
if (Header->e_type == ELF::ET_REL) {
const Elf_Shdr *RelocationSec = getRelSection(Rel);
const Elf_Shdr *RelocatedSec = EF.getSection(RelocationSec->sh_info);
Result = ROffset + RelocatedSec->sh_addr;
} else {
Result = ROffset;
}
return object_error::success;
}