Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://patch.msgid.link/20251121095340.464045-14-alexandre.chartre@oracle.com

authored by

Alexandre Chartre and committed by
Peter Zijlstra
d490aa21 26a453fb

+20 -5
+8 -5
tools/objtool/check.c
··· 27 27 #include <linux/static_call_types.h> 28 28 #include <linux/string.h> 29 29 30 - struct alternative { 31 - struct alternative *next; 32 - struct instruction *insn; 33 - }; 34 - 35 30 static unsigned long nr_cfi, nr_cfi_reused, nr_cfi_cache; 36 31 37 32 static struct cfi_init_state initial_func_cfi; ··· 1919 1924 struct list_head special_alts; 1920 1925 struct instruction *orig_insn, *new_insn; 1921 1926 struct special_alt *special_alt, *tmp; 1927 + enum alternative_type alt_type; 1922 1928 struct alternative *alt; 1923 1929 1924 1930 if (special_get_alts(file->elf, &special_alts)) ··· 1955 1959 if (handle_group_alt(file, special_alt, orig_insn, &new_insn)) 1956 1960 return -1; 1957 1961 1962 + alt_type = ALT_TYPE_INSTRUCTIONS; 1963 + 1958 1964 } else if (special_alt->jump_or_nop) { 1959 1965 if (handle_jump_alt(file, special_alt, orig_insn, &new_insn)) 1960 1966 return -1; 1967 + 1968 + alt_type = ALT_TYPE_JUMP_TABLE; 1969 + } else { 1970 + alt_type = ALT_TYPE_EX_TABLE; 1961 1971 } 1962 1972 1963 1973 alt = calloc(1, sizeof(*alt)); ··· 1974 1972 1975 1973 alt->insn = new_insn; 1976 1974 alt->next = orig_insn->alts; 1975 + alt->type = alt_type; 1977 1976 orig_insn->alts = alt; 1978 1977 1979 1978 list_del(&special_alt->list);
+12
tools/objtool/include/objtool/check.h
··· 38 38 bool ignore; 39 39 }; 40 40 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 + 41 53 #define INSN_CHUNK_BITS 8 42 54 #define INSN_CHUNK_SIZE (1 << INSN_CHUNK_BITS) 43 55 #define INSN_CHUNK_MAX (INSN_CHUNK_SIZE - 1)