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