Skip to content

Commit

Permalink
[Object] Remove unneeded check in ELFFile<ELFT>::dynamicEntries().
Browse files Browse the repository at this point in the history
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
  • Loading branch information
higuoxing committed May 8, 2020
1 parent e8147ad commit ce86a98
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions llvm/lib/Object/ELF.cpp
Expand Up @@ -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");
Expand Down

0 comments on commit ce86a98

Please sign in to comment.