[PATCH] D34752: [LLD][ELF] Fix nullptr dereference when creating an error message.

Sean Eveson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 5 07:56:12 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL307162: [ELF] Fix nullptr dereference when creating an error message for a synthetic… (authored by seaneveson).

Changed prior to commit:
  https://reviews.llvm.org/D34752?vs=105052&id=105270#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34752

Files:
  lld/trunk/ELF/InputSection.cpp
  lld/trunk/test/ELF/duplicated-synthetic-sym.s


Index: lld/trunk/test/ELF/duplicated-synthetic-sym.s
===================================================================
--- lld/trunk/test/ELF/duplicated-synthetic-sym.s
+++ lld/trunk/test/ELF/duplicated-synthetic-sym.s
@@ -0,0 +1,10 @@
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: cd %S
+// RUN: not ld.lld %t.o --format=binary duplicated-synthetic-sym.s -o %t.elf 2>&1 | FileCheck %s
+
+// CHECK: duplicate symbol: _binary_duplicated_synthetic_sym_s_start
+// CHECK: defined at (internal):(.data+0x0)
+
+    .globl  _binary_duplicated_synthetic_sym_s_start
+_binary_duplicated_synthetic_sym_s_start:
+    .long   0
Index: lld/trunk/ELF/InputSection.cpp
===================================================================
--- lld/trunk/ELF/InputSection.cpp
+++ lld/trunk/ELF/InputSection.cpp
@@ -276,7 +276,9 @@
 template <class ELFT> std::string InputSectionBase::getObjMsg(uint64_t Off) {
   // Synthetic sections don't have input files.
   elf::ObjectFile<ELFT> *File = getFile<ELFT>();
-  std::string Filename = File ? File->getName() : "(internal)";
+  if (!File)
+    return ("(internal):(" + Name + "+0x" + utohexstr(Off) + ")").str();
+  std::string Filename = File->getName();
 
   std::string Archive;
   if (!File->ArchiveName.empty())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34752.105270.patch
Type: text/x-patch
Size: 1279 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170705/2772b95e/attachment.bin>


More information about the llvm-commits mailing list