Blame SOURCES/create-diff-object-ignore-altrinstr-aux-backport.patch

02818e
From 46b54db1427ac7a58f986ae3506ce23c068d94e0 Mon Sep 17 00:00:00 2001
02818e
From: Josh Poimboeuf <jpoimboe@redhat.com>
02818e
Date: Tue, 23 Jun 2020 22:20:33 -0500
02818e
Subject: [PATCH] create-diff-object: change rela_equal() to return bool
02818e
02818e
Change rela_equal's return value to bool to make its return semantics
02818e
more clear.
02818e
02818e
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
02818e
02818e
create-diff-object: Ignore changes to .altinstr_aux
02818e
02818e
On x86, .altinstr_aux is used to store temporary code which allows
02818e
static_cpu_has() to work before apply_alternatives() has run.  This code
02818e
is completely inert for modules, because apply_alternatives() runs
02818e
during module init, before the module is fully formed.  Any changed
02818e
references to it (i.e. changed addend) can be ignored.  As long as
02818e
they're both references to .altinstr_aux, they can be considered equal,
02818e
even if the addends differ.
02818e
02818e
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
02818e
---
02818e
 kpatch-build/create-diff-object.c | 21 +++++++++++++++++----
02818e
 1 file changed, 17 insertions(+), 4 deletions(-)
02818e
02818e
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
02818e
index aedd07d..b7332b1 100644
02818e
--- a/kpatch-build/create-diff-object.c
02818e
+++ b/kpatch-build/create-diff-object.c
02818e
@@ -327,14 +327,27 @@ static int kpatch_mangled_strcmp(char *s1, char *s2)
02818e
 	return 1;
02818e
 }
02818e
 
02818e
-static int rela_equal(struct rela *rela1, struct rela *rela2)
02818e
+static bool rela_equal(struct rela *rela1, struct rela *rela2)
02818e
 {
02818e
 	struct rela *rela_toc1, *rela_toc2;
02818e
 	unsigned long toc_data1 = 0, toc_data2 = 0; /* = 0 to prevent gcc warning */
02818e
 
02818e
 	if (rela1->type != rela2->type ||
02818e
 	    rela1->offset != rela2->offset)
02818e
-		return 0;
02818e
+		return false;
02818e
+
02818e
+	/*
02818e
+	 * On x86, .altinstr_aux is used to store temporary code which allows
02818e
+	 * static_cpu_has() to work before apply_alternatives() has run.  This
02818e
+	 * code is completely inert for modules, because apply_alternatives()
02818e
+	 * runs during module init, before the module is fully formed.  Any
02818e
+	 * changed references to it (i.e. changed addend) can be ignored.  As
02818e
+	 * long as they're both references to .altinstr_aux, they can be
02818e
+	 * considered equal, even if the addends differ.
02818e
+	 */
02818e
+	if (!strcmp(rela1->sym->name, ".altinstr_aux") &&
02818e
+	    !strcmp(rela2->sym->name, ".altinstr_aux"))
02818e
+		return true;
02818e
 
02818e
 	/*
02818e
 	 * With -mcmodel=large on ppc64le, GCC might generate entries in the .toc
02818e
@@ -393,13 +406,13 @@ static int rela_equal(struct rela *rela1, struct rela *rela2)
02818e
 		return toc_data1 == toc_data2;
02818e
 
02818e
 	if (!rela_toc1 || !rela_toc2)
02818e
-		return 0;
02818e
+		return false;
02818e
 
02818e
 	if (rela_toc1->string)
02818e
 		return rela_toc2->string && !strcmp(rela_toc1->string, rela_toc2->string);
02818e
 
02818e
 	if (rela_toc1->addend != rela_toc2->addend)
02818e
-		return 0;
02818e
+		return false;
02818e
 
02818e
 	return !kpatch_mangled_strcmp(rela_toc1->sym->name, rela_toc2->sym->name);
02818e
 }
02818e
-- 
02818e
2.21.3
02818e