public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: PATCH: Add --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi] to ld
Date: Wed, 15 Apr 2015 03:58:00 -0000	[thread overview]
Message-ID: <20150415035850.GA30136@bubble.grove.modra.org> (raw)
In-Reply-To: <CAMe9rOrDsmL-NfuiuFewEvmO=LLCmafxaVqCo+VMW2aaztaEww@mail.gmail.com>

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

  reply	other threads:[~2015-04-15  3:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-13 12:38 H.J. Lu
2015-04-15  0:55 ` Alan Modra
2015-04-15  2:44   ` H.J. Lu
2015-04-15  3:58     ` Alan Modra [this message]
2015-04-15  5:07       ` H.J. Lu
2015-04-28 18:57         ` Andreas Schwab
2015-04-28 19:15           ` H.J. Lu
2015-04-28 19:22             ` Andreas Schwab
2015-04-28 19:25               ` H.J. Lu
2015-04-28 19:46                 ` Andreas Schwab
2015-04-28 19:26         ` Andreas Schwab
2015-04-28 19:29           ` H.J. Lu
2015-04-28 19:46             ` Andreas Schwab
2015-04-28 20:00               ` H.J. Lu
2015-04-28 20:21                 ` Andreas Schwab
2015-04-28 20:34                   ` H.J. Lu
2015-04-28 20:44                     ` Andreas Schwab
2015-04-28 20:45                       ` H.J. Lu
2015-04-28 20:49                         ` Andreas Schwab
2015-04-28 21:02                           ` H.J. Lu
2015-04-29  7:35             ` Andreas Schwab
2015-04-28 19:36         ` Andreas Schwab
2015-04-28 19:43           ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150415035850.GA30136@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).