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