This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Fail the link if something happens on DWARF parsing stage of -gdb-index building
ClosedPublic

Authored by grimar on Jun 29 2017, 8:06 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Jun 29 2017, 8:06 AM
This revision was automatically updated to reflect the committed changes.
ruiu added inline comments.Jul 11 2017, 2:26 PM
lld/trunk/ELF/SyntheticSections.cpp
1817

What does this ErrorPolicy::Continue mean? If there's something like Abort, you want to abort, as if something is broken in a DWARF debug info, it is very likely that the following bytes are also garbage.

grimar added inline comments.Jul 12 2017, 1:05 AM
lld/trunk/ELF/SyntheticSections.cpp
1817

There are ErrorPolicy::Continue and ErrorPolicy::Halt currently imlemented.
First one allows parsers to continue parsing object, second terminates parsing.

Continue used here intentionally because allows to report as many errors as possible and not Abort instantly.
(that is consistent with how compilers (and linkers) behave usually).

it is very likely that the following bytes are also garbage.

Broken objects is only a one side, there are many examples where Continue behavior may be more desirable:

  • For example currently we have case when one of X86_64 relocations is not supported (PR33173), we probably want to report all such cases and not fail after very first error.
  • Another example - we currently have AVR target in LLD, and DWARF parsers do not support its relocations at all. With Continue we will list ErrorLimit amount of places where it faces unimplemented relocations, what can be useful for working on AVR and other possible new targets.
  • If something wrong with compressed section, DWARF parsers would report a error currently ("failed to decompress .... "), it makes sence to continue parsing other sections to find more possible issues I think.