How to sort mixed DWARF32 and DWARF64 .debug_*

Fangrui Song i@maskray.me
Tue Nov 17 05:12:49 GMT 2020


On 2020-11-13, Fangrui Song wrote:
>> >This would work for any section types that come in 32-bit and 64-bit flavours...
>>
>> https://lists.llvm.org/pipermail/llvm-dev/2020-November/146557.html
>> raised the section type idea: we could assign a dedicated section type for
>> DWARF64 .debug_* sections. The thread also raised ideas about using sh_info.
>>
>> The section type idea actually looks quite good to me. There are some features we will need:
>>
>> * we might need to ask on generic-abi whether
>>    Solaris/HP-UX/... folks are happy with a dedicated section type, if not
>>    then perhaps we could use SHT_GNU_*
>> * we need a way in linker scripts to match input sections by type. AFAIK
>>    there is no existing mechanism.
>>
>> If we invent a keyword (say, TYPE) to match sections by type, we could use
>>    .debug_info     0 : { *(TYPE (SHT_PROGBITS) .debug_info${RELOCATING+ .gnu.linkonce.wi.*}) }
>>    .debug_info     0 : { *(TYPE (SHT_GNU_DWARF64) .debug_info) }
>>
>> or
>>
>>    .debug_info     0 : { *(TYPE (SHT_PROGBITS) .debug_info${RELOCATING+ .gnu.linkonce.wi.*} TYPE (SHT_GNU_DWARF64) .debug_info) }
>>
>
>Apologies that the examples need correction:
>
>.debug_info     0 : { *(TYPE (SHT_PROGBITS) .debug_info${RELOCATING+
>.gnu.linkonce.wi.*}) *(TYPE (SHT_GNU_DWARF64) .debug_info) }
>
>We need two input section descriptions because one does not impose an
>ordering. I do not add SHT_GNU_DWARF64 for .gnu.linkonce.wi.*
>because I think .gnu.linkonce.wi.* is a legacy which is not relevant
>in this century:)

I've made progress with my generic-abi proposal
https://groups.google.com/g/generic-abi/c/i2Xio-47QdQ "Reserve a section type value for DWARF64"

Let's see whether they will be happy with SHT_DWARF64=19 (in the generic range).
The linker script may become:

   .debug_info 0 : { *(TYPE (SHT_PROGBITS) .debug_info${RELOCATING+ .gnu.linkonce.wi.*}) *(TYPE (SHT_DWARF64) .debug_info) }

This single output section scheme should work for GDB.
GDB folks said that multiple .debug_info does not work in GDB (yet).


More information about the Binutils mailing list