[RFC PATCH v3 0/4] objtool and cross compilation

From: Vasily Gorbik
Date: Wed Sep 30 2020 - 18:17:48 EST


rfc v1 - rfc v2:
- rebased onto tip/objtool/core
- reformatted couple of lines

rfc v2 - rfc v3:
- reused __*_ENDIAN_BITFIELD and dropped unneeded byteswap if __KERNEL__
is defined following David's suggestions,
- re-splitted changes and made x86 instruction decoder a separate patch,
- extra patch to add -Wno-nested-externs build flag to enable BUILD_BUG()
usage,
- added a safer and more readable leXX_to_cpu macro in x86 instruction
decoder,
- simplified includes. Switched to using leXX_to_cpu/cpu_to_leXX in
the objtool and x86 instruction decoder since
<linux/kernel.h> is included in the objtool already.

Currently objtool seems to be the only tool from all the build tools
needed for x86 build which breaks x86 cross compilation on big endian
systems.

But besides x86 cross compilation, endianness awareness is also needed
for big endian architectures objtool support in general.

We have working prototype of objtool support and orc unwinder for s390
made originally by Martin Schwidefsky. I'm trying to bring it in shape
again and refactor to share more code with "generic" part.

But first things first. This patch series points to endianness problems
which should be addressed. Recent "other architectures support" patches
currently moved only some problematic parts into x86 arch specific folder.
Besides that even though big endian stuff is only needed for the objtool
arch/x86/lib/insn.c and arch/x86/include/asm/insn.h are shared across
the kernel source and the tools, so changes are applied to both.

Any suggestions how to make patches more acceptable are welcome.

Martin Schwidefsky (2):
objtool: x86 instruction decoder and big endian cross compiles
objtool: correct rebuilding of reloc sections

Vasily Gorbik (2):
objtool: allow nested externs to enable BUILD_BUG()
objtool: fix x86 orc generation on big endian cross compiles

arch/x86/include/asm/insn.h | 35 ++++++++
arch/x86/include/asm/orc_types.h | 10 +++
arch/x86/lib/insn.c | 108 ++++++++++++-------------
tools/arch/x86/include/asm/insn.h | 35 ++++++++
tools/arch/x86/include/asm/orc_types.h | 10 +++
tools/arch/x86/lib/insn.c | 108 ++++++++++++-------------
tools/objtool/Makefile | 2 +-
tools/objtool/arch/x86/special.c | 2 +-
tools/objtool/check.c | 4 +-
tools/objtool/elf.c | 34 ++++----
tools/objtool/orc_dump.c | 4 +-
tools/objtool/orc_gen.c | 2 +
12 files changed, 225 insertions(+), 129 deletions(-)

--
⣿⣿⣿⣿⢋⡀⣀⠹⣿⣿⣿⣿
⣿⣿⣿⣿⠠⣶⡦⠀⣿⣿⣿⣿
⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿
⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿
⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿
⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿