[PATCH] D25025: [ELF] - Do not crash on invalid symbol index.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 4 02:11:36 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL283201: [ELF] - Do not crash on invalid symbol index. (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D25025?vs=73257&id=73432#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25025

Files:
  lld/trunk/ELF/InputFiles.h
  lld/trunk/test/ELF/invalid/Inputs/invalid-symbol-index.elf
  lld/trunk/test/ELF/invalid/invalid-symbol-index.s


Index: lld/trunk/test/ELF/invalid/invalid-symbol-index.s
===================================================================
--- lld/trunk/test/ELF/invalid/invalid-symbol-index.s
+++ lld/trunk/test/ELF/invalid/invalid-symbol-index.s
@@ -0,0 +1,10 @@
+## invalid-symbol-index.elf has incorrect type of .symtab section.
+## There is no symbol bodies because of that and any symbol index becomes incorrect.
+## Section Headers:
+##   [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
+##   [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
+## ...
+##   [ 4] .symtab           RELA            0000000000000000 000048 000030 18      1   2  8
+# RUN: not ld.lld %p/Inputs/invalid-symbol-index.elf -o %t2 2>&1 | \
+# RUN:   FileCheck --check-prefix=INVALID-SYMBOL-INDEX %s
+# INVALID-SYMBOL-INDEX: invalid symbol index
Index: lld/trunk/ELF/InputFiles.h
===================================================================
--- lld/trunk/ELF/InputFiles.h
+++ lld/trunk/ELF/InputFiles.h
@@ -151,6 +151,8 @@
   InputSectionBase<ELFT> *getSection(const Elf_Sym &Sym) const;
 
   SymbolBody &getSymbolBody(uint32_t SymbolIndex) const {
+    if (SymbolIndex >= SymbolBodies.size())
+      fatal(getFilename(this) + ": invalid symbol index");
     return *SymbolBodies[SymbolIndex];
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25025.73432.patch
Type: text/x-patch
Size: 1349 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161004/8ade5f7f/attachment.bin>


More information about the llvm-commits mailing list