[PATCH v2 0/8] Add objtool and orc support for LoongArch

From: Tiezhu Yang
Date: Mon Oct 09 2023 - 09:03:20 EST


This version is based on 6.6-rc5, tested with the latest upstream
gcc and binutils (20231009), all of the objtool warnings have been
silenced.

The patches #5, #6 and #7 are based on the following objdump info:
the latest upstream gas of LoongArch replaces a pair of ADD32/64
and SUB32/64 with 32/64_PCREL, and the option -mrelax is used by
default, there are local labels for the branch and jump operation,
the reloc symbol is label + offset instead of section + offset.

The binutils should contain the following two commits:
(1) Use 32/64_PCREL to replace a pair of ADD32/64 and SUB32/64
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ecb802d02eeb
(2) as: add option for generate R_LARCH_32/64_PCREL
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=816029e06768

Tiezhu Yang (8):
objtool/LoongArch: Enable objtool to be built
objtool/LoongArch: Implement instruction decoder
objtool/x86: Separate arch-specific and generic parts
objtool/LoongArch: Enable orc to be built
objtool: Check local label about sibling call
objtool: Check local label in add_dead_ends()
objtool: Check local label in read_unwind_hints()
LoongArch: Add ORC unwinder support

arch/loongarch/Kconfig | 2 +
arch/loongarch/Kconfig.debug | 11 +
arch/loongarch/Makefile | 23 +
arch/loongarch/configs/loongson3_defconfig | 1 +
arch/loongarch/include/asm/Kbuild | 1 +
arch/loongarch/include/asm/bug.h | 1 +
arch/loongarch/include/asm/linkage.h | 2 +
arch/loongarch/include/asm/module.h | 7 +
arch/loongarch/include/asm/orc_header.h | 19 +
arch/loongarch/include/asm/orc_lookup.h | 34 ++
arch/loongarch/include/asm/orc_types.h | 58 +++
arch/loongarch/include/asm/stackframe.h | 3 +
arch/loongarch/include/asm/unwind.h | 22 +-
arch/loongarch/include/asm/unwind_hints.h | 28 +
arch/loongarch/kernel/Makefile | 3 +
arch/loongarch/kernel/entry.S | 9 +-
arch/loongarch/kernel/genex.S | 20 +-
arch/loongarch/kernel/head.S | 1 +
arch/loongarch/kernel/module.c | 11 +-
arch/loongarch/kernel/relocate_kernel.S | 2 +
arch/loongarch/kernel/setup.c | 2 +
arch/loongarch/kernel/stacktrace.c | 1 +
arch/loongarch/kernel/unwind_orc.c | 571 +++++++++++++++++++++
arch/loongarch/kernel/vmlinux.lds.S | 3 +
arch/loongarch/lib/Makefile | 2 +
arch/loongarch/mm/tlbex.S | 45 +-
arch/loongarch/power/Makefile | 2 +
arch/loongarch/vdso/Makefile | 1 +
include/linux/compiler.h | 9 +
scripts/Makefile | 5 +-
tools/arch/loongarch/include/asm/inst.h | 161 ++++++
tools/arch/loongarch/include/asm/orc_types.h | 58 +++
tools/include/linux/bitops.h | 11 +
tools/objtool/Makefile | 4 +
tools/objtool/arch/loongarch/Build | 3 +
tools/objtool/arch/loongarch/decode.c | 334 ++++++++++++
.../objtool/arch/loongarch/include/arch/cfi_regs.h | 21 +
tools/objtool/arch/loongarch/include/arch/elf.h | 30 ++
.../objtool/arch/loongarch/include/arch/special.h | 33 ++
tools/objtool/arch/loongarch/orc.c | 155 ++++++
tools/objtool/arch/loongarch/special.c | 15 +
tools/objtool/arch/x86/Build | 1 +
tools/objtool/arch/x86/orc.c | 169 ++++++
tools/objtool/check.c | 118 +++--
tools/objtool/include/objtool/orc.h | 10 +
tools/objtool/orc_dump.c | 69 +--
tools/objtool/orc_gen.c | 92 +---
47 files changed, 1949 insertions(+), 234 deletions(-)
create mode 100644 arch/loongarch/include/asm/orc_header.h
create mode 100644 arch/loongarch/include/asm/orc_lookup.h
create mode 100644 arch/loongarch/include/asm/orc_types.h
create mode 100644 arch/loongarch/include/asm/unwind_hints.h
create mode 100644 arch/loongarch/kernel/unwind_orc.c
create mode 100644 tools/arch/loongarch/include/asm/inst.h
create mode 100644 tools/arch/loongarch/include/asm/orc_types.h
create mode 100644 tools/objtool/arch/loongarch/Build
create mode 100644 tools/objtool/arch/loongarch/decode.c
create mode 100644 tools/objtool/arch/loongarch/include/arch/cfi_regs.h
create mode 100644 tools/objtool/arch/loongarch/include/arch/elf.h
create mode 100644 tools/objtool/arch/loongarch/include/arch/special.h
create mode 100644 tools/objtool/arch/loongarch/orc.c
create mode 100644 tools/objtool/arch/loongarch/special.c
create mode 100644 tools/objtool/arch/x86/orc.c
create mode 100644 tools/objtool/include/objtool/orc.h

--
2.1.0