diff options
author | Vasily Gorbik <gor@linux.ibm.com> | 2020-11-13 00:03:32 +0100 |
---|---|---|
committer | Josh Poimboeuf <jpoimboe@redhat.com> | 2021-01-13 18:13:14 -0600 |
commit | 7786032e52cb02982a7154993b5d88c9c7a31ba5 (patch) | |
tree | 0a18fd08e9856972d2a5ab49d3b731f4aff9c92f /tools/objtool | |
parent | 8bfe273238d77d3cee18e4c03b2f26ae360b5661 (diff) |
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')
-rw-r--r-- | tools/objtool/.gitignore | 2 | ||||
-rw-r--r-- | tools/objtool/Makefile | 1 | ||||
-rw-r--r-- | tools/objtool/arch/x86/decode.c | 8 | ||||
-rw-r--r-- | tools/objtool/arch/x86/include/arch/cfi_regs.h (renamed from tools/objtool/arch/x86/include/cfi_regs.h) | 0 | ||||
-rw-r--r-- | tools/objtool/arch/x86/include/arch/elf.h (renamed from tools/objtool/arch/x86/include/arch_elf.h) | 0 | ||||
-rw-r--r-- | tools/objtool/arch/x86/include/arch/endianness.h (renamed from tools/objtool/arch/x86/include/arch_endianness.h) | 0 | ||||
-rw-r--r-- | tools/objtool/arch/x86/include/arch/special.h (renamed from tools/objtool/arch/x86/include/arch_special.h) | 0 | ||||
-rw-r--r-- | tools/objtool/arch/x86/special.c | 4 | ||||
-rw-r--r-- | tools/objtool/builtin-check.c | 4 | ||||
-rw-r--r-- | tools/objtool/builtin-orc.c | 4 | ||||
-rw-r--r-- | tools/objtool/check.c | 16 | ||||
-rw-r--r-- | tools/objtool/elf.c | 6 | ||||
-rw-r--r-- | tools/objtool/include/objtool/arch.h (renamed from tools/objtool/arch.h) | 4 | ||||
-rw-r--r-- | tools/objtool/include/objtool/builtin.h (renamed from tools/objtool/builtin.h) | 0 | ||||
-rw-r--r-- | tools/objtool/include/objtool/cfi.h (renamed from tools/objtool/cfi.h) | 2 | ||||
-rw-r--r-- | tools/objtool/include/objtool/check.h (renamed from tools/objtool/check.h) | 4 | ||||
-rw-r--r-- | tools/objtool/include/objtool/elf.h (renamed from tools/objtool/elf.h) | 0 | ||||
-rw-r--r-- | tools/objtool/include/objtool/endianness.h (renamed from tools/objtool/endianness.h) | 2 | ||||
-rw-r--r-- | tools/objtool/include/objtool/objtool.h (renamed from tools/objtool/objtool.h) | 2 | ||||
-rw-r--r-- | tools/objtool/include/objtool/special.h (renamed from tools/objtool/special.h) | 4 | ||||
-rw-r--r-- | tools/objtool/include/objtool/warn.h (renamed from tools/objtool/warn.h) | 2 | ||||
-rw-r--r-- | tools/objtool/objtool.c | 6 | ||||
-rw-r--r-- | tools/objtool/orc_dump.c | 6 | ||||
-rw-r--r-- | tools/objtool/orc_gen.c | 6 | ||||
-rw-r--r-- | tools/objtool/special.c | 10 | ||||
-rw-r--r-- | tools/objtool/weak.c | 2 |
26 files changed, 48 insertions, 47 deletions
diff --git a/tools/objtool/.gitignore b/tools/objtool/.gitignore index 45cefda24c7b..14236db3677f 100644 --- a/tools/objtool/.gitignore +++ b/tools/objtool/.gitignore @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only arch/x86/lib/inat-tables.c -objtool +/objtool fixdep diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index 5cdb19036d7f..d179299980b9 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -27,6 +27,7 @@ all: $(OBJTOOL) INCLUDES := -I$(srctree)/tools/include \ -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ -I$(srctree)/tools/arch/$(SRCARCH)/include \ + -I$(srctree)/tools/objtool/include \ -I$(srctree)/tools/objtool/arch/$(SRCARCH)/include WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index cde9c36e40ae..6baa22732ca6 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -11,11 +11,11 @@ #include "../../../arch/x86/lib/inat.c" #include "../../../arch/x86/lib/insn.c" -#include "../../check.h" -#include "../../elf.h" -#include "../../arch.h" -#include "../../warn.h" #include <asm/orc_types.h> +#include <objtool/check.h> +#include <objtool/elf.h> +#include <objtool/arch.h> +#include <objtool/warn.h> static unsigned char op_to_cfi_reg[][2] = { {CFI_AX, CFI_R8}, diff --git a/tools/objtool/arch/x86/include/cfi_regs.h b/tools/objtool/arch/x86/include/arch/cfi_regs.h index 79bc517efba8..79bc517efba8 100644 --- a/tools/objtool/arch/x86/include/cfi_regs.h +++ b/tools/objtool/arch/x86/include/arch/cfi_regs.h diff --git a/tools/objtool/arch/x86/include/arch_elf.h b/tools/objtool/arch/x86/include/arch/elf.h index 69cc4264b28a..69cc4264b28a 100644 --- a/tools/objtool/arch/x86/include/arch_elf.h +++ b/tools/objtool/arch/x86/include/arch/elf.h diff --git a/tools/objtool/arch/x86/include/arch_endianness.h b/tools/objtool/arch/x86/include/arch/endianness.h index 7c362527da20..7c362527da20 100644 --- a/tools/objtool/arch/x86/include/arch_endianness.h +++ b/tools/objtool/arch/x86/include/arch/endianness.h diff --git a/tools/objtool/arch/x86/include/arch_special.h b/tools/objtool/arch/x86/include/arch/special.h index d818b2bffa02..d818b2bffa02 100644 --- a/tools/objtool/arch/x86/include/arch_special.h +++ b/tools/objtool/arch/x86/include/arch/special.h diff --git a/tools/objtool/arch/x86/special.c b/tools/objtool/arch/x86/special.c index fd4af88c0ea5..b4bd3505fc94 100644 --- a/tools/objtool/arch/x86/special.c +++ b/tools/objtool/arch/x86/special.c @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include <string.h> -#include "../../special.h" -#include "../../builtin.h" +#include <objtool/special.h> +#include <objtool/builtin.h> #define X86_FEATURE_POPCNT (4 * 32 + 23) #define X86_FEATURE_SMAP (9 * 32 + 20) diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index c6d199bfd0ae..f47951e19c9d 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -15,8 +15,8 @@ #include <subcmd/parse-options.h> #include <string.h> -#include "builtin.h" -#include "objtool.h" +#include <objtool/builtin.h> +#include <objtool/objtool.h> bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats, validate_dup, vmlinux; diff --git a/tools/objtool/builtin-orc.c b/tools/objtool/builtin-orc.c index 7b31121fa60b..6745f3328a0e 100644 --- a/tools/objtool/builtin-orc.c +++ b/tools/objtool/builtin-orc.c @@ -13,8 +13,8 @@ */ #include <string.h> -#include "builtin.h" -#include "objtool.h" +#include <objtool/builtin.h> +#include <objtool/objtool.h> static const char *orc_usage[] = { "objtool orc generate [<options>] file.o", diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 8cda0ef06522..8976047cb648 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -6,14 +6,14 @@ #include <string.h> #include <stdlib.h> -#include "builtin.h" -#include "cfi.h" -#include "arch.h" -#include "check.h" -#include "special.h" -#include "warn.h" -#include "arch_elf.h" -#include "endianness.h" +#include <arch/elf.h> +#include <objtool/builtin.h> +#include <objtool/cfi.h> +#include <objtool/arch.h> +#include <objtool/check.h> +#include <objtool/special.h> +#include <objtool/warn.h> +#include <objtool/endianness.h> #include <linux/objtool.h> #include <linux/hashtable.h> diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index c784122b7ecb..43714ecd09f7 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -15,10 +15,10 @@ #include <string.h> #include <unistd.h> #include <errno.h> -#include "builtin.h" +#include <objtool/builtin.h> -#include "elf.h" -#include "warn.h" +#include <objtool/elf.h> +#include <objtool/warn.h> #define MAX_NAME_LEN 128 diff --git a/tools/objtool/arch.h b/tools/objtool/include/objtool/arch.h index 4a84c3081b8e..dc4f503a3ae4 100644 --- a/tools/objtool/arch.h +++ b/tools/objtool/include/objtool/arch.h @@ -8,8 +8,8 @@ #include <stdbool.h> #include <linux/list.h> -#include "objtool.h" -#include "cfi.h" +#include <objtool/objtool.h> +#include <objtool/cfi.h> #ifdef INSN_USE_ORC #include <asm/orc_types.h> diff --git a/tools/objtool/builtin.h b/tools/objtool/include/objtool/builtin.h index 85c979caa367..85c979caa367 100644 --- a/tools/objtool/builtin.h +++ b/tools/objtool/include/objtool/builtin.h diff --git a/tools/objtool/cfi.h b/tools/objtool/include/objtool/cfi.h index c7c59c6a44ee..fd5cb0bed9bf 100644 --- a/tools/objtool/cfi.h +++ b/tools/objtool/include/objtool/cfi.h @@ -6,7 +6,7 @@ #ifndef _OBJTOOL_CFI_H #define _OBJTOOL_CFI_H -#include "cfi_regs.h" +#include <arch/cfi_regs.h> #define CFI_UNDEFINED -1 #define CFI_CFA -2 diff --git a/tools/objtool/check.h b/tools/objtool/include/objtool/check.h index 5ec00a4b891b..bba10968eac0 100644 --- a/tools/objtool/check.h +++ b/tools/objtool/include/objtool/check.h @@ -7,8 +7,8 @@ #define _CHECK_H #include <stdbool.h> -#include "cfi.h" -#include "arch.h" +#include <objtool/cfi.h> +#include <objtool/arch.h> struct insn_state { struct cfi_state cfi; diff --git a/tools/objtool/elf.h b/tools/objtool/include/objtool/elf.h index e6890cc70a25..e6890cc70a25 100644 --- a/tools/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h diff --git a/tools/objtool/endianness.h b/tools/objtool/include/objtool/endianness.h index ebece3191b58..10241341eff3 100644 --- a/tools/objtool/endianness.h +++ b/tools/objtool/include/objtool/endianness.h @@ -2,9 +2,9 @@ #ifndef _OBJTOOL_ENDIANNESS_H #define _OBJTOOL_ENDIANNESS_H +#include <arch/endianness.h> #include <linux/kernel.h> #include <endian.h> -#include "arch_endianness.h" #ifndef __TARGET_BYTE_ORDER #error undefined arch __TARGET_BYTE_ORDER diff --git a/tools/objtool/objtool.h b/tools/objtool/include/objtool/objtool.h index 4125d4578b23..32f4cd1da9fa 100644 --- a/tools/objtool/objtool.h +++ b/tools/objtool/include/objtool/objtool.h @@ -10,7 +10,7 @@ #include <linux/list.h> #include <linux/hashtable.h> -#include "elf.h" +#include <objtool/elf.h> #define __weak __attribute__((weak)) diff --git a/tools/objtool/special.h b/tools/objtool/include/objtool/special.h index abddf38ef334..8a09f4e9d480 100644 --- a/tools/objtool/special.h +++ b/tools/objtool/include/objtool/special.h @@ -7,8 +7,8 @@ #define _SPECIAL_H #include <stdbool.h> -#include "check.h" -#include "elf.h" +#include <objtool/check.h> +#include <objtool/elf.h> #define C_JUMP_TABLE_SECTION ".rodata..c_jump_table" diff --git a/tools/objtool/warn.h b/tools/objtool/include/objtool/warn.h index 7799f60de80a..d99c4675e4a5 100644 --- a/tools/objtool/warn.h +++ b/tools/objtool/include/objtool/warn.h @@ -11,7 +11,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> -#include "elf.h" +#include <objtool/elf.h> extern const char *objname; diff --git a/tools/objtool/objtool.c b/tools/objtool/objtool.c index 9df0cd86d310..e848feb0a5fc 100644 --- a/tools/objtool/objtool.c +++ b/tools/objtool/objtool.c @@ -21,9 +21,9 @@ #include <subcmd/pager.h> #include <linux/kernel.h> -#include "builtin.h" -#include "objtool.h" -#include "warn.h" +#include <objtool/builtin.h> +#include <objtool/objtool.h> +#include <objtool/warn.h> struct cmd_struct { const char *name; diff --git a/tools/objtool/orc_dump.c b/tools/objtool/orc_dump.c index 4e818a22e44b..c53fae9dbe93 100644 --- a/tools/objtool/orc_dump.c +++ b/tools/objtool/orc_dump.c @@ -6,9 +6,9 @@ #include <unistd.h> #include <linux/objtool.h> #include <asm/orc_types.h> -#include "objtool.h" -#include "warn.h" -#include "endianness.h" +#include <objtool/objtool.h> +#include <objtool/warn.h> +#include <objtool/endianness.h> static const char *reg_name(unsigned int reg) { diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c index 1be7e16b2595..2e5fb787a382 100644 --- a/tools/objtool/orc_gen.c +++ b/tools/objtool/orc_gen.c @@ -9,9 +9,9 @@ #include <linux/objtool.h> #include <asm/orc_types.h> -#include "check.h" -#include "warn.h" -#include "endianness.h" +#include <objtool/check.h> +#include <objtool/warn.h> +#include <objtool/endianness.h> int create_orc(struct objtool_file *file) { diff --git a/tools/objtool/special.c b/tools/objtool/special.c index ab7cb1e13411..2c7fbda7b055 100644 --- a/tools/objtool/special.c +++ b/tools/objtool/special.c @@ -11,11 +11,11 @@ #include <stdlib.h> #include <string.h> -#include "builtin.h" -#include "special.h" -#include "warn.h" -#include "arch_special.h" -#include "endianness.h" +#include <arch/special.h> +#include <objtool/builtin.h> +#include <objtool/special.h> +#include <objtool/warn.h> +#include <objtool/endianness.h> struct special_entry { const char *sec; diff --git a/tools/objtool/weak.c b/tools/objtool/weak.c index 7843e9a7a72f..f2716827cc30 100644 --- a/tools/objtool/weak.c +++ b/tools/objtool/weak.c @@ -7,7 +7,7 @@ #include <stdbool.h> #include <errno.h> -#include "objtool.h" +#include <objtool/objtool.h> #define UNSUPPORTED(name) \ ({ \ |