[lld] r307162 - [ELF] Fix nullptr dereference when creating an error message for a synthetic section.
Sean Eveson via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 5 07:55:43 PDT 2017
Author: seaneveson
Date: Wed Jul 5 07:55:43 2017
New Revision: 307162
URL: http://llvm.org/viewvc/llvm-project?rev=307162&view=rev
Log:
[ELF] Fix nullptr dereference when creating an error message for a synthetic section.
Differential Revision: https://reviews.llvm.org/D34752
Added:
lld/trunk/test/ELF/duplicated-synthetic-sym.s
Modified:
lld/trunk/ELF/InputSection.cpp
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=307162&r1=307161&r2=307162&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Jul 5 07:55:43 2017
@@ -276,7 +276,9 @@ template <class ELFT> std::string InputS
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())
Added: lld/trunk/test/ELF/duplicated-synthetic-sym.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/duplicated-synthetic-sym.s?rev=307162&view=auto
==============================================================================
--- lld/trunk/test/ELF/duplicated-synthetic-sym.s (added)
+++ lld/trunk/test/ELF/duplicated-synthetic-sym.s Wed Jul 5 07:55:43 2017
@@ -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
More information about the llvm-commits
mailing list