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

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