Re: [PATCH] init.h: discard exitcall symbols early

From: Nicolas Schier

Date: Tue Apr 07 2026 - 15:48:12 EST


On Tue, Mar 31, 2026 at 04:28:38PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> Any __exitcall() and built-in module_exit() handler is marked as __used,
> which leads to the code being included in the object file and later
> discarded at link time.
>
> As far as I can tell, this was originally added at the same time
> as initcalls were marked the same way, to prevent them from getting
> dropped with gcc-3.4, but it was never actaully necessary to keep exit
> functions around.
>
> Mark them as __maybe_unused instead, which lets the compiler treat
> the exitcalls as entirely unused, and make better decisions about
> dropping specializing static functions called from these.
>
> Link: https://lore.kernel.org/all/acruxMNdnUlyRHiy@xxxxxxxxxx/
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> ---
> include/linux/init.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/init.h b/include/linux/init.h
> index 5db55c660124..ad5c19763034 100644
> --- a/include/linux/init.h
> +++ b/include/linux/init.h
> @@ -47,7 +47,7 @@
> #define __initdata __section(".init.data")
> #define __initconst __section(".init.rodata")
> #define __exitdata __section(".exit.data")
> -#define __exit_call __used __section(".exitcall.exit")
> +#define __exit_call __maybe_unused __section(".exitcall.exit")
>
> /*
> * modpost check for section mismatches during the kernel build.
> --
> 2.39.5
>

Acked-by: Nicolas Schier <nsc@xxxxxxxxxx>

--
Nicolas