[PATCH] D68249: [llvm-objdump] Don't throw error for empty dynamic section

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 1 01:29:23 PDT 2019


grimar added inline comments.


================
Comment at: llvm/lib/Object/ELF.cpp:541
 
-  if (Dyn.empty())
-    // TODO: this error is untested.
-    return createError("invalid empty dynamic section");
-
-  if (DynSecSize % sizeof(Elf_Dyn) != 0)
-    // TODO: this error is untested.
-    return createError("malformed dynamic section");
-
-  if (Dyn.back().d_tag != ELF::DT_NULL)
-    // TODO: this error is untested.
-    return createError("dynamic sections must be DT_NULL terminated");
+  if (!Dyn.empty()) {
+    if (DynSecSize % sizeof(Elf_Dyn) != 0)
----------------
DT_NULL is a mandatory field according to the spec. I think it is invalid to remove `if (Dyn.empty())` check here.
lib/Object is a library that is used not only by `llvm-objdump`, but by many our tools.
For example, `dynamicEntries()` is also used by `llvm-elfabi` tool (though I am not familar with it, but anyways,
I guess it does not want to accept an invalid dynamic section).

Perhaps, you should add a flag like `bool AllowEmpty` or do a change on a `llvm-objdump` side instead.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68249





More information about the llvm-commits mailing list