History

objtool: Identify the different types of alternatives

Alternative code, including jump table and exception table, is represented with the same struct alternative structure. But there is no obvious way to identify whether the struct represents alternative instructions, a jump table or an exception table. So add a type to struct alternative to clearly identify the type of alternative.

Alexandre Chartre committed 11 months ago

Commit d490aa21 parent 26a453f2 files · +20 −5Browse files

Unified · Split

2 files
  1. tools/objtool/check.c +8 −5
  2. tools/objtool/include/objtool/check.h +12 −0
tools/objtool/check.c+8−5
@@ -27,11 +27,6 @@ · 26 unmodified lines
2727 #include <linux/static_call_types.h>
2828 #include <linux/string.h>
2929
30−struct alternative {
31− struct alternative *next;
32− struct instruction *insn;
33−};
34−
3530 static unsigned long nr_cfi, nr_cfi_reused, nr_cfi_cache;
3631
3732 static struct cfi_init_state initial_func_cfi;
@@ -1924,6 +1919,7 @@ static int add_special_section_alts(struct objtool_file *file) · 1886 unmodified lines
19241919 struct list_head special_alts;
19251920 struct instruction *orig_insn, *new_insn;
19261921 struct special_alt *special_alt, *tmp;
1922+ enum alternative_type alt_type;
19271923 struct alternative *alt;
19281924
19291925 if (special_get_alts(file->elf, &special_alts))
@@ -1959,9 +1955,15 @@ static int add_special_section_alts(struct objtool_file *file) · 29 unmodified lines
19591955 if (handle_group_alt(file, special_alt, orig_insn, &new_insn))
19601956 return -1;
19611957
1958+ alt_type = ALT_TYPE_INSTRUCTIONS;
1959+
19621960 } else if (special_alt->jump_or_nop) {
19631961 if (handle_jump_alt(file, special_alt, orig_insn, &new_insn))
19641962 return -1;
1963+
1964+ alt_type = ALT_TYPE_JUMP_TABLE;
1965+ } else {
1966+ alt_type = ALT_TYPE_EX_TABLE;
19651967 }
19661968
19671969 alt = calloc(1, sizeof(*alt));
@@ -1972,6 +1974,7 @@ static int add_special_section_alts(struct objtool_file *file) · 4 unmodified lines
19721974
19731975 alt->insn = new_insn;
19741976 alt->next = orig_insn->alts;
1977+ alt->type = alt_type;
19751978 orig_insn->alts = alt;
19761979
19771980 list_del(&special_alt->list);
tools/objtool/include/objtool/check.h+12−0
@@ -38,6 +38,18 @@ struct alt_group { · 37 unmodified lines
3838 bool ignore;
3939 };
4040
41+enum alternative_type {
42+ ALT_TYPE_INSTRUCTIONS,
43+ ALT_TYPE_JUMP_TABLE,
44+ ALT_TYPE_EX_TABLE,
45+};
46+
47+struct alternative {
48+ struct alternative *next;
49+ struct instruction *insn;
50+ enum alternative_type type;
51+};
52+
4153 #define INSN_CHUNK_BITS 8
4254 #define INSN_CHUNK_SIZE (1 << INSN_CHUNK_BITS)
4355 #define INSN_CHUNK_MAX (INSN_CHUNK_SIZE - 1)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t