PATCH: PR ld/18277: --compress-debug-sections=zlib may generate larger debug sections

H.J. Lu hjl.tools@gmail.com
Thu Apr 23 15:58:00 GMT 2015


On Fri, Apr 17, 2015 at 2:31 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> Section name is added to section name section to early for
> _bfd_elf_assign_file_positions_for_non_load to change section name
> if compressed section size is bigger than uncompressed section.
>
> This patch delays adding setion name to section name section after the
> section is compressed in bfd_elf_assign_file_positions_for_non_load and
> we only change setion name if compressed section size is smaller.  It
> means that section name section is placed after debug sections.  Some
> testcases have to be adjusted.
>
> Any comments, feedbacks, objections?
>

Here is the rebased patch.  Any comments, feedbacks, objections?

Thanks.

-- 
H.J.
---
When we set up st_name for output section name in elf_fake_sections, we
don't know if the compressed DWARF debug section will be smaller. We may
end up with compressed DWARF debug sections which are bigger than the
uncompressed ones.  This patch delays setting up st_name for output DWARF
debug section to _bfd_elf_assign_file_positions_for_non_load which will
compress the output debug section.  We also postpone placement of shstrtab
section after DWARF debug sections have been compressed.  The net effect
is .shstrtab section is now placed after .symtab and .strtab sections.

bfd/

PR ld/18277
* compress.c (bfd_compress_section_contents): Remove the
write_compress argument.
(bfd_init_section_compress_status): Updated.
(bfd_compress_section): Likewise.
* elf.c (_bfd_elf_set_reloc_sh_name): New.
(_bfd_elf_init_reloc_shdr): Add delay_st_name_p.  Set sh_name
to (unsigned int) -1 if delay_st_name_p is TRUE.  Use
_bfd_elf_set_reloc_sh_name.
(elf_fake_sections): Don't rename DWARF debug section for
linker output if it will be compressed.  Instead, set
delay_st_name_p to TRUE and pass it to _bfd_elf_init_reloc_shdr.
(assign_section_numbers): Call _bfd_elf_strtab_addref only if
sh_name != (unsigned int) -1.  Don't finalize nor assign
shstrtab section here.  Delay setting output section names to
_bfd_elf_write_object_contents.
(_bfd_elf_compute_section_file_positions): Update comments on
sh_offset for shstrtab section.
(assign_file_positions_for_non_load_sections): Set sh_offset to
-1 for shstrtab section.
(assign_file_positions_except_relocs): Likewise.
(_bfd_elf_assign_file_positions_for_non_load): Set up sh_name
when compressing DWARF debug sections.  Place shstrtab section
after DWARF debug sections have been compressed.
(_bfd_elf_write_object_contents): Setting sh_name for output
sections.

ld/testsuite/

PR ld/18277
* ld-elf/compressed1d.d: New.
* ld-elf/compressed1e.d: Likewise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Delay-setting-up-compressed-debug-section-names.patch
Type: text/x-patch
Size: 16766 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20150423/bbc10606/attachment.bin>


More information about the Binutils mailing list