objtool: Support GCC 9 cold subfunction naming scheme [Linux 4.14.137]

This Linux kernel change "objtool: Support GCC 9 cold subfunction naming scheme" is included in the Linux 4.14.137 release. This change is authored by Josh Poimboeuf <jpoimboe [at] redhat.com> on Wed Oct 31 21:57:30 2018 -0500. The commit for this change in Linux stable tree is a22c637 (patch) which is from upstream commit bcb6fb5. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream bcb6fb5.

objtool: Support GCC 9 cold subfunction naming scheme

commit bcb6fb5da77c2a228adf07cc9cb1a0c2aa2001c6 upstream.

Starting with GCC 8, a lot of unlikely code was moved out of line to
"cold" subfunctions in .text.unlikely.

For example, the unlikely bits of:

  irq_do_set_affinity()

are moved out to the following subfunction:

  irq_do_set_affinity.cold.49()

Starting with GCC 9, the numbered suffix has been removed.  So in the
above example, the cold subfunction is instead:

  irq_do_set_affinity.cold()

Tweak the objtool subfunction detection logic so that it detects both
GCC 8 and GCC 9 naming schemes.

Reported-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/015e9544b1f188d36a7f02fa31e9e95629aa5f50.1541040800.git.jpoimboe@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 tools/objtool/elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index e6cef5a..d089c71 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -305,7 +305,7 @@ static int read_symbols(struct elf *elf)
            if (sym->type != STT_FUNC)
                continue;
            sym->pfunc = sym->cfunc = sym;
-           coldstr = strstr(sym->name, ".cold.");
+           coldstr = strstr(sym->name, ".cold");
            if (!coldstr)
                continue;

Leave a Reply

Your email address will not be published. Required fields are marked *