[PATCH] D28559: [ELF] - Do not crash if user section has name equal to one of synthetic sections.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 12 05:11:32 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL291765: [ELF] - Do not crash if user section has name equal to one of synthetic… (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D28559?vs=83961&id=84112#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28559

Files:
  lld/trunk/ELF/InputSection.cpp
  lld/trunk/test/ELF/incompatible-section-types2.s


Index: lld/trunk/test/ELF/incompatible-section-types2.s
===================================================================
--- lld/trunk/test/ELF/incompatible-section-types2.s
+++ lld/trunk/test/ELF/incompatible-section-types2.s
@@ -0,0 +1,7 @@
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s
+
+// CHECK: error: Section has different type from others with the same name <internal>:(.shstrtab)
+
+.section .shstrtab,""
+.short 20
Index: lld/trunk/ELF/InputSection.cpp
===================================================================
--- lld/trunk/ELF/InputSection.cpp
+++ lld/trunk/ELF/InputSection.cpp
@@ -36,7 +36,10 @@
 // Returns a string to construct an error message.
 template <class ELFT>
 std::string lld::toString(const InputSectionBase<ELFT> *Sec) {
-  return (Sec->getFile()->getName() + ":(" + Sec->Name + ")").str();
+  // File can absent if section is synthetic.
+  std::string FileName =
+      Sec->getFile() ? Sec->getFile()->getName() : "<internal>";
+  return (FileName + ":(" + Sec->Name + ")").str();
 }
 
 template <class ELFT>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28559.84112.patch
Type: text/x-patch
Size: 1124 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170112/1237f11d/attachment.bin>


More information about the llvm-commits mailing list