Skip to content

objtool and cross compilation

Vasily Gorbik lkml 6 versions – In review

Get series with b4
b4 am cover.thread-1e2854.your-ad-here.call-01605220128-ext-6070@work.hours

Versions newest first · linked by author and title

  1. v5 Latest5 patches 1 replyIn review
  2. v4 RFC posting 2/20 of 4 patches 0 repliesSuperseded
  3. v4 RFC posting 1/24 patches 2 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v3 RFC4 patches3 repliesSuperseded
v2 RFC2 patches2 repliesSuperseded
v1 RFC2 patches1 replySuperseded

Changes in v5 from the cover letter

- original patch 1 has been merged. It has been replaced with the patch which moves instruction decoder selftests to tools headers usage. This effectively fixes x86 kernel cross-compilation with CONFIG_X86_DECODER_SELFTEST=y. And posttests are run successfully at least on s390 (with entire patch series applied).
- patch 2 has instruction decoder selftest fixup added.
- also includes patch 5 for objtool header include paths rework.
- patches 2-5 titles changed to those with which they were picked up into tip/objtool/core.

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5x86/tools: Use tools headers for instruction decoder selftestsarch/x86/tools/Makefile+4 -40 replies
2/5x86/insn: Support big endian cross-compilesarch/x86/include/asm/insn.h arch/x86/lib/insn.c arch/x86/tools/insn_sanity.c +2 more+160 -1120 replies
3/5objtool: Fix reloc generation on big endian cross compilestools/objtool/elf.c+19 -150 replies
4/5objtool: Fix x86 orc generation on big endian cross compilesarch/x86/include/asm/orc_types.h tools/arch/x86/include/asm/orc_types.h tools/objtool/arch/x86/include/arch_endianness.h +5 more+80 -60 replies
5/5objtool: Rework header include pathstools/objtool/.gitignore tools/objtool/Makefile tools/objtool/arch/x86/decode.c +23 more+48 -471 reply

Reviews trailers per patch

1 of 5 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchPeter Zijlstra (Intel)Masami Hiramatsu
SeriesA-b
1/5
2/5
3/5
4/5
5/5A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/5] objtool and cross compilation

The patch series is resent with additional patch for the instruction decoder selftest, since it has been dropped from the tip/objtool/core due to instruction decoder selftest build failure.

Previous version can be found here:
https://lore.kernel.org/lkml/cover.thread-b2a547.your-ad-here.call-01601912612-ext-9766@work.hours/

rfc v4 - v5:
- original patch 1 has been merged. It has been replaced with the patch which moves instruction decoder selftests to tools headers usage. This effectively fixes x86 kernel cross-compilation with CONFIG_X86_DECODER_SELFTEST=y. And posttests are run successfully at least on s390 (with entire patch series applied).
- patch 2 has instruction decoder selftest fixup added.
- also includes patch 5 for objtool header include paths rework.
- patches 2-5 titles changed to those with which they were picked up into tip/objtool/core.

rfc v3 - rfc v4:
- patch 4: objtool: fix x86 orc generation on big endian cross compiles
- introduced "bswap_if_needed()" macro for multi-byte values conversion, which are read from / about to be written to a target native endianness ELF file.
- patch 2: x86/insn: instruction decoder and big endian cross compiles
- changed subject prefix from objtool to x86/insn
- reformated leXX_to_cpu macro make it easier to read

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.

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

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.

Martin Schwidefsky (2):
x86/insn: Support big endian cross-compiles
objtool: Fix reloc generation on big endian cross compiles

Vasily Gorbik (3):
x86/tools: Use tools headers for instruction decoder selftests
objtool: Fix x86 orc generation on big endian cross compiles
objtool: Rework header include paths

 arch/x86/include/asm/insn.h                   |  33 ++++++
 arch/x86/include/asm/orc_types.h              |  10 ++
 arch/x86/lib/insn.c                           | 101 ++++++++----------
 arch/x86/tools/Makefile                       |   8 +-
 arch/x86/tools/insn_sanity.c                  |   4 -
 tools/arch/x86/include/asm/insn.h             |  33 ++++++
 tools/arch/x86/include/asm/orc_types.h        |  10 ++
 tools/arch/x86/lib/insn.c                     | 101 ++++++++----------
 tools/objtool/.gitignore                      |   2 +-
 tools/objtool/Makefile                        |   1 +
 tools/objtool/arch/x86/decode.c               |   8 +-
 .../arch/x86/include/{ => arch}/cfi_regs.h    |   0
 .../x86/include/{arch_elf.h => arch/elf.h}    |   0
 .../arch/x86/include/arch/endianness.h        |   9 ++
 .../{arch_special.h => arch/special.h}        |   0
 tools/objtool/arch/x86/special.c              |   4 +-
 tools/objtool/builtin-check.c                 |   4 +-
 tools/objtool/builtin-orc.c                   |   4 +-
 tools/objtool/check.c                         |  19 ++--
 tools/objtool/elf.c                           |  40 +++----
 tools/objtool/{ => include/objtool}/arch.h    |   4 +-
 tools/objtool/{ => include/objtool}/builtin.h |   0
 tools/objtool/{ => include/objtool}/cfi.h     |   2 +-
 tools/objtool/{ => include/objtool}/check.h   |   4 +-
 tools/objtool/{ => include/objtool}/elf.h     |   0
 tools/objtool/include/objtool/endianness.h    |  38 +++++++
 tools/objtool/{ => include/objtool}/objtool.h |   2 +-
 tools/objtool/{ => include/objtool}/special.h |   4 +-
 tools/objtool/{ => include/objtool}/warn.h    |   2 +-
 tools/objtool/objtool.c                       |   6 +-
 tools/objtool/orc_dump.c                      |   9 +-
 tools/objtool/orc_gen.c                       |   7 +-
 tools/objtool/special.c                       |  14 +--
 tools/objtool/weak.c                          |   2 +-
 34 files changed, 306 insertions(+), 179 deletions(-)
 rename tools/objtool/arch/x86/include/{ => arch}/cfi_regs.h (100%)
 rename tools/objtool/arch/x86/include/{arch_elf.h => arch/elf.h} (100%)
 create mode 100644 tools/objtool/arch/x86/include/arch/endianness.h
 rename tools/objtool/arch/x86/include/{arch_special.h => arch/special.h} (100%)
 rename tools/objtool/{ => include/objtool}/arch.h (96%)
 rename tools/objtool/{ => include/objtool}/builtin.h (100%)
 rename tools/objtool/{ => include/objtool}/cfi.h (96%)
 rename tools/objtool/{ => include/objtool}/check.h (96%)
 rename tools/objtool/{ => include/objtool}/elf.h (100%)
 create mode 100644 tools/objtool/include/objtool/endianness.h
 rename tools/objtool/{ => include/objtool}/objtool.h (96%)
 rename tools/objtool/{ => include/objtool}/special.h (94%)
 rename tools/objtool/{ => include/objtool}/warn.h (98%)
Signature · 1 line
2.25.4