[PATCH] D25237: [ELF] - Do not crash on MIPS if there is no object files in input.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 4 07:28:49 PDT 2016


grimar created this revision.
grimar added reviewers: atanasyan, ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777.
Herald added a subscriber: sdardis.

If we have input without object files, for example if we have only .so
code will crash in
checkFlags(), getPicFlags(), getArchFlags() functions.

Patch fixes the issue.


https://reviews.llvm.org/D25237

Files:
  ELF/Mips.cpp
  test/ELF/mips-no-objects.s


Index: test/ELF/mips-no-objects.s
===================================================================
--- test/ELF/mips-no-objects.s
+++ test/ELF/mips-no-objects.s
@@ -0,0 +1,5 @@
+# REQUIRES: mips
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o -shared -o %t.so
+# RUN: ld.lld %t.so -shared -o %t2.so
+# RUN: llvm-readobj %t2.so > /dev/null 2>&1
Index: ELF/Mips.cpp
===================================================================
--- ELF/Mips.cpp
+++ ELF/Mips.cpp
@@ -285,6 +285,8 @@
   std::vector<FileFlags> V;
   for (elf::ObjectFile<ELFT> *F : Symtab<ELFT>::X->getObjectFiles())
     V.push_back({F->getName(), F->getObj().getHeader()->e_flags});
+  if (V.empty())
+    return 0;
   checkFlags(V);
   return getMiscFlags(V) | getPicFlags(V) | getArchFlags(V);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25237.73476.patch
Type: text/x-patch
Size: 825 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161004/0cba11ca/attachment.bin>


More information about the llvm-commits mailing list