summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputFiles.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2016-10-07 09:01:04 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2016-10-07 09:01:04 +0000
commit53cf2a81128c4bbeb480d80cbcf409d7b207239d (patch)
treefaf54fa54cae1f52ccb4969df5a2f0eb194dba58 /lld/ELF/InputFiles.cpp
parentb7aec331255e7be93652dfad94e817fd8b7be0b8 (diff)
downloadbcm5719-llvm-53cf2a81128c4bbeb480d80cbcf409d7b207239d.tar.gz
bcm5719-llvm-53cf2a81128c4bbeb480d80cbcf409d7b207239d.zip
[ELF] - Do not crash on invalid size of dynamic section.
Previously if sh_size of dynamic section was broken, lld may crash. Or even may not crash if used 32 bits host. (then value may be truncated to 32 bits when doing pointer arithmetic and could be just zero). Patch fixes the issue. Differential revision: https://reviews.llvm.org/D25327 llvm-svn: 283533
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
-rw-r--r--lld/ELF/InputFiles.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 5b0ce109789..dda18aa8a4c 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -523,11 +523,11 @@ template <class ELFT> void SharedFile<ELFT>::parseSoName() {
if (!DynamicSec)
return;
- auto *Begin =
- reinterpret_cast<const Elf_Dyn *>(Obj.base() + DynamicSec->sh_offset);
- const Elf_Dyn *End = Begin + DynamicSec->sh_size / sizeof(Elf_Dyn);
- for (const Elf_Dyn &Dyn : make_range(Begin, End)) {
+ ArrayRef<Elf_Dyn> Arr =
+ check(Obj.template getSectionContentsAsArray<Elf_Dyn>(DynamicSec),
+ getFilename(this) + ": getSectionContentsAsArray failed");
+ for (const Elf_Dyn &Dyn : Arr) {
if (Dyn.d_tag == DT_SONAME) {
uintX_t Val = Dyn.getVal();
if (Val >= this->StringTable.size())
OpenPOWER on IntegriCloud