[PATCH] D79560: [Object] Remove unneeded check in ELFFile<ELFT>::dynamicEntries().

Xing GUO via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 7 02:48:08 PDT 2020


Higuoxing created this revision.
Higuoxing added reviewers: jhenderson, MaskRay.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Check for `DynSecSize % sizeof(Elf_Dyn) != 0` is unneeded in this context.

1. If the .dynamic section is acquired from program headers, the .dynamic

section is "cut off" by

  makeArrayRef(..., Phdr.p_filesz / sizeof(Elf_Dyn));
  DynSeSize = Phdr.p_filesz;



2. If the .dynamic section is acquired from section headers, the .dynamic

section is checked in `getSectionContentsAsArray<Elf_Dyn>(&Sec)`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79560

Files:
  llvm/lib/Object/ELF.cpp


Index: llvm/lib/Object/ELF.cpp
===================================================================
--- llvm/lib/Object/ELF.cpp
+++ llvm/lib/Object/ELF.cpp
@@ -545,10 +545,6 @@
     // 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");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79560.262576.patch
Type: text/x-patch
Size: 561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200507/4a97819d/attachment.bin>


More information about the llvm-commits mailing list