[PATCH] D89379: [llvm-readobj/libObject] - Allow dumping objects that has a broken SHT_SYMTAB_SHNDX section.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 19 21:13:05 PDT 2020


MaskRay added a comment.

> Currently it is impossible to create an instance of ELFObjectFile when the SHT_SYMTAB_SHNDX can't be read.

.. it errors ... when failed to parse SHT_SYMTAB_SHNDX

> It happens because ELFObjectFile tries to read its entries too early, in the constructor.

`ELFObjectFile::create`  is not a constructor. It is a factory function.



================
Comment at: llvm/include/llvm/Object/ELFObjectFile.h:699
+  if (DotSymtabShndxSec) {
+    // TODO: Test this error.
+    Expected<ArrayRef<Elf_Word>> ShndxTableOrErr =
----------------
Is it because yaml2obj cannot emit a malformed SHT_SYMTAB_SHNDX?


================
Comment at: llvm/unittests/Object/ELFObjectFileTest.cpp:303
+static Expected<ELFObjectFile<ELFT>> toBinary(SmallVectorImpl<char> &Storage,
+                                            StringRef Yaml) {
+  raw_svector_ostream OS(Storage);
----------------
Seems misaligned


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

https://reviews.llvm.org/D89379



More information about the llvm-commits mailing list