Re: [PATCH v2 42/62] kbuild,x86: Fix module permissions for __jump_table and __bug_table

From: Peter Zijlstra
Date: Mon May 26 2025 - 07:06:50 EST


On Fri, May 09, 2025 at 01:17:06PM -0700, Josh Poimboeuf wrote:
> An upcoming patch will add the SHF_MERGE flag to x86 __jump_table and
> __bug_table so their entry sizes can be defined in inline asm.
>
> However, those sections have SHF_WRITE, which the Clang linker (lld)
> explicitly forbids combining with SHF_MERGE.
>
> Those sections are modified at runtime and must remain writable. While
> SHF_WRITE is ignored by vmlinux, it's still needed for modules.
>
> To work around the linker interference, remove SHF_WRITE during
> compilation and restore it after linking the module.

*groan*

This and the following patches marking a whole bunch of sections M,
seems to suggest you're going to rely on sh_entsize actually working.

There was an ld.lld bug, and IIRC you need to enforce llvm-20 or later
if you want this to be so.