[PATCH] D54697: [llvm-objdump] Add `Version References` dumper

Xing via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 23 21:58:51 PST 2019


Higuoxing added a reviewer: grimar.
Higuoxing marked an inline comment as done.
Higuoxing added inline comments.


================
Comment at: tools/llvm-objdump/ELFDump.cpp:288
+    }
+  }
+
----------------
grimar wrote:
> If you move this loop to `printSymbolVersionInfo` and change the `printSymbolVersionDependency` signature
> to `printSymbolVersionDependency(const typename ELFT::Shdr &Shdr, ArrayRef<uint8_t> Contents)`
> that probably will be better, because for `printSymbolVersionDefinition` implementation you would also
> need to iterate over all sections and take the content. That can be done in a single place.
> 
> 
> I mean the code in `printSymbolVersionInfo` can be like:
> 
> ```
> template <class ELFT>
> static void printSymbolVersionInfo(const ELFFile<ELFT> *Elf) {
>   typedef typename ELFT::Shdr Elf_Shdr;
> 
>   auto SecOrErr = Elf->sections();
>   if (!SecOrErr)
>     report_fatal_error(errorToErrorCode(SecOrErr.takeError()).message());
> 
>   for (const Elf_Shdr &Shdr : *SecOrErr) {
>     if (Shdr.sh_type != ELF::SHT_GNU_verdef &&
>         Shdr.sh_type != ELF::SHT_GNU_verneed)
>       continue;
> 
>     auto ContentsOrErr = Elf->getSectionContents(&Shdr);
>     if (!ContentsOrErr)
>       report_fatal_error(errorToErrorCode(ContentsOrErr.takeError()).message());
> 
>     if (Shdr.sh_type == ELF::SHT_GNU_verdef)
>       printSymbolVersionDefinition<ELFT>(Shdr, *ContentsOrErr);
>     else if (Shdr.sh_type == ELF::SHT_GNU_verneed)
>       printSymbolVersionDependency<ELFT>(Shdr, *ContentsOrErr);
>   }
> }
> ```
> 
> 
Oh, thank you @grimar , I am wandering that whether the dumping order of verneed and verdef sections is important? Sometimes, the verneed section is before verdef and sometimes verneed is after verdef. 


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54697/new/

https://reviews.llvm.org/D54697





More information about the llvm-commits mailing list