xref: /linux/tools/objtool/include/objtool/special.h (revision a0acd94e3819fcd8346ae3c16df987e0fabb3128)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com>
4  */
5 
6 #ifndef _SPECIAL_H
7 #define _SPECIAL_H
8 
9 #include <stdbool.h>
10 #include <objtool/check.h>
11 #include <objtool/elf.h>
12 
13 #define C_JUMP_TABLE_SECTION ".data.rel.ro.c_jump_table"
14 
15 struct special_alt {
16 	struct list_head list;
17 
18 	bool group;
19 	bool jump_or_nop;
20 	u8 key_addend;
21 
22 	struct section *orig_sec;
23 	unsigned long orig_off;
24 
25 	struct section *new_sec;
26 	unsigned long new_off;
27 
28 	unsigned int orig_len, new_len, feature; /* group only */
29 };
30 
31 int special_get_alts(struct elf *elf, struct list_head *alts);
32 
33 void arch_handle_alternative(struct special_alt *alt);
34 
35 /*
36  * Should the reloc at @offset -- the "new" (replacement) field of a special
37  * section group entry -- be ignored?  The meaning of a zero-length replacement
38  * is arch specific, so the arch decides.
39  */
40 bool arch_alt_ignore_new_reloc(struct section *sec, unsigned long offset);
41 
42 bool arch_support_alt_relocation(struct special_alt *special_alt,
43 				 struct instruction *insn,
44 				 struct reloc *reloc);
45 struct reloc *arch_find_switch_table(struct objtool_file *file,
46 				     struct instruction *insn,
47 				     unsigned long *table_size);
48 const char *arch_cpu_feature_name(int feature_number);
49 
50 #endif /* _SPECIAL_H */
51