summaryrefslogtreecommitdiffstats
path: root/tools/objtool/arch.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/arch.h
parent8bfe273238d77d3cee18e4c03b2f26ae360b5661 (diff)
downloadlinux-stable-7786032e52cb02982a7154993b5d88c9c7a31ba5.tar.gz
linux-stable-7786032e52cb02982a7154993b5d88c9c7a31ba5.tar.bz2
linux-stable-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/arch.h')
-rw-r--r--tools/objtool/arch.h93
1 files changed, 0 insertions, 93 deletions
diff --git a/tools/objtool/arch.h b/tools/objtool/arch.h
deleted file mode 100644
index 4a84c3081b8e..000000000000
--- a/tools/objtool/arch.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com>
- */
-
-#ifndef _ARCH_H
-#define _ARCH_H
-
-#include <stdbool.h>
-#include <linux/list.h>
-#include "objtool.h"
-#include "cfi.h"
-
-#ifdef INSN_USE_ORC
-#include <asm/orc_types.h>
-#endif
-
-enum insn_type {
- INSN_JUMP_CONDITIONAL,
- INSN_JUMP_UNCONDITIONAL,
- INSN_JUMP_DYNAMIC,
- INSN_JUMP_DYNAMIC_CONDITIONAL,
- INSN_CALL,
- INSN_CALL_DYNAMIC,
- INSN_RETURN,
- INSN_CONTEXT_SWITCH,
- INSN_BUG,
- INSN_NOP,
- INSN_STAC,
- INSN_CLAC,
- INSN_STD,
- INSN_CLD,
- INSN_OTHER,
-};
-
-enum op_dest_type {
- OP_DEST_REG,
- OP_DEST_REG_INDIRECT,
- OP_DEST_MEM,
- OP_DEST_PUSH,
- OP_DEST_PUSHF,
- OP_DEST_LEAVE,
-};
-
-struct op_dest {
- enum op_dest_type type;
- unsigned char reg;
- int offset;
-};
-
-enum op_src_type {
- OP_SRC_REG,
- OP_SRC_REG_INDIRECT,
- OP_SRC_CONST,
- OP_SRC_POP,
- OP_SRC_POPF,
- OP_SRC_ADD,
- OP_SRC_AND,
-};
-
-struct op_src {
- enum op_src_type type;
- unsigned char reg;
- int offset;
-};
-
-struct stack_op {
- struct op_dest dest;
- struct op_src src;
- struct list_head list;
-};
-
-struct instruction;
-
-void arch_initial_func_cfi_state(struct cfi_init_state *state);
-
-int arch_decode_instruction(const struct elf *elf, const struct section *sec,
- unsigned long offset, unsigned int maxlen,
- unsigned int *len, enum insn_type *type,
- unsigned long *immediate,
- struct list_head *ops_list);
-
-bool arch_callee_saved_reg(unsigned char reg);
-
-unsigned long arch_jump_destination(struct instruction *insn);
-
-unsigned long arch_dest_reloc_offset(int addend);
-
-const char *arch_nop_insn(int len);
-
-int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg);
-
-#endif /* _ARCH_H */