Map ".text.hot" and ".text.unlikely" input section prefixes to separate output sections.

Ian Lance Taylor iant@google.com
Tue Nov 20 15:13:00 GMT 2012


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



More information about the Binutils mailing list