|
|
d465ec |
From c351828bf35121628461095eeb25ea2152e98d38 Mon Sep 17 00:00:00 2001
|
|
|
d465ec |
From: Josh Poimboeuf <jpoimboe@redhat.com>
|
|
|
d465ec |
Date: Mon, 21 Nov 2022 19:32:18 -0800
|
|
|
d465ec |
Subject: [PATCH] v0.9.7 backport: MR!1314 ("create-diff-object: fix
|
|
|
d465ec |
__UNIQUE_ID() variable correlation")
|
|
|
d465ec |
|
|
|
d465ec |
commit 901445a54fcecbd6852b79878e67153c5048602e
|
|
|
d465ec |
Author: Josh Poimboeuf <jpoimboe@redhat.com>
|
|
|
d465ec |
Date: Mon Nov 21 19:32:18 2022 -0800
|
|
|
d465ec |
|
|
|
d465ec |
create-diff-object: fix __UNIQUE_ID() variable correlation
|
|
|
d465ec |
|
|
|
d465ec |
kpatch_mangled_strcmp() only ignores the digits after the period, but in
|
|
|
d465ec |
the case of __UNIQUE_ID(), the symbol names have random digits before
|
|
|
d465ec |
the period due to the use of `__COUNTER__`. Make sure such symbols are
|
|
|
d465ec |
properly correlated.
|
|
|
d465ec |
|
|
|
d465ec |
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
|
|
|
d465ec |
|
|
|
d465ec |
Signed-off-by: Yannick Cote <ycote@redhat.com>
|
|
|
d465ec |
---
|
|
|
d465ec |
kpatch-build/create-diff-object.c | 32 +++++++++++++++++++++++++++++++
|
|
|
d465ec |
1 file changed, 32 insertions(+)
|
|
|
d465ec |
|
|
|
d465ec |
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
|
|
|
d465ec |
index 360441111c5e..7106b67cfd25 100644
|
|
|
d465ec |
--- a/kpatch-build/create-diff-object.c
|
|
|
d465ec |
+++ b/kpatch-build/create-diff-object.c
|
|
|
d465ec |
@@ -396,6 +396,35 @@ static bool has_digit_tail(char *tail)
|
|
|
d465ec |
return false;
|
|
|
d465ec |
}
|
|
|
d465ec |
|
|
|
d465ec |
+/*
|
|
|
d465ec |
+ * Hack for __UNIQUE_ID(). The following should match:
|
|
|
d465ec |
+ *
|
|
|
d465ec |
+ * __UNIQUE_ID_ddebug1131.186
|
|
|
d465ec |
+ * __UNIQUE_ID_ddebug1132.187
|
|
|
d465ec |
+ */
|
|
|
d465ec |
+static int __kpatch_unique_id_strcmp(char *s1, char *s2)
|
|
|
d465ec |
+{
|
|
|
d465ec |
+ /* match '__UNIQUE_ID_ddebug' */
|
|
|
d465ec |
+ while (*s1 == *s2) {
|
|
|
d465ec |
+ if (!*s1)
|
|
|
d465ec |
+ return 0;
|
|
|
d465ec |
+ s1++;
|
|
|
d465ec |
+ s2++;
|
|
|
d465ec |
+ }
|
|
|
d465ec |
+
|
|
|
d465ec |
+ /* skip digits before '.' or EOL */
|
|
|
d465ec |
+ while (isdigit(*s1))
|
|
|
d465ec |
+ s1++;
|
|
|
d465ec |
+ while (isdigit(*s2))
|
|
|
d465ec |
+ s2++;
|
|
|
d465ec |
+
|
|
|
d465ec |
+ if ((!*s1 || has_digit_tail(s1)) &&
|
|
|
d465ec |
+ (!*s2 || has_digit_tail(s2)))
|
|
|
d465ec |
+ return 0;
|
|
|
d465ec |
+
|
|
|
d465ec |
+ return 1;
|
|
|
d465ec |
+}
|
|
|
d465ec |
+
|
|
|
d465ec |
/*
|
|
|
d465ec |
* This is like strcmp, but for gcc-mangled symbols. It skips the comparison
|
|
|
d465ec |
* of any substring which consists of '.' followed by any number of digits.
|
|
|
d465ec |
@@ -409,6 +438,9 @@ static int kpatch_mangled_strcmp(char *s1, char *s2)
|
|
|
d465ec |
if (strstr(s1, ".str1."))
|
|
|
d465ec |
return strcmp(s1, s2);
|
|
|
d465ec |
|
|
|
d465ec |
+ if (!strncmp(s1, "__UNIQUE_ID_", 12))
|
|
|
d465ec |
+ return __kpatch_unique_id_strcmp(s1, s2);
|
|
|
d465ec |
+
|
|
|
d465ec |
while (*s1 == *s2) {
|
|
|
d465ec |
if (!*s1)
|
|
|
d465ec |
return 0;
|
|
|
d465ec |
--
|
|
|
d465ec |
2.38.1
|
|
|
d465ec |
|