This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Map ".text.hot" and ".text.unlikely" input section prefixes to separate output sections.
- From: Ian Lance Taylor <iant at google dot com>
- To: Sriraman Tallam <tmsriram at google dot com>
- Cc: binutils <binutils at sourceware dot org>, Cary Coutant <ccoutant at google dot com>
- Date: Tue, 20 Nov 2012 07:12:55 -0800
- Subject: Re: Map ".text.hot" and ".text.unlikely" input section prefixes to separate output sections.
- References: <CAAs8HmygtSkVh3v4dz2hBTzS1AH-rLbBkTDJ-hVkzENC2sqQZg@mail.gmail.com> <mcrlitsdqf3.fsf@coign.corp.google.com> <CAAs8HmxS9v50Bzw1srgUaC+8dCekCjv_H5_kyAi3Z5TDB8TkGg@mail.gmail.com>
On Wed, Nov 14, 2012 at 5:06 PM, Sriraman Tallam <tmsriram@google.com> wrote:
>
> I finally got around to doing this in a way you suggested a while
> back, that is sorting text sections within the output section rather
> than creating separate output sections. Patch attached.
OK, let's go back to this version.
> + // The GNU linker groups input sections whose names match .text.unlikely.*.
> + // This is used to get better code layout. We are compatible.
> + // Additionally, it could also be beneficial to group .text.hot.*,
> + // .text.startup.* prefixed input sections.
> + if (!this->script_options_->saw_sections_clause()
> + && !parameters->options().relocatable()
> + && !os->input_section_order_specified()
> + && strcmp(name, ".text") == 0)
> + os->set_must_sort_attached_input_sections();
We don't need to always set must_sort_attached_input_sections for
.text. We only need to set it if we see a .text.unlikely, etc.,
section. Let's do that.
> + // If it is a text section use the following order:
> + // .text.unlikely, .text.startup, .text.hot, and .text
> + // In some cases one prefix is itself a prefix of another prefix; in
> + // such a case the longer prefix must come first below.
The last sentence is only there because .text is in the list, but it's
not clear to me why .text is in the list. What happens if you simply
omit it?
> s1_group_index = s2_group_index = num_prefixes;
Write two separate assignments, please.
Ian