2019-05-19 15:51:43 +02:00
/* SPDX-License-Identifier: GPL-2.0-or-later */
2017-06-28 10:11:05 -05:00
/*
* Copyright ( C ) 2017 Josh Poimboeuf < jpoimboe @ redhat . com >
*/
# ifndef _CHECK_H
# define _CHECK_H
# include <stdbool.h>
2017-06-28 10:11:07 -05:00
# include "cfi.h"
2017-06-28 10:11:05 -05:00
# include "arch.h"
2017-06-28 10:11:07 -05:00
struct insn_state {
2020-03-25 14:04:45 +01:00
struct cfi_state cfi ;
2019-02-25 12:50:09 +01:00
unsigned int uaccess_stack ;
2020-03-25 14:04:45 +01:00
bool uaccess ;
bool df ;
2020-03-10 18:57:41 +01:00
bool noinstr ;
s8 instr ;
2017-06-28 10:11:07 -05:00
} ;
2017-06-28 10:11:05 -05:00
struct instruction {
struct list_head list ;
struct hlist_node hash ;
2020-08-18 15:57:45 +02:00
struct list_head static_call_node ;
2017-06-28 10:11:05 -05:00
struct section * sec ;
unsigned long offset ;
2017-06-28 10:11:07 -05:00
unsigned int len ;
2019-07-17 20:36:56 -05:00
enum insn_type type ;
2017-06-28 10:11:05 -05:00
unsigned long immediate ;
2020-04-14 12:36:11 +02:00
bool dead_end , ignore , ignore_alts ;
2020-04-01 16:54:26 +02:00
bool hint ;
2018-01-16 10:24:06 +01:00
bool retpoline_safe ;
2020-03-10 18:57:41 +01:00
s8 instr ;
2019-07-24 17:47:26 -05:00
u8 visited ;
2020-04-01 16:38:19 +02:00
u8 ret_offset ;
2020-04-14 12:36:11 +02:00
int alt_group ;
2017-06-28 10:11:05 -05:00
struct symbol * call_dest ;
struct instruction * jump_dest ;
2018-02-08 14:02:32 +01:00
struct instruction * first_jump_src ;
objtool: Rename rela to reloc
Before supporting additional relocation types rename the relevant
types and functions from "rela" to "reloc". This work be done with
the following regex:
sed -e 's/struct rela/struct reloc/g' \
-e 's/\([_\*]\)rela\(s\{0,1\}\)/\1reloc\2/g' \
-e 's/tmprela\(s\{0,1\}\)/tmpreloc\1/g' \
-e 's/relasec/relocsec/g' \
-e 's/rela_list/reloc_list/g' \
-e 's/rela_hash/reloc_hash/g' \
-e 's/add_rela/add_reloc/g' \
-e 's/rela->/reloc->/g' \
-e '/rela[,\.]/{ s/\([^\.>]\)rela\([\.,]\)/\1reloc\2/g ; }' \
-e 's/rela =/reloc =/g' \
-e 's/relas =/relocs =/g' \
-e 's/relas\[/relocs[/g' \
-e 's/relaname =/relocname =/g' \
-e 's/= rela\;/= reloc\;/g' \
-e 's/= relas\;/= relocs\;/g' \
-e 's/= relaname\;/= relocname\;/g' \
-e 's/, rela)/, reloc)/g' \
-e 's/\([ @]\)rela\([ "]\)/\1reloc\2/g' \
-e 's/ rela$/ reloc/g' \
-e 's/, relaname/, relocname/g' \
-e 's/sec->rela/sec->reloc/g' \
-e 's/(\(!\{0,1\}\)rela/(\1reloc/g' \
-i \
arch.h \
arch/x86/decode.c \
check.c \
check.h \
elf.c \
elf.h \
orc_gen.c \
special.c
Notable exceptions which complicate the regex include gelf_*
library calls and standard/expected section names which still use
"rela" because they encode the type of relocation expected. Also, keep
"rela" in the struct because it encodes a specific type of relocation
we currently expect.
It will eventually turn into a member of an anonymous union when a
susequent patch adds implicit addend, or "rel", relocation support.
Signed-off-by: Matt Helsley <mhelsley@vmware.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2020-05-29 14:01:13 -07:00
struct reloc * jump_table ;
2017-06-28 10:11:05 -05:00
struct list_head alts ;
struct symbol * func ;
2020-03-27 15:28:47 +00:00
struct list_head stack_ops ;
2020-03-25 14:04:45 +01:00
struct cfi_state cfi ;
2020-08-25 13:47:42 +01:00
# ifdef INSN_USE_ORC
2017-07-11 10:33:42 -05:00
struct orc_entry orc ;
2020-08-25 13:47:42 +01:00
# endif
2017-06-28 10:11:05 -05:00
} ;
2020-09-04 16:30:23 +01:00
static inline bool is_static_jump ( struct instruction * insn )
{
return insn - > type = = INSN_JUMP_CONDITIONAL | |
insn - > type = = INSN_JUMP_UNCONDITIONAL ;
}
2017-07-11 10:33:42 -05:00
struct instruction * find_insn ( struct objtool_file * file ,
struct section * sec , unsigned long offset ) ;
2017-06-28 10:11:05 -05:00
2017-06-28 10:11:07 -05:00
# define for_each_insn(file, insn) \
list_for_each_entry ( insn , & file - > insn_list , list )
2017-07-11 10:33:42 -05:00
# define sec_for_each_insn(file, sec, insn) \
for ( insn = find_insn ( file , sec , 0 ) ; \
insn & & & insn - > list ! = & file - > insn_list & & \
insn - > sec = = sec ; \
insn = list_next_entry ( insn , list ) )
2017-06-28 10:11:05 -05:00
# endif /* _CHECK_H */