[llvm-dev] [LLD] Support DWARF64, debug_info "sorting"

Fāng-ruì Sòng via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 16 23:05:53 PST 2020


On Mon, Nov 16, 2020 at 10:42 PM Igor Kudrin <ikudrin at accesssoftek.com> wrote:
>
> On 14.11.2020 3:42, Fāng-ruì Sòng wrote:
> > For .debug_* in object files:
> >
> > DWARF32 -> SHT_PROGBITS (unchanged)
> > DWARF64 -> SHT_DWARF64 or SHT_GNU_DWARF64
> >
> > In LLD, we will need to allow mixed SHT_PROGBITS and SHT_DWARF64. If
> > all input sections are SHT_DWARF64, the output section type probably
> > should also be SHT_DWARF64.
> > If mixed, SHT_PROGBITS.
>
> I am not really sure that we need a new section type. This gets a small
> simplification in one part of the linker but adds much more burden of
> supporting that to all tools and specs around. And that support would be
> required for a rarely used feature, which certainly results that support
> to be partial and sometimes erroneous.

This is not a small simplification. If we consider how we would
address .debug_str with the relocation approach,
it would be quite contrived. A reply I just made
https://lists.llvm.org/pipermail/llvm-dev/2020-November/146673.html
detailed why I don't like the conceptual model: the behavior is
dependent on other sections.
I also felt bad as I had to do string comparison on ".debug_"
(https://reviews.llvm.org/D91404)

I've chatted with gdb folks: gdb (gdb/dwarf2/read.c) is agnostic about
the section type. (They just cannot handle multiple .debug_info
sections.)
SHT_PROGBITS is a default (or "use this if nothing more specific
exists") section type that probably no tool will specifically check
the type.
For many tools, they don't understand DWARF64 yet - there is little
they need to adapt when they add DWARF64 support.
Currently the only problem I can think of is readelf -S (from my
understanding of
https://sourceware.org/pipermail/binutils/2020-November/114116.html ,
Nick will be happy if I write a GNU readelf patch to make the section
header table dump look good:) )

> If we aim for clarity and not ambiguity, I would suggest considering the
> following. The DWARF specs designed so that the data of DWARF32 and
> DWARF64 formats can be intermixed together in one section. What section
> type should be used for that combination? Should it be another new
> section type, something like SHT_DWARF32_DWARF64? Probably not, that
> should be a regular SHT_PROGBITS. That means that DWARF64 data can be
> contained in a SHT_PROGBITS section. Consequently, the section which
> contains DWARF64 data without DWARF32 data should also be SHT_PROGBITS,
> because the latter is just a special case of the former.

I suggest we follow the `canMergeToProgbits` logic in LLD: mixed
SHT_DWARF64 and SHT_PROGBITS get SHT_PROGBITS. This is the existing
rule for many other section types.
Conceptually, the combined section should impose the rigid restriction
when it is further combined with other sections.
This is probably an extra argument that we don't need SHT_DWARF32.

> > FWIW I started a generic-abi thread
> > https://groups.google.com/g/generic-abi/c/i2Xio-47QdQ ("Reserve a
> > section type value for DWARF64") to give stakeholders from other ELF
> > operating systems a chance to participate in the design. I have paid
> > attention to my wording: a new section type is **not decided yet** on
> > LLVM/GNU binutils sides. Our discussions on llvm-dev/binutils will
> > benefit from agreement/disagreement from generic-abi.
>
> Thank you for conducting all these discussions. I hope we will finally
> find a way to bring the feature alive.

Thanks to James and Pavel for quoting the standard.
https://groups.google.com/g/generic-abi/c/i2Xio-47QdQ
It seems that we've made progress on the thread and may be able to get
a generic value.
I am following up with binutils folks
https://sourceware.org/pipermail/binutils/2020-November/
I hope we can get to a design which satisfies all parties.


> --
> Best Regards,
> Igor Kudrin
> C++ Developer, Access Softek, Inc.



-- 
宋方睿


More information about the llvm-dev mailing list