[PATCH] D34814: [ELF] - Fail the link if something happens on DWARF parsing stage of -gdb-index building
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 10 13:12:19 PDT 2017
On Thu, Jun 29, 2017 at 8:06 AM George Rimar via Phabricator via
llvm-commits <llvm-commits at lists.llvm.org> wrote:
> grimar created this revision.
> Herald added subscribers: aprantl, emaste.
>
> This is relative to PR33173,
>
> Previously if something wrong happened on DWARF parsers side during parsing
> object for building gdb index (like was in PR: unsupported relocation)
> then LLD continued
> and finished the link. DWARF parsers sure showed error message on their
> side, but that is all.
>
> Patch changes behavior to fail the link in this case and show more
> detailed message.
>
>
> https://reviews.llvm.org/D34814
>
> Files:
> ELF/SyntheticSections.cpp
> test/ELF/invalid/invalid-debug-relocations.test
>
>
> Index: test/ELF/invalid/invalid-debug-relocations.test
> ===================================================================
> --- test/ELF/invalid/invalid-debug-relocations.test
> +++ test/ELF/invalid/invalid-debug-relocations.test
> @@ -0,0 +1,41 @@
> +# REQUIRES: x86
> +# RUN: yaml2obj %s -o %t.o
> +# RUN: not ld.lld -gdb-index %t.o -o %t.exe 2>&1 | FileCheck %s
> +
> +# CHECK: error: {{.*}}.o: error parsing DWARF data:
> +# CHECK-NEXT: >>> failed to compute relocation: Unknown, Invalid data was
> encountered while parsing the file
> +
> +!ELF
> +FileHeader:
> + Class: ELFCLASS32
> + Data: ELFDATA2LSB
> + Type: ET_REL
> + Machine: EM_386
> +Sections:
> + - Type: SHT_PROGBITS
> + Name: .text
> + Flags: [ ]
> + AddressAlign: 0x04
> + Content: "0000"
> + - Type: SHT_PROGBITS
> + Name: .debug_info
> + Flags: [ ]
> + AddressAlign: 0x04
> + Content: "0000"
> + - Type: SHT_REL
> + Name: .rel.debug_info
> + Link: .symtab
> + Info: .debug_info
> + Relocations:
> + - Offset: 0
> + Symbol: _start
> + Type: 0xFF
> + - Offset: 4
> + Symbol: _start
> + Type: 0xFF
> +Symbols:
> + Global:
> + - Name: _start
> + Type: STT_FUNC
> + Section: .text
> + Value: 0x0
> Index: ELF/SyntheticSections.cpp
> ===================================================================
> --- ELF/SyntheticSections.cpp
> +++ ELF/SyntheticSections.cpp
> @@ -1810,7 +1810,11 @@
> return {};
> }
>
> - DWARFContextInMemory Dwarf(*Obj.get());
> + DWARFContextInMemory Dwarf(*Obj.get(), nullptr, [&](Error E) {
> + error(toString(Sec->File) + ": error parsing DWARF data:\n>>> " +
> + toString(std::move(E)));
> + return ErrorPolicy::Continue;
>
Is 'error(...)' a noreturn function (does it cause the linker to stop
immediately?)? If so, remove the 'return' after it, since that'll be
unreachable code.
> + });
>
> GdbIndexChunk Ret;
> Ret.CompilationUnits = readCuList(Dwarf, Sec);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170710/006f5765/attachment.html>
More information about the llvm-commits
mailing list