Re: [PATCH v3 00/11] objtool/powerpc: Fix up feature section alternatives at build time

From: Josh Poimboeuf

Date: Wed Dec 02 2026 - 16:25:12 EST


On Wed, Dec 02, 2026 at 01:10:47PM +0530, Shivang Upadhyay wrote:
> The replacement code of a powerpc feature section (BEGIN_FTR_SECTION /
> FTR_SECTION_ELSE / ALT_FTR_SECTION_END macros) is emitted into a __ftr_alt_*
> section. At boot, apply_feature_fixups() copies the replacement code over it.
> Since the copy lands at a different address than the one it was linked for, the
> PC-relative branches in it have to be translated, which is currently done at
> runtime by patch_feature_section().
>
> This has two drawbacks:
>
> - __ftr_alt_* sections are allocatable but not executable, so the
> linker cannot insert branch stubs for them. They therefore have to
> be placed close to .text, and every branch in them must reach its
> target directly. This can break the build as the kernel grows.

Is this a real issue or is it theoretical?

> - The branches are translated on every boot, although everything
> needed to do it is known at link time.

x86 also does something similar for its alternatives, I'm not sure
that's much of a drawback though.

Presumably objtool-on-vmlinux adds some slowness to the build.

> This series moves the translation to build time. After vmlinux is
> linked, objtool is run on it with the new --alt-fixup option. It parses
> the __ftr_fixup, __mmu_ftr_fixup and __fw_ftr_fixup tables, and for each
> PC-relative relocation in the replacement code, asks the arch to rewrite
> the instruction so that it is valid at the place it will be copied to.
> With that, the __ftr_alt_* sections are marked executable and moved out
> of .text into their own output section, so the linker can insert stubs
> where needed.
>
> Objtool does not process modules or the VDSO, so the runtime translation
> is kept for those and only skipped for the core kernel.

So now there are two translation methods of instead of one?

Is there any reason why objtool coudn't be run on linked vDSO and
modules as well?

> Previously, Nicholas Piggin proposed a build-time solution using a custom
> powerpc tool [1]. The approach here builds on that idea, but uses
> objtool's existing ELF parsing and instruction patching infrastructure
> instead of a separate tool.

I notice that last approach was almost 10 years ago, just wondering if
this is a real problem that people are hitting.

--
Josh