<div dir="ltr"><div>I was thinking about whether I liked the section name idea myself. I think a slight refinement could be to have linkers combine .debug and .debug64 sections into one output section (in non -r links), so that end consumers (debuggers etc) don't have to worry about it. However, conformance is still a concern to me as we cannot really retrofit the existing standard versions, and the section names themselves are in the standard. That means that tools that otherwise would work might stop working when presented with a "new" DWARFv3/4/5 output that 
 it

in theory could otherwise handle. This applies to both debuggers who don't know about the support and tools like llvm-dwarfdump which work on intermediate objects until they get updated. One final concern with the section name approach is that there are tools that look for the debug sections in general (e.g. llvm-objcopy --strip-debug), which use the prefix ".debug_" to identify such sections, rather than .debug, so .debug64 would be a bad name to use (although you could do .debug_64_info or .debug_info_64 probably safely).<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 18 Nov 2020 at 06:07, Fāng-ruì Sòng <<a href="mailto:maskray@google.com">maskray@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">In <a href="https://groups.google.com/g/generic-abi/c/i2Xio-47QdQ" rel="noreferrer" target="_blank">https://groups.google.com/g/generic-abi/c/i2Xio-47QdQ</a> (you need to<br>
join the group before making a post)<br>
Cary Coutant raised yet another idea: whether we can use ".debug64" as<br>
the section prefix. I like the idea because of:<br>
<br>
* It is immediately obvious whether DWARF64 is used and whether<br>
DWARF32 is used along with DWARF64.<br>
* In a relocatable link mixing DWARF32 and DWARF64 sections, DWARF32<br>
and DWARF64 sections will naturally not get mixed. (For a relocation<br>
based approach, if DWARF64 is the first input section, the output may<br>
appear as a "DWARF64" because the proposed approach only checks the<br>
first relocation)<br>
<br>
On the other hand,<br>
<br>
* It is (slightly) non-conformant because of the different section names.<br>
* Tooling support. Some commonly used consumers have recognized<br>
DWARF64. We'll have to teach these tools about new section names. The<br>
number of sections to recognize has doubled. This may result in a fair<br>
amount of complexity (DWARFContext/MCObjectFileInfo/llvm-dwarfdump<br>
-debug* options/ld.lld --gdb-index are things I can immediately think<br>
of).<br>
<br>
On balance I think this is not as good as the section type idea.<br>
<br>
On Tue, Nov 17, 2020 at 12:17 AM James Henderson<br>
<<a href="mailto:jh7370.2008@my.bristol.ac.uk" target="_blank">jh7370.2008@my.bristol.ac.uk</a>> wrote:<br>
><br>
> Thinking about it, it would probably be wise to raise this discussion on the DWARF mailing list too. They might want to put an addendum in the spec/DWARF wiki/somewhere appropriate along the lines of "ELF support for DWARF64", which can be retroactively applied to existing standards. The committee may also have some thoughts on how tools are expected to work with DWARF64 and DWARF32 mixtures.<br>
><br>
> James<br>
><br>
> On Tue, 17 Nov 2020 at 07:06, Fāng-ruì Sòng <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> wrote:<br>
>><br>
>> On Mon, Nov 16, 2020 at 10:42 PM Igor Kudrin <<a href="mailto:ikudrin@accesssoftek.com" target="_blank">ikudrin@accesssoftek.com</a>> wrote:<br>
>> ><br>
>> > On 14.11.2020 3:42, Fāng-ruì Sòng wrote:<br>
>> > > For .debug_* in object files:<br>
>> > ><br>
>> > > DWARF32 -> SHT_PROGBITS (unchanged)<br>
>> > > DWARF64 -> SHT_DWARF64 or SHT_GNU_DWARF64<br>
>> > ><br>
>> > > In LLD, we will need to allow mixed SHT_PROGBITS and SHT_DWARF64. If<br>
>> > > all input sections are SHT_DWARF64, the output section type probably<br>
>> > > should also be SHT_DWARF64.<br>
>> > > If mixed, SHT_PROGBITS.<br>
>> ><br>
>> > I am not really sure that we need a new section type. This gets a small<br>
>> > simplification in one part of the linker but adds much more burden of<br>
>> > supporting that to all tools and specs around. And that support would be<br>
>> > required for a rarely used feature, which certainly results that support<br>
>> > to be partial and sometimes erroneous.<br>
>><br>
>> This is not a small simplification. If we consider how we would<br>
>> address .debug_str with the relocation approach,<br>
>> it would be quite contrived. A reply I just made<br>
>> <a href="https://lists.llvm.org/pipermail/llvm-dev/2020-November/146673.html" rel="noreferrer" target="_blank">https://lists.llvm.org/pipermail/llvm-dev/2020-November/146673.html</a><br>
>> detailed why I don't like the conceptual model: the behavior is<br>
>> dependent on other sections.<br>
>> I also felt bad as I had to do string comparison on ".debug_"<br>
>> (<a href="https://reviews.llvm.org/D91404" rel="noreferrer" target="_blank">https://reviews.llvm.org/D91404</a>)<br>
>><br>
>> I've chatted with gdb folks: gdb (gdb/dwarf2/read.c) is agnostic about<br>
>> the section type. (They just cannot handle multiple .debug_info<br>
>> sections.)<br>
>> SHT_PROGBITS is a default (or "use this if nothing more specific<br>
>> exists") section type that probably no tool will specifically check<br>
>> the type.<br>
>> For many tools, they don't understand DWARF64 yet - there is little<br>
>> they need to adapt when they add DWARF64 support.<br>
>> Currently the only problem I can think of is readelf -S (from my<br>
>> understanding of<br>
>> <a href="https://sourceware.org/pipermail/binutils/2020-November/114116.html" rel="noreferrer" target="_blank">https://sourceware.org/pipermail/binutils/2020-November/114116.html</a> ,<br>
>> Nick will be happy if I write a GNU readelf patch to make the section<br>
>> header table dump look good:) )<br>
>><br>
>> > If we aim for clarity and not ambiguity, I would suggest considering the<br>
>> > following. The DWARF specs designed so that the data of DWARF32 and<br>
>> > DWARF64 formats can be intermixed together in one section. What section<br>
>> > type should be used for that combination? Should it be another new<br>
>> > section type, something like SHT_DWARF32_DWARF64? Probably not, that<br>
>> > should be a regular SHT_PROGBITS. That means that DWARF64 data can be<br>
>> > contained in a SHT_PROGBITS section. Consequently, the section which<br>
>> > contains DWARF64 data without DWARF32 data should also be SHT_PROGBITS,<br>
>> > because the latter is just a special case of the former.<br>
>><br>
>> I suggest we follow the `canMergeToProgbits` logic in LLD: mixed<br>
>> SHT_DWARF64 and SHT_PROGBITS get SHT_PROGBITS. This is the existing<br>
>> rule for many other section types.<br>
>> Conceptually, the combined section should impose the rigid restriction<br>
>> when it is further combined with other sections.<br>
>> This is probably an extra argument that we don't need SHT_DWARF32.<br>
>><br>
>> > > FWIW I started a generic-abi thread<br>
>> > > <a href="https://groups.google.com/g/generic-abi/c/i2Xio-47QdQ" rel="noreferrer" target="_blank">https://groups.google.com/g/generic-abi/c/i2Xio-47QdQ</a> ("Reserve a<br>
>> > > section type value for DWARF64") to give stakeholders from other ELF<br>
>> > > operating systems a chance to participate in the design. I have paid<br>
>> > > attention to my wording: a new section type is **not decided yet** on<br>
>> > > LLVM/GNU binutils sides. Our discussions on llvm-dev/binutils will<br>
>> > > benefit from agreement/disagreement from generic-abi.<br>
>> ><br>
>> > Thank you for conducting all these discussions. I hope we will finally<br>
>> > find a way to bring the feature alive.<br>
>><br>
>> Thanks to James and Pavel for quoting the standard.<br>
>> <a href="https://groups.google.com/g/generic-abi/c/i2Xio-47QdQ" rel="noreferrer" target="_blank">https://groups.google.com/g/generic-abi/c/i2Xio-47QdQ</a><br>
>> It seems that we've made progress on the thread and may be able to get<br>
>> a generic value.<br>
>> I am following up with binutils folks<br>
>> <a href="https://sourceware.org/pipermail/binutils/2020-November/" rel="noreferrer" target="_blank">https://sourceware.org/pipermail/binutils/2020-November/</a><br>
>> I hope we can get to a design which satisfies all parties.<br>
>><br>
>><br>
>> > --<br>
>> > Best Regards,<br>
>> > Igor Kudrin<br>
>> > C++ Developer, Access Softek, Inc.<br>
>><br>
>><br>
>><br>
>> --<br>
>> 宋方睿<br>
<br>
<br>
<br>
-- <br>
宋方睿<br>
</blockquote></div>