public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@bigpond.net.au>
To: "H. J. Lu" <hjl@lucon.org>
Cc: binutils@sources.redhat.com
Subject: Re: PATCH: PR 797: Alignment in empty section changes the output layout
Date: Tue, 29 Mar 2005 08:12:00 -0000	[thread overview]
Message-ID: <20050329025959.GE14407@bubble.modra.org> (raw)
In-Reply-To: <20050329020631.GA1504@lucon.org>

On Mon, Mar 28, 2005 at 06:06:31PM -0800, H. J. Lu wrote:
> On Tue, Mar 29, 2005 at 08:12:31AM +0930, Alan Modra wrote:
> > On Thu, Mar 24, 2005 at 02:05:56PM -0800, H. J. Lu wrote:
> > > +	 So we remove the unused output sections without input sections
> > > +	 and the empty unused output sections created by linker, if
> > > +	 they don't have any contents.  */
> > 
> > Is it possible to do this in strip_excluded_output_sections?  You won't
> > have sizes set at that stage, but linker_has_input will be set, as will
> > SEC_HAS_CONTENTS from link script data statements.  So I think most of
> 
> But SEC_KEEP may not be set before lang_mark_used_section.
> 
> > what you're trying to achieve can be done there.  SEC_LINKER_CREATED
> > sections ought to be handled by the backend size_dynamic_sections
> > function calling _bfd_strip_section_from_output.
> 
> Or I can check every output section and call _bfd_strip_section_from_output
> at the end of bfd_elf_size_dynamic_sections so that I don't have to
> change every backend.

No, I think that would be a bad idea.  Most SEC_LINKER_CREATED sections
are created by the backend code, so the backend code should manage them.
Otherwise you run the risk of removing sections that some backend wants
to keep.

> But _bfd_strip_section_from_output will check
> every input section. It may be expensive.

Sure.  Let's fix it.  Perhaps by creating bfd_link_order lists earlier,
after placing orphans.

> If I have to do it in
> gld${EMULATION_NAME}_finish for other sections anyway, why not
> to remove empty unused linker created sections in a same place.

I don't really like the idea of removing sections so late in the link
process.  It's a hack that I allowed because removing excess symbols and
output sections was desirable, but now you're adding hacks upon hacks. 
As evidenced by the need for yet another section flag.

The proper place to remove sections is after the backend
size_dynamic_sections has run and before space for dynamic symbols is
allocated.  If you do it that way you'll avoid some unnecessary dynamic
syms too.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

  reply	other threads:[~2005-03-29  3:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-24 11:45 H. J. Lu
2005-03-25  2:22 ` H. J. Lu
2005-03-29  4:21   ` Alan Modra
2005-03-29  7:13     ` H. J. Lu
2005-03-29  8:12       ` Alan Modra [this message]
2005-03-30 16:30         ` H. J. Lu
2005-05-04 19:53 H. J. Lu
2005-05-05  3:48 ` Alan Modra
2005-05-05  4:52   ` H. J. Lu
2005-05-05  5:35     ` Alan Modra
2005-05-05  5:56       ` H. J. Lu
2005-05-05  6:33         ` Alan Modra
2005-05-05 16:12           ` H. J. Lu
2005-05-06  6:20             ` Alan Modra
2005-05-07 19:16               ` H. J. Lu
2005-05-07 20:08                 ` H. J. Lu
2005-05-17 15:13                   ` Nick Clifton

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=20050329025959.GE14407@bubble.modra.org \
    --to=amodra@bigpond.net.au \
    --cc=binutils@sources.redhat.com \
    --cc=hjl@lucon.org \
    /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).