]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
kbuild: Split .modinfo out from ELF_DETAILS
authorNathan Chancellor <nathan@kernel.org>
Wed, 25 Feb 2026 22:02:51 +0000 (15:02 -0700)
committerNathan Chancellor <nathan@kernel.org>
Thu, 26 Feb 2026 18:50:19 +0000 (11:50 -0700)
Commit 3e86e4d74c04 ("kbuild: keep .modinfo section in
vmlinux.unstripped") added .modinfo to ELF_DETAILS while removing it
from COMMON_DISCARDS, as it was needed in vmlinux.unstripped and
ELF_DETAILS was present in all architecture specific vmlinux linker
scripts. While this shuffle is fine for vmlinux, ELF_DETAILS and
COMMON_DISCARDS may be used by other linker scripts, such as the s390
and x86 compressed boot images, which may not expect to have a .modinfo
section. In certain circumstances, this could result in a bootloader
failing to load the compressed kernel [1].

Commit ddc6cbef3ef1 ("s390/boot/vmlinux.lds.S: Ensure bzImage ends with
SecureBoot trailer") recently addressed this for the s390 bzImage but
the same bug remains for arm, parisc, and x86. The presence of .modinfo
in the x86 bzImage was the root cause of the issue worked around with
commit d50f21091358 ("kbuild: align modinfo section for Secureboot
Authenticode EDK2 compat"). misc.c in arch/x86/boot/compressed includes
lib/decompress_unzstd.c, which in turn includes lib/xxhash.c and its
MODULE_LICENSE / MODULE_DESCRIPTION macros due to the STATIC definition.

Split .modinfo out from ELF_DETAILS into its own macro and handle it in
all vmlinux linker scripts. Discard .modinfo in the places where it was
previously being discarded from being in COMMON_DISCARDS, as it has
never been necessary in those uses.

Cc: stable@vger.kernel.org
Fixes: 3e86e4d74c04 ("kbuild: keep .modinfo section in vmlinux.unstripped")
Reported-by: Ed W <lists@wildgooses.com>
Closes: https://lore.kernel.org/587f25e0-a80e-46a5-9f01-87cb40cfa377@wildgooses.com/ [1]
Tested-by: Ed W <lists@wildgooses.com> # x86_64
Link: https://patch.msgid.link/20260225-separate-modinfo-from-elf-details-v1-1-387ced6baf4b@kernel.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
27 files changed:
arch/alpha/kernel/vmlinux.lds.S
arch/arc/kernel/vmlinux.lds.S
arch/arm/boot/compressed/vmlinux.lds.S
arch/arm/kernel/vmlinux-xip.lds.S
arch/arm/kernel/vmlinux.lds.S
arch/arm64/kernel/vmlinux.lds.S
arch/csky/kernel/vmlinux.lds.S
arch/hexagon/kernel/vmlinux.lds.S
arch/loongarch/kernel/vmlinux.lds.S
arch/m68k/kernel/vmlinux-nommu.lds
arch/m68k/kernel/vmlinux-std.lds
arch/m68k/kernel/vmlinux-sun3.lds
arch/mips/kernel/vmlinux.lds.S
arch/nios2/kernel/vmlinux.lds.S
arch/openrisc/kernel/vmlinux.lds.S
arch/parisc/boot/compressed/vmlinux.lds.S
arch/parisc/kernel/vmlinux.lds.S
arch/powerpc/kernel/vmlinux.lds.S
arch/riscv/kernel/vmlinux.lds.S
arch/s390/kernel/vmlinux.lds.S
arch/sh/kernel/vmlinux.lds.S
arch/sparc/kernel/vmlinux.lds.S
arch/um/kernel/dyn.lds.S
arch/um/kernel/uml.lds.S
arch/x86/boot/compressed/vmlinux.lds.S
arch/x86/kernel/vmlinux.lds.S
include/asm-generic/vmlinux.lds.h

index 2efa7dfc798a9577815244b68ee0da3bea316d06..2d136c63db161a6b4e69e3f09abee220fecb238c 100644 (file)
@@ -71,6 +71,7 @@ SECTIONS
 
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ELF_DETAILS
 
        DISCARDS
index 61a1b2b96e1d81396d6b7f7ab505756d0d8bb86e..6af63084ff28542e9e1b2f21b5d4fae401a87200 100644 (file)
@@ -123,6 +123,7 @@ SECTIONS
        _end = . ;
 
        STABS_DEBUG
+       MODINFO
        ELF_DETAILS
        DISCARDS
 
index d411abd4310ea97f14401cd73b21d77250af095f..2d916647df03cae64936669f2bda559408f3e336 100644 (file)
@@ -21,6 +21,7 @@ SECTIONS
     COMMON_DISCARDS
     *(.ARM.exidx*)
     *(.ARM.extab*)
+    *(.modinfo)
     *(.note.*)
     *(.rel.*)
     *(.printk_index)
index f2e8d4fac0687139ca02aafffd363a442ea03950..5afb725998ec0ae250c3a5d79c062e7178504563 100644 (file)
@@ -154,6 +154,7 @@ SECTIONS
 
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ARM_DETAILS
 
        ARM_ASSERTS
index d592a203f9c6b2714ebd7bdb17359fcb634a05fd..c07843c3c53d3b9450c4f3924c3a918dd908c940 100644 (file)
@@ -153,6 +153,7 @@ SECTIONS
 
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ARM_DETAILS
 
        ARM_ASSERTS
index ad6133b89e7a40a23e3d2354044b614e8fd27315..2964aad0362e4e14a4798509f00872bddc429997 100644 (file)
@@ -349,6 +349,7 @@ SECTIONS
 
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ELF_DETAILS
 
        HEAD_SYMBOLS
index d718961786d246b3049f91b877d88a85bd880883..81943981b3af4a95fb6f7c88f3b2d16a6a92608e 100644 (file)
@@ -109,6 +109,7 @@ SECTIONS
 
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ELF_DETAILS
 
        DISCARDS
index 1150b77fa281ce002f7b4c0f502851ce18728cc5..aae22283b5e0032e180f52bbc67e3fff6088d5be 100644 (file)
@@ -62,6 +62,7 @@ SECTIONS
 
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ELF_DETAILS
        .hexagon.attributes 0 : { *(.hexagon.attributes) }
 
index 08ea921cdec16eca09e51cdaac4cb6e75e942a26..d0e1377a041d63c94331736c17bfcb8be905458e 100644 (file)
@@ -147,6 +147,7 @@ SECTIONS
 
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ELF_DETAILS
 
 #ifdef CONFIG_EFI_STUB
index 2624fc18c131f1896d1983aec1aaab2b35e5ae68..45d7f4b0177b49ddca66167414b2e091517d1c59 100644 (file)
@@ -85,6 +85,7 @@ SECTIONS {
        _end = .;
 
        STABS_DEBUG
+       MODINFO
        ELF_DETAILS
 
        /* Sections to be discarded */
index 1ccdd04ae46242ead1d2e98be8e9c48f17340345..7326586afe15f5ea19e0ee897c769261c5f1b095 100644 (file)
@@ -58,6 +58,7 @@ SECTIONS
   _end = . ;
 
   STABS_DEBUG
+  MODINFO
   ELF_DETAILS
 
   /* Sections to be discarded */
index f13ddcc2af5c280f7505752d421b679e4846930a..1b19fef201fba6935c4498a47063e9818e0b42e0 100644 (file)
@@ -51,6 +51,7 @@ __init_begin = .;
   _end = . ;
 
   STABS_DEBUG
+  MODINFO
   ELF_DETAILS
 
   /* Sections to be discarded */
index 2b708fac8d2c17b8c8d093b4d9ca1d8e092d446a..579b2cc1995aee3d1ce81e883d6644cd78149885 100644 (file)
@@ -217,6 +217,7 @@ SECTIONS
 
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ELF_DETAILS
 
        /* These must appear regardless of  .  */
index 37b9580550646974af780836c6d4b5daadf19070..206f92445bfad85e4d547724681279edb865918c 100644 (file)
@@ -57,6 +57,7 @@ SECTIONS
 
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ELF_DETAILS
 
        DISCARDS
index 049bff45f612658c3e5658b0ee1a9a86561fda2a..9b29c3211774ca6576f48d904d5111d2660f3264 100644 (file)
@@ -101,6 +101,7 @@ SECTIONS
        /* Throw in the debugging sections */
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ELF_DETAILS
 
         /* Sections to be discarded -- must be last */
index ab7b439908578c784b22e081ae527abc6b23cfbd..87d24cc824b668e0fb64e273762e203672206caf 100644 (file)
@@ -90,6 +90,7 @@ SECTIONS
        /* Sections to be discarded */
        DISCARDS
        /DISCARD/ : {
+               *(.modinfo)
 #ifdef CONFIG_64BIT
                /* temporary hack until binutils is fixed to not emit these
                 * for static binaries
index b445e47903cfd0b813035c2056f11a4f818cf6d2..0ca93d6d723543898eb987d87c729176ebee7070 100644 (file)
@@ -165,6 +165,7 @@ SECTIONS
        _end = . ;
 
        STABS_DEBUG
+       MODINFO
        ELF_DETAILS
        .note 0 : { *(.note) }
 
index 15850296c0a9cc1ab25def1e5757910da7214e68..8fc11d6565bfb46275f8ea8b418695d55395d42b 100644 (file)
@@ -397,6 +397,7 @@ SECTIONS
        _end = . ;
 
        DWARF_DEBUG
+       MODINFO
        ELF_DETAILS
 
        DISCARDS
index 61bd5ba6680a786bf1db7dc37bf1acda0639b5c7..997f9eb3b22b139e7262417cd72bb5e5b6979e86 100644 (file)
@@ -170,6 +170,7 @@ SECTIONS
 
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ELF_DETAILS
        .riscv.attributes 0 : { *(.riscv.attributes) }
 
index 53bcbb91bb9bd56845994fbd0f996c98d4fb2828..2b62395e35bfb1279679c593d59de7208cb65f09 100644 (file)
@@ -221,6 +221,7 @@ SECTIONS
        /* Debugging sections.  */
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ELF_DETAILS
 
        /*
index 008c30289eaa6d27bd7452e011eec1041258b901..169c63fb3c1dcb2272a15ae99ceb4381c82611c7 100644 (file)
@@ -89,6 +89,7 @@ SECTIONS
 
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ELF_DETAILS
 
        DISCARDS
index f1b86eb3034043ff9e9d568d4dcdb111b9b92dd6..7ea510d9b42f249e7c99caa814d55e1b611fbdb9 100644 (file)
@@ -191,6 +191,7 @@ SECTIONS
 
        STABS_DEBUG
        DWARF_DEBUG
+       MODINFO
        ELF_DETAILS
 
        DISCARDS
index a36b7918a011ace9960ccaf1e0e8be5cd4b74bbc..ad3cefeff2acb19718364ee8d1a0bcb504a2aed2 100644 (file)
@@ -172,6 +172,7 @@ SECTIONS
 
   STABS_DEBUG
   DWARF_DEBUG
+  MODINFO
   ELF_DETAILS
 
   DISCARDS
index a409d4b66114f786e4fc58b1639d3058d890e1de..30aa24348d60cd29e0e05bbf4175ff951ea22bb0 100644 (file)
@@ -113,6 +113,7 @@ SECTIONS
 
   STABS_DEBUG
   DWARF_DEBUG
+  MODINFO
   ELF_DETAILS
 
   DISCARDS
index 587ce3e7c5048ace5102d2975e6edec6cdaca5ea..e0b152715d9c6f21145fc1ea72a1ef4de157b622 100644 (file)
@@ -88,7 +88,7 @@ SECTIONS
        /DISCARD/ : {
                *(.dynamic) *(.dynsym) *(.dynstr) *(.dynbss)
                *(.hash) *(.gnu.hash)
-               *(.note.*)
+               *(.note.*) *(.modinfo)
        }
 
        .got.plt (INFO) : {
index 3a24a3fc55f5b4a519a83fb118fa67b5949a8e49..4711a35e706cde002073b5ba6546634f9309ecee 100644 (file)
@@ -427,6 +427,7 @@ SECTIONS
        .llvm_bb_addr_map : { *(.llvm_bb_addr_map) }
 #endif
 
+       MODINFO
        ELF_DETAILS
 
        DISCARDS
index eeb070f330bdb8ef301fadfe57ebefe1b0a01755..1e1580febe4b9a78d30bef72c7ea942c412833a3 100644 (file)
 
 /* Required sections not related to debugging. */
 #define ELF_DETAILS                                                    \
-               .modinfo : { *(.modinfo) . = ALIGN(8); }                \
                .comment 0 : { *(.comment) }                            \
                .symtab 0 : { *(.symtab) }                              \
                .strtab 0 : { *(.strtab) }                              \
                .shstrtab 0 : { *(.shstrtab) }
 
+#define MODINFO                                                                \
+               .modinfo : { *(.modinfo) . = ALIGN(8); }
+
 #ifdef CONFIG_GENERIC_BUG
 #define BUG_TABLE                                                      \
        . = ALIGN(8);                                                   \