From: "Madhavan T. Venkataraman" <madvenka@xxxxxxxxxxxxxxxxxxx> Add CFI definitions and Endianness for ARM64. Add DYNAMIC_CHECK option for ARM64. Provide stubs for arch_decode_instructions() and check() just to get Objtool to build on ARM64. Signed-off-by: Madhavan T. Venkataraman <madvenka@xxxxxxxxxxxxxxxxxxx> --- tools/objtool/Build | 1 + tools/objtool/Makefile | 6 +++++- tools/objtool/arch/arm64/Build | 1 + tools/objtool/arch/arm64/decode.c | 21 +++++++++++++++++++ .../arch/arm64/include/arch/cfi_regs.h | 13 ++++++++++++ .../arch/arm64/include/arch/endianness.h | 9 ++++++++ tools/objtool/dcheck.c | 16 ++++++++++++++ 7 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 tools/objtool/arch/arm64/Build create mode 100644 tools/objtool/arch/arm64/decode.c create mode 100644 tools/objtool/arch/arm64/include/arch/cfi_regs.h create mode 100644 tools/objtool/arch/arm64/include/arch/endianness.h create mode 100644 tools/objtool/dcheck.c diff --git a/tools/objtool/Build b/tools/objtool/Build index 974290dc4aac..fb0846b7d95e 100644 --- a/tools/objtool/Build +++ b/tools/objtool/Build @@ -4,6 +4,7 @@ objtool-y += weak.o objtool-$(STATIC_CHECK) += check.o objtool-$(STATIC_CHECK) += special.o +objtool-$(DYNAMIC_CHECK) += dcheck.o objtool-y += builtin-check.o objtool-y += cfi.o objtool-y += insn.o diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index 797d1ea02db0..92583b82eb78 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -46,7 +46,11 @@ ifeq ($(SRCARCH),x86) STATIC_CHECK := y endif -export BUILD_ORC STATIC_CHECK +ifeq ($(SRCARCH),arm64) + DYNAMIC_CHECK := y +endif + +export BUILD_ORC STATIC_CHECK DYNAMIC_CHECK export srctree OUTPUT CFLAGS SRCARCH AWK include $(srctree)/tools/build/Makefile.include diff --git a/tools/objtool/arch/arm64/Build b/tools/objtool/arch/arm64/Build new file mode 100644 index 000000000000..3ff1f00c6a47 --- /dev/null +++ b/tools/objtool/arch/arm64/Build @@ -0,0 +1 @@ +objtool-y += decode.o diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/decode.c new file mode 100644 index 000000000000..69f851337537 --- /dev/null +++ b/tools/objtool/arch/arm64/decode.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Author: Madhavan T. Venkataraman (madvenka@xxxxxxxxxxxxxxxxxxx) + * + * Copyright (C) 2022 Microsoft Corporation + */ + +#include <stdio.h> +#include <stdlib.h> + +#include <objtool/check.h> + +int arch_decode_instruction(struct objtool_file *file, + 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) +{ + return 0; +} diff --git a/tools/objtool/arch/arm64/include/arch/cfi_regs.h b/tools/objtool/arch/arm64/include/arch/cfi_regs.h new file mode 100644 index 000000000000..cff3b04d7248 --- /dev/null +++ b/tools/objtool/arch/arm64/include/arch/cfi_regs.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _OBJTOOL_CFI_REGS_H +#define _OBJTOOL_CFI_REGS_H + +#define CFI_FP 29 +#define CFI_BP CFI_FP +#define CFI_RA 30 +#define CFI_SP 31 + +#define CFI_NUM_REGS 32 + +#endif /* _OBJTOOL_CFI_REGS_H */ diff --git a/tools/objtool/arch/arm64/include/arch/endianness.h b/tools/objtool/arch/arm64/include/arch/endianness.h new file mode 100644 index 000000000000..7c362527da20 --- /dev/null +++ b/tools/objtool/arch/arm64/include/arch/endianness.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _ARCH_ENDIANNESS_H +#define _ARCH_ENDIANNESS_H + +#include <endian.h> + +#define __TARGET_BYTE_ORDER __LITTLE_ENDIAN + +#endif /* _ARCH_ENDIANNESS_H */ diff --git a/tools/objtool/dcheck.c b/tools/objtool/dcheck.c new file mode 100644 index 000000000000..e2098c9ad282 --- /dev/null +++ b/tools/objtool/dcheck.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2015-2017 Josh Poimboeuf <jpoimboe@xxxxxxxxxx> + */ + +#include <string.h> +#include <stdlib.h> +#include <inttypes.h> +#include <sys/mman.h> + +#include <objtool/objtool.h> + +int check(struct objtool_file *file) +{ + return 0; +} -- 2.25.1