diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2018-06-07 00:02:07 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2018-06-07 00:02:07 +0000 |
commit | cf017ada68d96a4960df5ee80d756e5d27ff10a3 (patch) | |
tree | ccc560e28bf287a1655ded96f4daf3bf62b3c298 /llvm/tools/llvm-readobj | |
parent | 4d9fd7a266048fa0c0de8e694f6e768498884522 (diff) | |
download | bcm5719-llvm-cf017ada68d96a4960df5ee80d756e5d27ff10a3.tar.gz bcm5719-llvm-cf017ada68d96a4960df5ee80d756e5d27ff10a3.zip |
llvm-readobj: fix printing number of relocations in Android packed format.
With '-elf-output-style=GNU -relocations', a header containing the number
of entries is printed before all the relocation entries in the section.
For Android packed format, we need to perform the unpacking first before
we can get the actual number of relocations in the section.
Patch by Rahul Chaudhry!
Differential Revision: https://reviews.llvm.org/D47800
llvm-svn: 334147
Diffstat (limited to 'llvm/tools/llvm-readobj')
-rw-r--r-- | llvm/tools/llvm-readobj/ELFDumper.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index b6fed4f3c34..2492fa2acc2 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -2641,6 +2641,14 @@ template <class ELFT> void GNUStyle<ELFT>::printRelocations(const ELFO *Obj) { HasRelocSections = true; StringRef Name = unwrapOrError(Obj->getSectionName(&Sec)); unsigned Entries = Sec.getEntityCount(); + std::vector<Elf_Rela> AndroidRelas; + if (Sec.sh_type == ELF::SHT_ANDROID_REL || + Sec.sh_type == ELF::SHT_ANDROID_RELA) { + // Android's packed relocation section needs to be unpacked first + // to get the actual number of entries. + AndroidRelas = unwrapOrError(Obj->android_relas(&Sec)); + Entries = AndroidRelas.size(); + } uintX_t Offset = Sec.sh_offset; OS << "\nRelocation section '" << Name << "' at offset 0x" << to_hexString(Offset, false) << " contains " << Entries @@ -2665,7 +2673,7 @@ template <class ELFT> void GNUStyle<ELFT>::printRelocations(const ELFO *Obj) { break; case ELF::SHT_ANDROID_REL: case ELF::SHT_ANDROID_RELA: - for (const auto &R : unwrapOrError(Obj->android_relas(&Sec))) + for (const auto &R : AndroidRelas) printRelocation(Obj, SymTab, R, Sec.sh_type == ELF::SHT_ANDROID_RELA); break; } |