From f9dc10cd8913a3ada2575599b8fade748bad2598 Mon Sep 17 00:00:00 2001 From: George Rimar Date: Mon, 5 Feb 2018 09:47:24 +0000 Subject: [PATCH] [ELF] - Report valid binary filename when reporting error. We did not report valid filename for duplicate symbol error when symbol came from binary input file. Patch fixes it. Differential revision: https://reviews.llvm.org/D42635 llvm-svn: 324217 --- lld/ELF/InputFiles.cpp | 4 ++-- lld/ELF/InputFiles.h | 4 ++-- lld/test/ELF/duplicated-synthetic-sym.s | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 2326a7d9bf8f..4edabc578667 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -1032,8 +1032,8 @@ static ELFKind getELFKind(MemoryBufferRef MB) { void BinaryFile::parse() { ArrayRef Data = toArrayRef(MB.getBuffer()); - auto *Section = make(nullptr, SHF_ALLOC | SHF_WRITE, - SHT_PROGBITS, 8, Data, ".data"); + auto *Section = make(this, SHF_ALLOC | SHF_WRITE, SHT_PROGBITS, + 8, Data, ".data"); Sections.push_back(Section); // For each input file foo that is embedded to a result as a binary diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h index dda1de81570c..a2251a410c6e 100644 --- a/lld/ELF/InputFiles.h +++ b/lld/ELF/InputFiles.h @@ -90,8 +90,8 @@ public: // Returns object file symbols. It is a runtime error to call this // function on files of other types. ArrayRef getSymbols() { - assert(FileKind == ObjKind || FileKind == BitcodeKind || - FileKind == ArchiveKind); + assert(FileKind == BinaryKind || FileKind == ObjKind || + FileKind == BitcodeKind || FileKind == ArchiveKind); return Symbols; } diff --git a/lld/test/ELF/duplicated-synthetic-sym.s b/lld/test/ELF/duplicated-synthetic-sym.s index d9bc8bc7c7a1..095f581e2143 100644 --- a/lld/test/ELF/duplicated-synthetic-sym.s +++ b/lld/test/ELF/duplicated-synthetic-sym.s @@ -9,7 +9,7 @@ // CHECK: duplicate symbol: _binary_file_bin_start // CHECK-NEXT: defined at {{.*}}.o:(.text+0x0) -// CHECK-NEXT: defined at :(.data+0x0) +// CHECK-NEXT: defined at file.bin:(.data+0x0) .globl _binary_file_bin_start _binary_file_bin_start: