What does .text.unlikely mean in ELF object files?
Asked Answered
C

1

6

In my objdump -t output, I see the following two lines:

00000000000004d2 l     F .text.unlikely 00000000000000ec function-signature-goes-here [clone .cold.427]

and

00000000000018e0 g     F .text  0000000000000690 function-signature-goes-here

I know l means local and g means global. I also know that .text is a section, or a type of section, in an object file, containing compiled program instructions. But what is .text.unlikely? Assuming it's a different section (or type-of-section) from .text - what's the difference?

Chura answered 3/2, 2020 at 19:37 Comment(0)
H
9

In my GCC v5.4.0 manpage, I found the following switch:

-freorder-functions which says:

Reorder functions in the object file in order to improve code locality. This is implemented by using special subsections ".text.hot" for most frequently executed functions and ".text.unlikely" for unlikely executed functions. Reordering is done by the linker so object file format must support named sections and linker must place them in a reasonable way.

Also profile feedback must be available to make this option effective. See -fprofile-arcs for details.

Enabled at levels -O2, -O3, -Os.

Looks like the compiler was run with optimization flags or that switch for this binary, and functions are organized in subsections to optimize spatial locality.

Healy answered 3/2, 2020 at 21:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.