[PATCH] compress .gnu.debuglto_.debug_* sections if requested

Martin Liška mliska@suse.cz
Fri Sep 30 07:19:49 GMT 2022


On 9/30/22 02:20, Alan Modra wrote:
> On Thu, Sep 29, 2022 at 03:35:15PM +0200, Martin Liška wrote:
>> +  /* Compress/decompress DWARF debug sections with names: .debug_*,
>> +     .zdebug_*, .gnu.debuglto_.debug_, after the section flags is set.  */
>>    if ((newsect->flags & SEC_DEBUGGING) != 0
>>        && (newsect->flags & SEC_HAS_CONTENTS) != 0
>> -      && ((name[1] == 'd' && name[6] == '_')
>> -	  || (name[1] == 'z' && name[7] == '_')))
>> +      && (startswith (name, ".debug_")
>> +	  || startswith (name, ".zdebug_")
>> +	  || startswith (name, ".gnu.debuglto_.debug_")))
> 
> If you test "(newsect->flags & SEC_ELF_OCTETS) != 0" as well, I think
> you could omit any name tests here.  This would also compress
> .gnu.linkonce.wi.* sections.  (Not that they matter very much, I'm
> just pointing out a code simplification.)

Yep, I like the code simplification!

> 
>> --- a/gas/write.c
>> +++ b/gas/write.c
>> @@ -1481,7 +1481,8 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
>>      return;
>>  
>>    section_name = bfd_section_name (sec);
>> -  if (!startswith (section_name, ".debug_"))
>> +  if (!startswith (section_name, ".debug_")
>> +      && !startswith (section_name, ".gnu.debuglto_.debug_"))
>>      return;
>>  
>>    bool use_zstd = abfd->flags & BFD_COMPRESS_ZSTD;
> 
> Hmm, it looks to me like this function will transform
> ".gnu.debuglto_.debug_*" to ".zgnu.debuglto_.debug_*" if
> --compress-debug-sections=zlib-gnu is used, which will break your
> elf.c change.  Please check --compress-debug-sections=zlib-gnu.

Again, great comment, fixed in v2.

Ready for master now?
Thanks,
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-compress-.gnu.debuglto_.debug_-sections-if-requested.patch
Type: text/x-patch
Size: 2750 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20220930/d694814a/attachment.bin>


More information about the Binutils mailing list