Skip to content

LTO PPC64: InputSection too large for range extension thunk #1332

@aik

Description

@aik

Trying to hack the POWERPC64 kernel to build with LTO. The config is CONFIG_LTO_CLANG_FULL=y, llvm is the latest + https://reviews.llvm.org/D96931 (fixes multiple "changed binding to global").

Now the very last call to lld fails. I added some printf at aik/llvm-project@7f5e8fe#diff-7bda54aace526c7e883a5e1c34446b3ffca171b50a4340a8795ef0ecc0d1f291R1791 , got this

[fstn1-p1 kernel-llvm-13-lto]$ ld.lld -EL -m elf64lppc -mllvm -import-instr-limit=5 -Bstatic --build-id=sha1 --orphan-handling=warn --strip-debug -o .tmp_vmlinux.kallsyms1 -T ./arch/powerpc/kernel/vmlinux.lds -error-limit=0 --whole-archive vmlinux.o --no-whole-archive
+-+-+-+ getISDThunkSec 1793: type=11 src=c00000000002cc9c osaddr=c000000000008000 off=24bac f0 [][vmlinux.o] secsize=948 secname=__ftr_alt_97
ld.lld: error: InputSection too large for range extension thunk vmlinux.o:(__ftr_alt_97+0xF0)

Which does not make much sense to me:

[fstn1-p1 kernel-llvm-13-lto]$ objdump -D vmlinux.o | grep -B3 2cc9c:

000000000002cc98 <wq_numa_init>:
   2cc98:       00 00 4c 3c     addis   r2,r12,0
   2cc9c:       00 00 42 38     addi    r2,r2,0

The __ftr_alt_97 section is a black magic which either enables chunks of asm depending on CPU features (search for END_FTR_SECTION/etc in the kernel) or fills those with noops.

[fstn1-p1 kernel-llvm-13-lto]$ readelf -S vmlinux.o  | grep -A1  __ftr_alt_97
  [19] __ftr_alt_97      PROGBITS         0000000000000000  00025cb0
       00000000000003b4  0000000000000000   A       0     0     4
  [20] .rela__ftr_alt_97 RELA             0000000000000000  0198e0e8
       0000000000000150  0000000000000018   I      134658    19     8

What does this error signal about?

My kernel with the config is here: aik@a3ba4e8

Metadata

Metadata

Assignees

No one assigned

    Labels

    [ARCH] powerpcThis bug impacts ARCH=powerpc[BUG] linuxA bug that should be fixed in the mainline kernel.[FEATURE] LTORelated to building the kernel with LLVM Link Time Optimization[TOOL] lldThe issue is relevant to LLD linkerquestionQuestion asked by issue author.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions