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

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