<div dir="ltr"><div dir="ltr">Hello Xing,<br><br>It made another test fail now:<br><a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/45688">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/45688</a><br>. . .<br>Failing Tests (1):<br> LLVM :: tools/llvm-readobj/elf-versioninfo.test<br><br>Please have a look?<br><br>Thanks<br><br>Galina<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 22, 2019 at 9:19 AM Xing GUO via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: higuoxing<br>
Date: Fri Mar 22 09:20:54 2019<br>
New Revision: 356777<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=356777&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=356777&view=rev</a><br>
Log:<br>
[llvm-readobj] Revert bad changes<br>
<br>
Modified:<br>
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp<br>
<br>
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=356777&r1=356776&r2=356777&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=356777&r1=356776&r2=356777&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)<br>
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Fri Mar 22 09:20:54 2019<br>
@@ -342,12 +342,6 @@ public:<br>
virtual void printProgramHeaders(const ELFFile<ELFT> *Obj,<br>
bool PrintProgramHeaders,<br>
cl::boolOrDefault PrintSectionMapping) = 0;<br>
- virtual void printVersionSymbolSection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) = 0;<br>
- virtual void printVersionDefinitionSection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) = 0;<br>
- virtual void printVersionDependencySection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) = 0;<br>
virtual void printHashHistogram(const ELFFile<ELFT> *Obj) = 0;<br>
virtual void printCGProfile(const ELFFile<ELFT> *Obj) = 0;<br>
virtual void printAddrsig(const ELFFile<ELFT> *Obj) = 0;<br>
@@ -382,12 +376,6 @@ public:<br>
size_t Offset) override;<br>
void printProgramHeaders(const ELFO *Obj, bool PrintProgramHeaders,<br>
cl::boolOrDefault PrintSectionMapping) override;<br>
- void printVersionSymbolSection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) override;<br>
- void printVersionDefinitionSection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) override;<br>
- void printVersionDependencySection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) override;<br>
void printHashHistogram(const ELFFile<ELFT> *Obj) override;<br>
void printCGProfile(const ELFFile<ELFT> *Obj) override;<br>
void printAddrsig(const ELFFile<ELFT> *Obj) override;<br>
@@ -482,12 +470,6 @@ public:<br>
void printDynamicRelocations(const ELFO *Obj) override;<br>
void printProgramHeaders(const ELFO *Obj, bool PrintProgramHeaders,<br>
cl::boolOrDefault PrintSectionMapping) override;<br>
- void printVersionSymbolSection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) override;<br>
- void printVersionDefinitionSection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) override;<br>
- void printVersionDependencySection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) override;<br>
void printHashHistogram(const ELFFile<ELFT> *Obj) override;<br>
void printCGProfile(const ELFFile<ELFT> *Obj) override;<br>
void printAddrsig(const ELFFile<ELFT> *Obj) override;<br>
@@ -653,18 +635,113 @@ static void printVersionSymbolSection(EL<br>
}<br>
}<br>
<br>
+static const EnumEntry<unsigned> SymVersionFlags[] = {<br>
+ {"Base", "BASE", VER_FLG_BASE},<br>
+ {"Weak", "WEAK", VER_FLG_WEAK},<br>
+ {"Info", "INFO", VER_FLG_INFO}};<br>
+<br>
+template <typename ELFO, class ELFT><br>
+static void printVersionDefinitionSection(ELFDumper<ELFT> *Dumper,<br>
+ const ELFO *Obj,<br>
+ const typename ELFO::Elf_Shdr *Sec,<br>
+ ScopedPrinter &W) {<br>
+ using VerDef = typename ELFO::Elf_Verdef;<br>
+ using VerdAux = typename ELFO::Elf_Verdaux;<br>
+<br>
+ DictScope SD(W, "SHT_GNU_verdef");<br>
+ if (!Sec)<br>
+ return;<br>
+<br>
+ const uint8_t *SecStartAddress =<br>
+ (const uint8_t *)Obj->base() + Sec->sh_offset;<br>
+ const uint8_t *SecEndAddress = SecStartAddress + Sec->sh_size;<br>
+ const uint8_t *P = SecStartAddress;<br>
+ const typename ELFO::Elf_Shdr *StrTab =<br>
+ unwrapOrError(Obj->getSection(Sec->sh_link));<br>
+<br>
+ unsigned VerDefsNum = Sec->sh_info;<br>
+ while (VerDefsNum--) {<br>
+ if (P + sizeof(VerDef) > SecEndAddress)<br>
+ report_fatal_error("invalid offset in the section");<br>
+<br>
+ auto *VD = reinterpret_cast<const VerDef *>(P);<br>
+ DictScope Def(W, "Definition");<br>
+ W.printNumber("Version", VD->vd_version);<br>
+ W.printEnum("Flags", VD->vd_flags, makeArrayRef(SymVersionFlags));<br>
+ W.printNumber("Index", VD->vd_ndx);<br>
+ W.printNumber("Hash", VD->vd_hash);<br>
+ W.printString("Name",<br>
+ StringRef((const char *)(Obj->base() + StrTab->sh_offset +<br>
+ VD->getAux()->vda_name)));<br>
+ if (!VD->vd_cnt)<br>
+ report_fatal_error("at least one definition string must exist");<br>
+ if (VD->vd_cnt > 2)<br>
+ report_fatal_error("more than one predecessor is not expected");<br>
+<br>
+ if (VD->vd_cnt == 2) {<br>
+ const uint8_t *PAux = P + VD->vd_aux + VD->getAux()->vda_next;<br>
+ const VerdAux *Aux = reinterpret_cast<const VerdAux *>(PAux);<br>
+ W.printString("Predecessor",<br>
+ StringRef((const char *)(Obj->base() + StrTab->sh_offset +<br>
+ Aux->vda_name)));<br>
+ }<br>
+<br>
+ P += VD->vd_next;<br>
+ }<br>
+}<br>
+<br>
+template <typename ELFO, class ELFT><br>
+static void printVersionDependencySection(ELFDumper<ELFT> *Dumper,<br>
+ const ELFO *Obj,<br>
+ const typename ELFO::Elf_Shdr *Sec,<br>
+ ScopedPrinter &W) {<br>
+ using VerNeed = typename ELFO::Elf_Verneed;<br>
+ using VernAux = typename ELFO::Elf_Vernaux;<br>
+<br>
+ DictScope SD(W, "SHT_GNU_verneed");<br>
+ if (!Sec)<br>
+ return;<br>
+<br>
+ const uint8_t *SecData = (const uint8_t *)Obj->base() + Sec->sh_offset;<br>
+ const typename ELFO::Elf_Shdr *StrTab =<br>
+ unwrapOrError(Obj->getSection(Sec->sh_link));<br>
+<br>
+ const uint8_t *P = SecData;<br>
+ unsigned VerNeedNum = Sec->sh_info;<br>
+ for (unsigned I = 0; I < VerNeedNum; ++I) {<br>
+ const VerNeed *Need = reinterpret_cast<const VerNeed *>(P);<br>
+ DictScope Entry(W, "Dependency");<br>
+ W.printNumber("Version", Need->vn_version);<br>
+ W.printNumber("Count", Need->vn_cnt);<br>
+ W.printString("FileName",<br>
+ StringRef((const char *)(Obj->base() + StrTab->sh_offset +<br>
+ Need->vn_file)));<br>
+<br>
+ const uint8_t *PAux = P + Need->vn_aux;<br>
+ for (unsigned J = 0; J < Need->vn_cnt; ++J) {<br>
+ const VernAux *Aux = reinterpret_cast<const VernAux *>(PAux);<br>
+ DictScope Entry(W, "Entry");<br>
+ W.printNumber("Hash", Aux->vna_hash);<br>
+ W.printEnum("Flags", Aux->vna_flags, makeArrayRef(SymVersionFlags));<br>
+ W.printNumber("Index", Aux->vna_other);<br>
+ W.printString("Name",<br>
+ StringRef((const char *)(Obj->base() + StrTab->sh_offset +<br>
+ Aux->vna_name)));<br>
+ PAux += Aux->vna_next;<br>
+ }<br>
+ P += Need->vn_next;<br>
+ }<br>
+}<br>
+<br>
template <typename ELFT> void ELFDumper<ELFT>::printVersionInfo() {<br>
// Dump version symbol section.<br>
- ELFDumperStyle->printVersionSymbolSection(ObjF->getELFFile(),<br>
- dot_gnu_version_sec);<br>
+ printVersionSymbolSection(this, ObjF->getELFFile(), dot_gnu_version_sec, W);<br>
<br>
// Dump version definition section.<br>
- ELFDumperStyle->printVersionDefinitionSection(ObjF->getELFFile(),<br>
- dot_gnu_version_d_sec);<br>
+ printVersionDefinitionSection(this, ObjF->getELFFile(), dot_gnu_version_d_sec, W);<br>
<br>
// Dump version dependency section.<br>
- ELFDumperStyle->printVersionDependencySection(ObjF->getELFFile(),<br>
- dot_gnu_version_r_sec);<br>
+ printVersionDependencySection(this, ObjF->getELFFile(), dot_gnu_version_r_sec, W);<br>
}<br>
<br>
template <typename ELFT><br>
@@ -848,11 +925,6 @@ static const EnumEntry<unsigned> ElfOSAB<br>
{"Standalone", "Standalone App", ELF::ELFOSABI_STANDALONE}<br>
};<br>
<br>
-static const EnumEntry<unsigned> SymVersionFlags[] = {<br>
- {"Base", "BASE", VER_FLG_BASE},<br>
- {"Weak", "WEAK", VER_FLG_WEAK},<br>
- {"Info", "INFO", VER_FLG_INFO}};<br>
-<br>
static const EnumEntry<unsigned> AMDGPUElfOSABI[] = {<br>
{"AMDGPU_HSA", "AMDGPU - HSA", ELF::ELFOSABI_AMDGPU_HSA},<br>
{"AMDGPU_PAL", "AMDGPU - PAL", ELF::ELFOSABI_AMDGPU_PAL},<br>
@@ -3388,36 +3460,6 @@ void GNUStyle<ELFT>::printDynamicRelocat<br>
}<br>
}<br>
<br>
-template <class ELFT><br>
-void GNUStyle<ELFT>::printVersionSymbolSection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) {<br>
- if (!Sec)<br>
- return;<br>
-<br>
- StringRef SecName = unwrapOrError(Obj->getSectionName(Sec));<br>
- OS << "Dumper for " << SecName << " is not implemented\n";<br>
-}<br>
-<br>
-template <class ELFT><br>
-void GNUStyle<ELFT>::printVersionDefinitionSection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) {<br>
- if (!Sec)<br>
- return;<br>
-<br>
- StringRef SecName = unwrapOrError(Obj->getSectionName(Sec));<br>
- OS << "Dumper for " << SecName << " is not implemented\n";<br>
-}<br>
-<br>
-template <class ELFT><br>
-void GNUStyle<ELFT>::printVersionDependencySection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) {<br>
- if (!Sec)<br>
- return;<br>
-<br>
- StringRef SecName = unwrapOrError(Obj->getSectionName(Sec));<br>
- OS << "Dumper for " << SecName << " is not implemented\n";<br>
-}<br>
-<br>
// Hash histogram shows statistics of how efficient the hash was for the<br>
// dynamic symbol table. The table shows number of hash buckets for different<br>
// lengths of chains as absolute number and percentage of the total buckets.<br>
@@ -4496,122 +4538,6 @@ void LLVMStyle<ELFT>::printProgramHeader<br>
}<br>
}<br>
<br>
-template <class ELFT><br>
-void LLVMStyle<ELFT>::printVersionSymbolSection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) {<br>
- DictScope SS(W, "Version symbols");<br>
- if (!Sec)<br>
- return;<br>
-<br>
- StringRef SecName = unwrapOrError(Obj->getSectionName(Sec));<br>
- W.printNumber("Section Name", SecName, Sec->sh_name);<br>
- W.printHex("Address", Sec->sh_addr);<br>
- W.printHex("Offset", Sec->sh_offset);<br>
- W.printNumber("Link", Sec->sh_link);<br>
-<br>
- const uint8_t *VersymBuf = (const uint8_t *)Obj->base() + Sec->sh_offset;<br>
- const ELFDumper<ELFT> *Dumper = this->dumper();<br>
- StringRef StrTable = Dumper->getDynamicStringTable();<br>
-<br>
- // Same number of entries in the dynamic symbol table (DT_SYMTAB).<br>
- ListScope Syms(W, "Symbols");<br>
- for (const Elf_Sym &Sym : Dumper->dynamic_symbols()) {<br>
- DictScope S(W, "Symbol");<br>
- const Elf_Versym *Versym = reinterpret_cast<const Elf_Versym *>(VersymBuf);<br>
- std::string FullSymbolName =<br>
- Dumper->getFullSymbolName(&Sym, StrTable, true /* IsDynamic */);<br>
- W.printNumber("Version", Versym->vs_index);<br>
- W.printString("Name", FullSymbolName);<br>
- VersymBuf += sizeof(Elf_Versym);<br>
- }<br>
-}<br>
-<br>
-template <class ELFT><br>
-void LLVMStyle<ELFT>::printVersionDefinitionSection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) {<br>
- DictScope SD(W, "SHT_GNU_verdef");<br>
- if (!Sec)<br>
- return;<br>
-<br>
- const uint8_t *SecStartAddress =<br>
- (const uint8_t *)Obj->base() + Sec->sh_offset;<br>
- const uint8_t *SecEndAddress = SecStartAddress + Sec->sh_size;<br>
- const uint8_t *VerdefBuf = SecStartAddress;<br>
- const Elf_Shdr *StrTab = unwrapOrError(Obj->getSection(Sec->sh_link));<br>
-<br>
- unsigned VerDefsNum = Sec->sh_info;<br>
- while (VerDefsNum--) {<br>
- if (VerdefBuf + sizeof(Elf_Verdef) > SecEndAddress)<br>
- // FIXME: report_fatal_error is not a good way to report error. We should<br>
- // emit a parsing error here and below.<br>
- report_fatal_error("invalid offset in the section");<br>
-<br>
- const Elf_Verdef *Verdef = reinterpret_cast<const Elf_Verdef *>(VerdefBuf);<br>
- DictScope Def(W, "Definition");<br>
- W.printNumber("Version", Verdef->vd_version);<br>
- W.printEnum("Flags", Verdef->vd_flags, makeArrayRef(SymVersionFlags));<br>
- W.printNumber("Index", Verdef->vd_ndx);<br>
- W.printNumber("Hash", Verdef->vd_hash);<br>
- W.printString("Name",<br>
- StringRef((const char *)(Obj->base() + StrTab->sh_offset +<br>
- Verdef->getAux()->vda_name)));<br>
- if (!Verdef->vd_cnt)<br>
- report_fatal_error("at least one definition string must exist");<br>
- if (Verdef->vd_cnt > 2)<br>
- report_fatal_error("more than one predecessor is not expected");<br>
-<br>
- if (Verdef->vd_cnt == 2) {<br>
- const uint8_t *VerdauxBuf =<br>
- VerdefBuf + Verdef->vd_aux + Verdef->getAux()->vda_next;<br>
- const Elf_Verdaux *Verdaux =<br>
- reinterpret_cast<const Elf_Verdaux *>(VerdauxBuf);<br>
- W.printString("Predecessor",<br>
- StringRef((const char *)(Obj->base() + StrTab->sh_offset +<br>
- Verdaux->vda_name)));<br>
- }<br>
- VerdefBuf += Verdef->vd_next;<br>
- }<br>
-}<br>
-<br>
-template <class ELFT><br>
-void LLVMStyle<ELFT>::printVersionDependencySection(const ELFFile<ELFT> *Obj,<br>
- const Elf_Shdr *Sec) {<br>
- DictScope SD(W, "SHT_GNU_verneed");<br>
- if (!Sec)<br>
- return;<br>
-<br>
- const uint8_t *SecData = (const uint8_t *)Obj->base() + Sec->sh_offset;<br>
- const Elf_Shdr *StrTab = unwrapOrError(Obj->getSection(Sec->sh_link));<br>
-<br>
- const uint8_t *VerneedBuf = SecData;<br>
- unsigned VerneedNum = Sec->sh_info;<br>
- for (unsigned I = 0; I < VerneedNum; ++I) {<br>
- const Elf_Verneed *Verneed =<br>
- reinterpret_cast<const Elf_Verneed *>(VerneedBuf);<br>
- DictScope Entry(W, "Dependency");<br>
- W.printNumber("Version", Verneed->vn_version);<br>
- W.printNumber("Count", Verneed->vn_cnt);<br>
- W.printString("FileName",<br>
- StringRef((const char *)(Obj->base() + StrTab->sh_offset +<br>
- Verneed->vn_file)));<br>
-<br>
- const uint8_t *VernauxBuf = VerneedBuf + Verneed->vn_aux;<br>
- for (unsigned J = 0; J < Verneed->vn_cnt; ++J) {<br>
- const Elf_Vernaux *Vernaux =<br>
- reinterpret_cast<const Elf_Vernaux *>(VernauxBuf);<br>
- DictScope Entry(W, "Entry");<br>
- W.printNumber("Hash", Vernaux->vna_hash);<br>
- W.printEnum("Flags", Vernaux->vna_flags, makeArrayRef(SymVersionFlags));<br>
- W.printNumber("Index", Vernaux->vna_other);<br>
- W.printString("Name",<br>
- StringRef((const char *)(Obj->base() + StrTab->sh_offset +<br>
- Vernaux->vna_name)));<br>
- VernauxBuf += Vernaux->vna_next;<br>
- }<br>
- VerneedBuf += Verneed->vn_next;<br>
- }<br>
-}<br>
-<br>
template <class ELFT><br>
void LLVMStyle<ELFT>::printHashHistogram(const ELFFile<ELFT> *Obj) {<br>
W.startLine() << "Hash Histogram not implemented!\n";<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>