2019-05-19 21:51:43 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2017-06-28 23:11:05 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CHECK_H
|
|
|
|
#define _CHECK_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2017-06-28 23:11:07 +08:00
|
|
|
#include "cfi.h"
|
2017-06-28 23:11:05 +08:00
|
|
|
#include "arch.h"
|
|
|
|
|
2017-06-28 23:11:07 +08:00
|
|
|
struct insn_state {
|
2020-03-25 21:04:45 +08:00
|
|
|
struct cfi_state cfi;
|
2019-02-25 19:50:09 +08:00
|
|
|
unsigned int uaccess_stack;
|
2020-03-25 21:04:45 +08:00
|
|
|
bool uaccess;
|
|
|
|
bool df;
|
2020-03-11 01:57:41 +08:00
|
|
|
bool noinstr;
|
|
|
|
s8 instr;
|
2017-06-28 23:11:07 +08:00
|
|
|
};
|
|
|
|
|
2017-06-28 23:11:05 +08:00
|
|
|
struct instruction {
|
|
|
|
struct list_head list;
|
|
|
|
struct hlist_node hash;
|
2020-08-18 21:57:45 +08:00
|
|
|
struct list_head static_call_node;
|
2017-06-28 23:11:05 +08:00
|
|
|
struct section *sec;
|
|
|
|
unsigned long offset;
|
2017-06-28 23:11:07 +08:00
|
|
|
unsigned int len;
|
2019-07-18 09:36:56 +08:00
|
|
|
enum insn_type type;
|
2017-06-28 23:11:05 +08:00
|
|
|
unsigned long immediate;
|
2020-04-14 18:36:11 +08:00
|
|
|
bool dead_end, ignore, ignore_alts;
|
2020-04-01 22:54:26 +08:00
|
|
|
bool hint;
|
2018-01-16 17:24:06 +08:00
|
|
|
bool retpoline_safe;
|
2020-03-11 01:57:41 +08:00
|
|
|
s8 instr;
|
2019-07-25 06:47:26 +08:00
|
|
|
u8 visited;
|
2020-04-01 22:38:19 +08:00
|
|
|
u8 ret_offset;
|
2020-04-14 18:36:11 +08:00
|
|
|
int alt_group;
|
2017-06-28 23:11:05 +08:00
|
|
|
struct symbol *call_dest;
|
|
|
|
struct instruction *jump_dest;
|
2018-02-08 21:02:32 +08: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-30 05:01:13 +08:00
|
|
|
struct reloc *jump_table;
|
2017-06-28 23:11:05 +08:00
|
|
|
struct list_head alts;
|
|
|
|
struct symbol *func;
|
2020-03-27 23:28:47 +08:00
|
|
|
struct list_head stack_ops;
|
2020-03-25 21:04:45 +08:00
|
|
|
struct cfi_state cfi;
|
2020-08-25 20:47:42 +08:00
|
|
|
#ifdef INSN_USE_ORC
|
2017-07-11 23:33:42 +08:00
|
|
|
struct orc_entry orc;
|
2020-08-25 20:47:42 +08:00
|
|
|
#endif
|
2017-06-28 23:11:05 +08:00
|
|
|
};
|
|
|
|
|
2020-09-04 23:30:23 +08:00
|
|
|
static inline bool is_static_jump(struct instruction *insn)
|
|
|
|
{
|
|
|
|
return insn->type == INSN_JUMP_CONDITIONAL ||
|
|
|
|
insn->type == INSN_JUMP_UNCONDITIONAL;
|
|
|
|
}
|
|
|
|
|
2017-07-11 23:33:42 +08:00
|
|
|
struct instruction *find_insn(struct objtool_file *file,
|
|
|
|
struct section *sec, unsigned long offset);
|
2017-06-28 23:11:05 +08:00
|
|
|
|
2017-06-28 23:11:07 +08:00
|
|
|
#define for_each_insn(file, insn) \
|
|
|
|
list_for_each_entry(insn, &file->insn_list, list)
|
|
|
|
|
2017-07-11 23:33:42 +08: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 23:11:05 +08:00
|
|
|
#endif /* _CHECK_H */
|