This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Add --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi] to ld


On Tue, Apr 14, 2015 at 07:43:36PM -0700, H.J. Lu wrote:
> On Tue, Apr 14, 2015 at 5:55 PM, Alan Modra <amodra@gmail.com> wrote:
> > So, I'm wondering whether things would look better if
> > elf_link_input_bfd allocated the extra buffer needed rather than in
> > both _bfd_write_merged_section and _bfd_elf_set_section_contents.
> > Of course, _bfd_write_merged_section would need two extra parameters,
> > contents and offset, and write to "contents" if non-NULL rather than
> > to the output file.
> 
> Thanks for the suggestion.  I allocated the buffer in bfd_elf_final_link
> instead without adding extra arguments to _bfd_write_merged_section.
> Here is the updated patch. OK for master?

I still think the extra arguments are better, but will OK this one
with some fixes.

> @@ -283,13 +284,15 @@ sec_merge_add (struct sec_merge_hash *tab, const char *str,
>  }
>  
>  static bfd_boolean
> -sec_merge_emit (bfd *abfd, struct sec_merge_hash_entry *entry)
> +sec_merge_emit (bfd *abfd, struct sec_merge_hash_entry *entry,
> +		file_ptr offset)
>  {
>    struct sec_merge_sec_info *secinfo = entry->secinfo;
>    asection *sec = secinfo->sec;
>    char *pad = NULL;
>    bfd_size_type off = 0;
>    int alignment_power = sec->output_section->alignment_power;
> +  unsigned char *contents = NULL;

pass contents to sec_merge_emit, so that

> @@ -298,6 +301,14 @@ sec_merge_emit (bfd *abfd, struct sec_merge_hash_entry *entry)
>  	return FALSE;
>      }
>  
> +  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
> +    {
> +      Elf_Internal_Shdr *hdr
> +	= &elf_section_data (sec->output_section)->this_hdr;
> +      if (hdr->sh_offset == (file_ptr) -1)
> +	contents = hdr->contents;
> +    }
> +

this hunk can disappear.

> @@ -794,12 +820,33 @@ _bfd_write_merged_section (bfd *output_bfd, asection *sec, void *psecinfo)
>    if (secinfo->first_str == NULL)
>      return TRUE;
>  
> +  contents = NULL;
> +
>    /* FIXME: octets_per_byte.  */
> -  pos = sec->output_section->filepos + sec->output_offset;
> -  if (bfd_seek (output_bfd, pos, SEEK_SET) != 0)
> -    return FALSE;
> +  if (bfd_get_flavour (output_bfd) == bfd_target_elf_flavour)

Delete this unnecessary test.  merge.c is only used with ELF output.

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]