[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251119143247.3944213-19-alexandre.chartre@oracle.com>
Date: Wed, 19 Nov 2025 15:32:35 +0100
From: Alexandre Chartre <alexandre.chartre@...cle.com>
To: linux-kernel@...r.kernel.org, mingo@...nel.org, jpoimboe@...nel.org,
peterz@...radead.org, david.laight.linux@...il.com
Cc: alexandre.chartre@...cle.com
Subject: [PATCH v5 18/30] objtool: Preserve alternatives order
Preserve the order in which alternatives are defined. Currently
objtool stores alternatives in a list in reverse order.
Signed-off-by: Alexandre Chartre <alexandre.chartre@...cle.com>
---
tools/objtool/check.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 5bb932f211f6b..25839c3950a3c 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1942,6 +1942,7 @@ static int add_special_section_alts(struct objtool_file *file)
struct special_alt *special_alt, *tmp;
enum alternative_type alt_type;
struct alternative *alt;
+ struct alternative *a;
if (special_get_alts(file->elf, &special_alts))
return -1;
@@ -1994,9 +1995,20 @@ static int add_special_section_alts(struct objtool_file *file)
}
alt->insn = new_insn;
- alt->next = orig_insn->alts;
alt->type = alt_type;
- orig_insn->alts = alt;
+ alt->next = NULL;
+
+ /*
+ * Store alternatives in the same order they have been
+ * defined.
+ */
+ if (!orig_insn->alts) {
+ orig_insn->alts = alt;
+ } else {
+ for (a = orig_insn->alts; a->next; a = a->next)
+ ;
+ a->next = alt;
+ }
list_del(&special_alt->list);
free(special_alt);
--
2.43.5
Powered by blists - more mailing lists