[llvm] ce86a98 - [Object] Remove unneeded check in ELFFile<ELFT>::dynamicEntries().
Xing GUO via llvm-commits
llvm-commits at lists.llvm.org
Thu May 7 18:51:49 PDT 2020
Author: Xing GUO
Date: 2020-05-08T09:54:36+08:00
New Revision: ce86a986c39b2ad50ce495fe2d69c95d8a961c37
URL: https://github.com/llvm/llvm-project/commit/ce86a986c39b2ad50ce495fe2d69c95d8a961c37
DIFF: https://github.com/llvm/llvm-project/commit/ce86a986c39b2ad50ce495fe2d69c95d8a961c37.diff
LOG: [Object] Remove unneeded check in ELFFile<ELFT>::dynamicEntries().
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)`.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D79560
Added:
Modified:
llvm/lib/Object/ELF.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Object/ELF.cpp b/llvm/lib/Object/ELF.cpp
index e58d62382a55..c43ddda5bfb6 100644
--- a/llvm/lib/Object/ELF.cpp
+++ b/llvm/lib/Object/ELF.cpp
@@ -545,10 +545,6 @@ Expected<typename ELFT::DynRange> ELFFile<ELFT>::dynamicEntries() const {
// 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");
More information about the llvm-commits
mailing list