Blame 0103-create-diff-object-compare-section-name-with-kpatch_.patch

54dc0a
From 47d1b39ba7686e2368c1ad24af274dfd9f54ecf9 Mon Sep 17 00:00:00 2001
642cd7
From: Song Liu <songliubraving@fb.com>
642cd7
Date: Wed, 13 Oct 2021 00:10:20 -0700
f6c393
Subject: [PATCH 103/112] create-diff-object: compare section name with
642cd7
 kpatch_section_function_name
642cd7
642cd7
Profile-Guided Optimization (PGO) uses profiling data to help the compiler
642cd7
to evaluate the properties of a function, and thus adds different prefixes
642cd7
to the section/function. For example, with -ffunction-sections, the
642cd7
compiler will prefix some sectiones with .text.unlikely. However, if a
642cd7
function changes from the version in the profiling data, the compiler may
642cd7
ignore the profiling data. This often happens to the patched function
642cd7
when kpatch-build builds the patch. As a result, the original function
642cd7
and the patch function may have different prefix, i.e., one of them has
642cd7
.text, the other has .text.unlikely.
642cd7
642cd7
To correlate these functions properly, use kpatch_section_function_name()
642cd7
in kpatch_correlate_sections() to find matching sections.
642cd7
642cd7
Signed-off-by: Song Liu <songliubraving@fb.com>
642cd7
---
642cd7
 kpatch-build/create-diff-object.c | 7 +++++--
642cd7
 1 file changed, 5 insertions(+), 2 deletions(-)
642cd7
642cd7
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
54dc0a
index fec57b8..e88cb3b 100644
642cd7
--- a/kpatch-build/create-diff-object.c
642cd7
+++ b/kpatch-build/create-diff-object.c
54dc0a
@@ -1053,6 +1053,8 @@ static void kpatch_correlate_section(struct section *sec_orig,
642cd7
 		kpatch_correlate_symbol(sec_orig->sym, sec_patched->sym);
642cd7
 }
642cd7
 
642cd7
+static char *kpatch_section_function_name(struct section *sec);
642cd7
+
642cd7
 static void kpatch_correlate_sections(struct list_head *seclist_orig,
642cd7
 		struct list_head *seclist_patched)
642cd7
 {
54dc0a
@@ -1062,8 +1064,9 @@ static void kpatch_correlate_sections(struct list_head *seclist_orig,
642cd7
 		if (sec_orig->twin)
642cd7
 			continue;
642cd7
 		list_for_each_entry(sec_patched, seclist_patched, list) {
642cd7
-			if (kpatch_mangled_strcmp(sec_orig->name, sec_patched->name) ||
642cd7
-			    sec_patched->twin)
642cd7
+			if (sec_patched->twin ||
642cd7
+			    kpatch_mangled_strcmp(kpatch_section_function_name(sec_orig),
642cd7
+						  kpatch_section_function_name(sec_patched)))
642cd7
 				continue;
642cd7
 
54dc0a
 			if (is_ubsan_sec(sec_orig->name))
642cd7
-- 
f6c393
2.45.1
642cd7