Skip to content

Commit 13fab06

Browse files
achartrePeter Zijlstra
authored andcommitted
objtool: Uniquely identify alternative instruction groups
Assign a unique identifier to every alternative instruction group in order to be able to tell which instructions belong to what alternative. [peterz: extracted from a larger patch] Signed-off-by: Alexandre Chartre <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Miroslav Benes <[email protected]>
1 parent 9e98d62 commit 13fab06

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tools/objtool/check.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,9 @@ static int handle_group_alt(struct objtool_file *file,
752752
struct instruction *orig_insn,
753753
struct instruction **new_insn)
754754
{
755+
static unsigned int alt_group_next_index = 1;
755756
struct instruction *last_orig_insn, *last_new_insn, *insn, *fake_jump = NULL;
757+
unsigned int alt_group = alt_group_next_index++;
756758
unsigned long dest_off;
757759

758760
last_orig_insn = NULL;
@@ -761,7 +763,7 @@ static int handle_group_alt(struct objtool_file *file,
761763
if (insn->offset >= special_alt->orig_off + special_alt->orig_len)
762764
break;
763765

764-
insn->alt_group = true;
766+
insn->alt_group = alt_group;
765767
last_orig_insn = insn;
766768
}
767769

@@ -795,6 +797,7 @@ static int handle_group_alt(struct objtool_file *file,
795797
}
796798

797799
last_new_insn = NULL;
800+
alt_group = alt_group_next_index++;
798801
insn = *new_insn;
799802
sec_for_each_insn_from(file, insn) {
800803
if (insn->offset >= special_alt->new_off + special_alt->new_len)
@@ -804,6 +807,7 @@ static int handle_group_alt(struct objtool_file *file,
804807

805808
insn->ignore = orig_insn->ignore_alts;
806809
insn->func = orig_insn->func;
810+
insn->alt_group = alt_group;
807811

808812
/*
809813
* Since alternative replacement code is copy/pasted by the

tools/objtool/check.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ struct instruction {
3030
unsigned int len;
3131
enum insn_type type;
3232
unsigned long immediate;
33-
bool alt_group, dead_end, ignore, ignore_alts;
33+
bool dead_end, ignore, ignore_alts;
3434
bool hint;
3535
bool retpoline_safe;
3636
s8 instr;
3737
u8 visited;
3838
u8 ret_offset;
39+
int alt_group;
3940
struct symbol *call_dest;
4041
struct instruction *jump_dest;
4142
struct instruction *first_jump_src;

0 commit comments

Comments
 (0)