summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2019-05-30 10:36:52 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2019-05-30 10:36:52 +0000
commitc372f41c18aadbad09e72800304b301d4c475571 (patch)
treecdd4e39948b78827c407f1797b4afc4a5d2dec11 /llvm/tools
parent32aac1727a2ab3031ad0878330059f94cca7b5dc (diff)
downloadbcm5719-llvm-c372f41c18aadbad09e72800304b301d4c475571.tar.gz
bcm5719-llvm-c372f41c18aadbad09e72800304b301d4c475571.zip
[llvm-readobj/llvm-readelf] - Implement GNU style dumper of the SHT_GNU_verdef section.
It was not implemented yet, we had only LLVM style dumper implemented. Section description is here: https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/symversion.html Differential revision: https://reviews.llvm.org/D62520 llvm-svn: 362082
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-readobj/ELFDumper.cpp57
1 files changed, 44 insertions, 13 deletions
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index fdef4b79ebf..1aea4935da6 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -3491,18 +3491,7 @@ void GNUStyle<ELFT>::printVersionSymbolSection(const ELFFile<ELFT> *Obj,
OS << '\n';
}
-template <class ELFT>
-void GNUStyle<ELFT>::printVersionDefinitionSection(const ELFFile<ELFT> *Obj,
- const Elf_Shdr *Sec) {
- if (!Sec)
- return;
-
- StringRef SecName = unwrapOrError(Obj->getSectionName(Sec));
- OS << "Dumper for " << SecName << " is not implemented\n";
- OS << '\n';
-}
-
-static std::string verNeedFlagToString(unsigned Flags) {
+static std::string versionFlagToString(unsigned Flags) {
if (Flags == 0)
return "none";
@@ -3524,6 +3513,48 @@ static std::string verNeedFlagToString(unsigned Flags) {
}
template <class ELFT>
+void GNUStyle<ELFT>::printVersionDefinitionSection(const ELFFile<ELFT> *Obj,
+ const Elf_Shdr *Sec) {
+ if (!Sec)
+ return;
+
+ unsigned VerDefsNum = Sec->sh_info;
+ printGNUVersionSectionProlog(OS, "Version definition", VerDefsNum, Obj, Sec);
+
+ const Elf_Shdr *StrTabSec = unwrapOrError(Obj->getSection(Sec->sh_link));
+ StringRef StringTable(
+ reinterpret_cast<const char *>(Obj->base() + StrTabSec->sh_offset),
+ StrTabSec->sh_size);
+
+ const uint8_t *VerdefBuf = unwrapOrError(Obj->getSectionContents(Sec)).data();
+ const uint8_t *Begin = VerdefBuf;
+
+ while (VerDefsNum--) {
+ const Elf_Verdef *Verdef = reinterpret_cast<const Elf_Verdef *>(VerdefBuf);
+ OS << format(" 0x%04x: Rev: %u Flags: %s Index: %u Cnt: %u",
+ VerdefBuf - Begin, (unsigned)Verdef->vd_version,
+ versionFlagToString(Verdef->vd_flags).c_str(),
+ (unsigned)Verdef->vd_ndx, (unsigned)Verdef->vd_cnt);
+
+ const uint8_t *VerdauxBuf = VerdefBuf + Verdef->vd_aux;
+ const Elf_Verdaux *Verdaux =
+ reinterpret_cast<const Elf_Verdaux *>(VerdauxBuf);
+ OS << format(" Name: %s\n",
+ StringTable.drop_front(Verdaux->vda_name).data());
+
+ for (unsigned I = 1; I < Verdef->vd_cnt; ++I) {
+ VerdauxBuf += Verdaux->vda_next;
+ Verdaux = reinterpret_cast<const Elf_Verdaux *>(VerdauxBuf);
+ OS << format(" 0x%04x: Parent %u: %s\n", VerdauxBuf - Begin, I,
+ StringTable.drop_front(Verdaux->vda_name).data());
+ }
+
+ VerdefBuf += Verdef->vd_next;
+ }
+ OS << '\n';
+}
+
+template <class ELFT>
void GNUStyle<ELFT>::printVersionDependencySection(const ELFFile<ELFT> *Obj,
const Elf_Shdr *Sec) {
if (!Sec)
@@ -3558,7 +3589,7 @@ void GNUStyle<ELFT>::printVersionDependencySection(const ELFFile<ELFT> *Obj,
OS << format(" 0x%04x: Name: %s Flags: %s Version: %u\n",
reinterpret_cast<const uint8_t *>(Vernaux) - SecData.begin(),
StringTable.drop_front(Vernaux->vna_name).data(),
- verNeedFlagToString(Vernaux->vna_flags).c_str(),
+ versionFlagToString(Vernaux->vna_flags).c_str(),
(unsigned)Vernaux->vna_other);
VernauxBuf += Vernaux->vna_next;
}
OpenPOWER on IntegriCloud