Skip to content

Commit 3e86e4d

Browse files
masahir0ynathanchance
authored andcommitted
kbuild: keep .modinfo section in vmlinux.unstripped
Keep the .modinfo section during linking, but strip it from the final vmlinux. Adjust scripts/mksysmap to exclude modinfo symbols from kallsyms. This change will allow the next commit to extract the .modinfo section from the vmlinux.unstripped intermediate. Signed-off-by: Masahiro Yamada <[email protected]> Signed-off-by: Alexey Gladkov <[email protected]> Reviewed-by: Nicolas Schier <[email protected]> Link: https://patch.msgid.link/aaf67c07447215463300fccaa758904bac42f992.1758182101.git.legion@kernel.org Signed-off-by: Nathan Chancellor <[email protected]>
1 parent 0ce5139 commit 3e86e4d

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

include/asm-generic/vmlinux.lds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
831831

832832
/* Required sections not related to debugging. */
833833
#define ELF_DETAILS \
834+
.modinfo : { *(.modinfo) } \
834835
.comment 0 : { *(.comment) } \
835836
.symtab 0 : { *(.symtab) } \
836837
.strtab 0 : { *(.strtab) } \
@@ -1044,7 +1045,6 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
10441045
*(.discard.*) \
10451046
*(.export_symbol) \
10461047
*(.no_trim_symbol) \
1047-
*(.modinfo) \
10481048
/* ld.bfd warns about .gnu.version* even when not emitted */ \
10491049
*(.gnu.version*) \
10501050

scripts/Makefile.vmlinux

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,14 @@ endif
8686
# vmlinux
8787
# ---------------------------------------------------------------------------
8888

89-
remove-section-y :=
89+
remove-section-y := .modinfo
9090
remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) += '.rel*'
9191

92+
# To avoid warnings: "empty loadable segment detected at ..." from GNU objcopy,
93+
# it is necessary to remove the PT_LOAD flag from the segment.
9294
quiet_cmd_strip_relocs = OBJCOPY $@
93-
cmd_strip_relocs = $(OBJCOPY) $(addprefix --remove-section=,$(remove-section-y)) $< $@
95+
cmd_strip_relocs = $(OBJCOPY) $(patsubst %,--set-section-flags %=noload,$(remove-section-y)) $< $@; \
96+
$(OBJCOPY) $(addprefix --remove-section=,$(remove-section-y)) $@
9497

9598
targets += vmlinux
9699
vmlinux: vmlinux.unstripped FORCE

scripts/mksysmap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979
/ _SDA_BASE_$/d
8080
/ _SDA2_BASE_$/d
8181

82+
# MODULE_INFO()
83+
/ __UNIQUE_ID_modinfo[0-9]*$/d
84+
8285
# ---------------------------------------------------------------------------
8386
# Ignored patterns
8487
# (symbols that contain the pattern are ignored)

0 commit comments

Comments
 (0)