aboutsummaryrefslogtreecommitdiffstats
path: root/tools/objtool/check.h
diff options
context:
space:
mode:
authorVasily Gorbik <gor@linux.ibm.com>2020-11-13 00:03:32 +0100
committerJosh Poimboeuf <jpoimboe@redhat.com>2021-01-13 18:13:14 -0600
commit7786032e52cb02982a7154993b5d88c9c7a31ba5 (patch)
tree0a18fd08e9856972d2a5ab49d3b731f4aff9c92f /tools/objtool/check.h
parentobjtool: Fix x86 orc generation on big endian cross-compiles (diff)
downloadlinux-dev-7786032e52cb02982a7154993b5d88c9c7a31ba5.tar.xz
linux-dev-7786032e52cb02982a7154993b5d88c9c7a31ba5.zip
objtool: Rework header include paths
Currently objtool headers are being included either by their base name or included via ../ from a parent directory. In case of a base name usage: #include "warn.h" #include "arch_elf.h" it does not make it apparent from which directory the file comes from. To make it slightly better, and actually to avoid name clashes some arch specific files have "arch_" suffix. And files from an arch folder have to revert to including via ../ e.g: #include "../../elf.h" With additional architectures support and the code base growth there is a need for clearer headers naming scheme for multiple reasons: 1. to make it instantly obvious where these files come from (objtool itself / objtool arch|generic folders / some other external files), 2. to avoid name clashes of objtool arch specific headers, potential obtool arch generic headers and the system header files (there is /usr/include/elf.h already), 3. to avoid ../ includes and improve code readability. 4. to give a warm fuzzy feeling to developers who are mostly kernel developers and are accustomed to linux kernel headers arranging scheme. Doesn't this make it instantly obvious where are these files come from? #include <objtool/warn.h> #include <arch/elf.h> And doesn't it look nicer to avoid ugly ../ includes? Which also guarantees this is elf.h from the objtool and not /usr/include/elf.h. #include <objtool/elf.h> This patch defines and implements new objtool headers arranging scheme. Which is: - all generic headers go to include/objtool (similar to include/linux) - all arch headers go to arch/$(SRCARCH)/include/arch (to get arch prefix). This is similar to linux arch specific "asm/*" headers but we are not abusing "asm" name and calling it what it is. This also helps to prevent name clashes (arch is not used in system headers or kernel exports). To bring objtool to this state the following things are done: 1. current top level tools/objtool/ headers are moved into include/objtool/ subdirectory, 2. arch specific headers, currently only arch/x86/include/ are moved into arch/x86/include/arch/ and were stripped of "arch_" suffix, 3. new -I$(srctree)/tools/objtool/include include path to make includes like <objtool/warn.h> possible, 4. rewriting file includes, 5. make git not to ignore include/objtool/ subdirectory. Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Diffstat (limited to 'tools/objtool/check.h')
-rw-r--r--tools/objtool/check.h69
1 files changed, 0 insertions, 69 deletions
diff --git a/tools/objtool/check.h b/tools/objtool/check.h
deleted file mode 100644
index 5ec00a4b891b..000000000000
--- a/tools/objtool/check.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com>
- */
-
-#ifndef _CHECK_H
-#define _CHECK_H
-
-#include <stdbool.h>
-#include "cfi.h"
-#include "arch.h"
-
-struct insn_state {
- struct cfi_state cfi;
- unsigned int uaccess_stack;
- bool uaccess;
- bool df;
- bool noinstr;
- s8 instr;
-};
-
-struct instruction {
- struct list_head list;
- struct hlist_node hash;
- struct list_head static_call_node;
- struct section *sec;
- unsigned long offset;
- unsigned int len;
- enum insn_type type;
- unsigned long immediate;
- bool dead_end, ignore, ignore_alts;
- bool hint;
- bool retpoline_safe;
- s8 instr;
- u8 visited;
- u8 ret_offset;
- int alt_group;
- struct symbol *call_dest;
- struct instruction *jump_dest;
- struct instruction *first_jump_src;
- struct reloc *jump_table;
- struct list_head alts;
- struct symbol *func;
- struct list_head stack_ops;
- struct cfi_state cfi;
-#ifdef INSN_USE_ORC
- struct orc_entry orc;
-#endif
-};
-
-static inline bool is_static_jump(struct instruction *insn)
-{
- return insn->type == INSN_JUMP_CONDITIONAL ||
- insn->type == INSN_JUMP_UNCONDITIONAL;
-}
-
-struct instruction *find_insn(struct objtool_file *file,
- struct section *sec, unsigned long offset);
-
-#define for_each_insn(file, insn) \
- list_for_each_entry(insn, &file->insn_list, list)
-
-#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))
-
-#endif /* _CHECK_H */