[PATCH] D42635: [ELF] - Report valid binary filename when reporting error.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 1 14:40:58 PST 2018
The code change LGTM.
I agree with Rui on the test change.
Cheers,
Rafael
George Rimar via Phabricator <reviews at reviews.llvm.org> writes:
> grimar created this revision.
> grimar added reviewers: ruiu, espindola.
> Herald added a subscriber: emaste.
>
> We did not report valid filename for duplicate symbol error when
> symbol came from binary input file.
> Patch fixes it.
>
>
> https://reviews.llvm.org/D42635
>
> Files:
> ELF/InputFiles.cpp
> ELF/InputFiles.h
> test/ELF/duplicated-synthetic-sym.s
>
>
> Index: test/ELF/duplicated-synthetic-sym.s
> ===================================================================
> --- test/ELF/duplicated-synthetic-sym.s
> +++ test/ELF/duplicated-synthetic-sym.s
> @@ -4,7 +4,7 @@
> // 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)
> +// CHECK: defined at duplicated-synthetic-sym.s:(.data+0x0)
>
> .globl _binary_duplicated_synthetic_sym_s_start
> _binary_duplicated_synthetic_sym_s_start:
> Index: ELF/InputFiles.h
> ===================================================================
> --- ELF/InputFiles.h
> +++ ELF/InputFiles.h
> @@ -90,8 +90,8 @@
> // Returns object file symbols. It is a runtime error to call this
> // function on files of other types.
> ArrayRef<Symbol *> getSymbols() {
> - assert(FileKind == ObjKind || FileKind == BitcodeKind ||
> - FileKind == ArchiveKind);
> + assert(FileKind == BinaryKind || FileKind == ObjKind ||
> + FileKind == BitcodeKind || FileKind == ArchiveKind);
> return Symbols;
> }
>
> Index: ELF/InputFiles.cpp
> ===================================================================
> --- ELF/InputFiles.cpp
> +++ ELF/InputFiles.cpp
> @@ -1026,8 +1026,8 @@
>
> void BinaryFile::parse() {
> ArrayRef<uint8_t> Data = toArrayRef(MB.getBuffer());
> - auto *Section = make<InputSection>(nullptr, SHF_ALLOC | SHF_WRITE,
> - SHT_PROGBITS, 8, Data, ".data");
> + auto *Section = make<InputSection>(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
>
>
> Index: test/ELF/duplicated-synthetic-sym.s
> ===================================================================
> --- test/ELF/duplicated-synthetic-sym.s
> +++ test/ELF/duplicated-synthetic-sym.s
> @@ -4,7 +4,7 @@
> // 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)
> +// CHECK: defined at duplicated-synthetic-sym.s:(.data+0x0)
>
> .globl _binary_duplicated_synthetic_sym_s_start
> _binary_duplicated_synthetic_sym_s_start:
> Index: ELF/InputFiles.h
> ===================================================================
> --- ELF/InputFiles.h
> +++ ELF/InputFiles.h
> @@ -90,8 +90,8 @@
> // Returns object file symbols. It is a runtime error to call this
> // function on files of other types.
> ArrayRef<Symbol *> getSymbols() {
> - assert(FileKind == ObjKind || FileKind == BitcodeKind ||
> - FileKind == ArchiveKind);
> + assert(FileKind == BinaryKind || FileKind == ObjKind ||
> + FileKind == BitcodeKind || FileKind == ArchiveKind);
> return Symbols;
> }
>
> Index: ELF/InputFiles.cpp
> ===================================================================
> --- ELF/InputFiles.cpp
> +++ ELF/InputFiles.cpp
> @@ -1026,8 +1026,8 @@
>
> void BinaryFile::parse() {
> ArrayRef<uint8_t> Data = toArrayRef(MB.getBuffer());
> - auto *Section = make<InputSection>(nullptr, SHF_ALLOC | SHF_WRITE,
> - SHT_PROGBITS, 8, Data, ".data");
> + auto *Section = make<InputSection>(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
More information about the llvm-commits
mailing list