[PATCH] D76081: [Object] object::ELFObjectFile::dynamic_symbol_begin(): skip symbol index 0
Xing via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 15 22:51:43 PDT 2020
Higuoxing updated this revision to Diff 250478.
Higuoxing marked an inline comment as done.
Higuoxing added a comment.
Addressed comment.
- Ignore malformed .dynsym section.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76081/new/
https://reviews.llvm.org/D76081
Files:
llvm/include/llvm/Object/ELFObjectFile.h
Index: llvm/include/llvm/Object/ELFObjectFile.h
===================================================================
--- llvm/include/llvm/Object/ELFObjectFile.h
+++ llvm/include/llvm/Object/ELFObjectFile.h
@@ -1019,8 +1019,14 @@
template <class ELFT>
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
- DataRefImpl Sym = toDRI(DotDynSymSec, 0);
- return symbol_iterator(SymbolRef(Sym, this));
+ if (!DotDynSymSec || !DotDynSymSec->sh_size ||
+ DotDynSymSec->sh_size % sizeof(Elf_Sym) != 0) {
+ // We are ignoring malformed .dynsym section.
+ return symbol_iterator(SymbolRef(toDRI(DotDynSymSec, 0), this));
+ } else {
+ // Skip 0-index NULL symbol.
+ return symbol_iterator(SymbolRef(toDRI(DotDynSymSec, 1), this));
+ }
}
template <class ELFT>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76081.250478.patch
Type: text/x-patch
Size: 796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200316/e40c13cb/attachment.bin>
More information about the llvm-commits
mailing list