[PATCH] D67547: [llvm-readobj/llvm-objdump] - Improve how tool locate the dynamic table and report warnings about that.

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 02:27:29 PDT 2019


jhenderson added inline comments.


================
Comment at: tools/llvm-readobj/ELFDumper.cpp:1492
   // Ignore sh_entsize and use the expected value for entry size explicitly.
   // This allows us to dump the dynamic sections with a broken sh_entsize
   // field.
----------------
dump the dynamic sections -> dump dynamic sections


================
Comment at: tools/llvm-readobj/ELFDumper.cpp:1503-1504
 
-  // If we have a PT_DYNAMIC header, we will either check the found dynamic
-  // section or take the dynamic table data directly from the header.
-  if (!DynamicPhdr)
+  // When we only have an information from section header table or from the
+  // PT_DYNAMIC header, just use it.
+  if (!DynamicPhdr || !DynamicSec) {
----------------
When we only have information from one of the SHT_DYNAMIC section header or PT_DYNAMIC program header, just use that.


================
Comment at: tools/llvm-readobj/ELFDumper.cpp:1522-1523
     reportWarning(
-        createError(
-            "PT_DYNAMIC segment offset + size exceeds the size of the file"),
+        createError("SHT_DYNAMIC section header and PT_DYNAMIC disagree about "
+                    "the location of the dynamic table"),
         ObjF->getFileName());
----------------
I'd make this error message say "PT_DYNAMIC program header" for consistency, since we call the section header the "SHT_DYNAMIC section header".


================
Comment at: tools/llvm-readobj/ELFDumper.cpp:1532
 
-  StringRef Name =
-      unwrapOrError(ObjF->getFileName(), Obj->getSectionName(DynamicSec));
-  if (DynamicSec->sh_addr + DynamicSec->sh_size >
-          DynamicPhdr->p_vaddr + DynamicPhdr->p_memsz ||
-      DynamicSec->sh_addr < DynamicPhdr->p_vaddr)
-    reportWarning(createError("The SHT_DYNAMIC section '" + Name +
-                              "' is not contained within the "
-                              "PT_DYNAMIC segment"),
-                  ObjF->getFileName());
+  // Information in the PT_DYNAMIC header has priority over the information
+  // in a section header.
----------------
header -> program header


================
Comment at: tools/llvm-readobj/ELFDumper.cpp:1538
+          createError(
+              "SHT_DYNAMIC dynamic table is invalid, PT_DYNAMIC will be used"),
+          ObjF->getFileName());
----------------
"invalid," -> "invalid:"


================
Comment at: tools/llvm-readobj/ELFDumper.cpp:1541
+    DynamicTable = FromPhdr;
 
+  } else {
----------------
Delete this blank line


================
Comment at: tools/llvm-readobj/ELFDumper.cpp:1545
+        createError(
+            "PT_DYNAMIC dynamic table is invalid, SHT_DYNAMIC will be used"),
+        ObjF->getFileName());
----------------
"invalid," -> "invalid:"


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

https://reviews.llvm.org/D67547





More information about the llvm-commits mailing list