[PATCH] D81144: [MC] Generate .debug_line in the 64-bit DWARF format [2/7]

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 10:25:34 PDT 2020


ikudrin added a comment.

In D81144#2082358 <https://reviews.llvm.org/D81144#2082358>, @probinson wrote:

> In D81144#2081485 <https://reviews.llvm.org/D81144#2081485>, @ikudrin wrote:
>
> > If an assembler source contains `.file`/`.loc` directives, and `-dwarf64` is given, `llvm-mc` will still correctly produce a `DWARF64` `.debug_line` section. That is because the only differences between `DWARF32` and `DWARF64` ones are `unit_length` and `header_length` fields, and references to `.debug_line_str`, and all these are covered by this patch.
> >
> > Do you have any specific example which results in an incorrect output with these patches?
>
>
> Right, both the GenDwarf and .file/.loc paths use the same infrastructure.  But if an assembler source contains .file/.loc directives, it likely also has compiler-generated .debug_info/etc sections, so the consistency of the output sections is not assured.  The DWARF spec (section 7.4) states "The 32-bit and 64-bit DWARF format conventions must _not_ be intermixed within a single compilation unit."
>
> Thinking about this more, as a practical matter, we probably don't want to make llvm-mc detect the formats of the .debug_info/etc sections and assure that all the formats are consistent.  I suppose have to make it the responsibility of the user to invoke llvm-mc with `--dwarf-64` only for hand-written asm or asm with other sections emitted in DWARF-64 format?


To enforce the rule we probably could devise an assembler directive like `.dwarf32`/`.dwarf64`. If a compiler generates an assembler source with some debug info sections pre-filled, it might add that directive to ensure that the result will be consistent.

> I suppose the DWARF verifier should be the one to check the format consistency of all the .debug_* (sub-)sections.  Does it do that?

I can't remember anything like that.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81144/new/

https://reviews.llvm.org/D81144





More information about the llvm-commits mailing list