diff --git a/tools/objtool/arch.h b/tools/objtool/arch.h index 540331850a865cc9fa16a0942bc00ec24dda64cb..00c14786d2622717808ea4d6577ce58da80d3cc1 100644 --- a/tools/objtool/arch.h +++ b/tools/objtool/arch.h @@ -72,6 +72,8 @@ struct stack_op { struct instruction; +void get_arch(const struct elf *elf); + void arch_initial_func_cfi_state(struct cfi_init_state *state); int arch_decode_instruction(const struct elf *elf, const struct section *sec, diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index 3853a413abcf7d973541edd1ab670bb314cfed9b..6599b0f31552d10e958a6def0f3d30d7de886f82 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -32,19 +32,31 @@ int arch_offset; int x8664bit; static int is_x86_64(const struct elf *elf) +{ + switch (elf->ehdr.e_machine) { + case EM_X86_64: + return 1; + case EM_386: + return 0; + default: + WARN("unexpected ELF machine type %d", elf->ehdr.e_machine); + return -1; + } +} + +void get_arch(const struct elf *elf) { switch (elf->ehdr.e_machine) { case EM_X86_64: arch_offset = 8; x8664bit = 1; - return 1; + break; case EM_386: arch_offset = 4; x8664bit = 0; - return 0; + break; default: WARN("unexpected ELF machine type %d", elf->ehdr.e_machine); - return -1; } } diff --git a/tools/objtool/check.c b/tools/objtool/check.c index f7bc480083af69a3ab2002a31816e39fbd8f71dc..4e1ab4d377c04b3254a65485a1e0e84554074c7f 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2920,6 +2920,8 @@ int check(struct objtool_file *file) { int ret, warnings = 0; + get_arch(file->elf); + arch_initial_func_cfi_state(&initial_func_cfi); ret = decode_sections(file);