From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125455 invoked by alias); 15 Apr 2015 03:58:59 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 125442 invoked by uid 89); 15 Apr 2015 03:58:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.5 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,UNSUBSCRIBE_BODY autolearn=no version=3.3.2 X-HELO: mail-pd0-f182.google.com Received: from mail-pd0-f182.google.com (HELO mail-pd0-f182.google.com) (209.85.192.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 15 Apr 2015 03:58:57 +0000 Received: by pdbqa5 with SMTP id qa5so36406266pdb.1 for ; Tue, 14 Apr 2015 20:58:55 -0700 (PDT) X-Received: by 10.68.57.201 with SMTP id k9mr42318969pbq.135.1429070335654; Tue, 14 Apr 2015 20:58:55 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-155-134.oycza5.sa.bigpond.net.au. [58.160.155.134]) by mx.google.com with ESMTPSA id jg3sm803212pbb.72.2015.04.14.20.58.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Apr 2015 20:58:54 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 2923EEA017E; Wed, 15 Apr 2015 13:28:50 +0930 (ACST) Date: Wed, 15 Apr 2015 03:58:00 -0000 From: Alan Modra To: "H.J. Lu" Cc: Binutils Subject: Re: PATCH: Add --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi] to ld Message-ID: <20150415035850.GA30136@bubble.grove.modra.org> Mail-Followup-To: "H.J. Lu" , Binutils References: <20150415005524.GB31531@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00234.txt.bz2 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 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