From patchwork Sat Jun 21 13:57:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Gladkov X-Patchwork-Id: 899003 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80C494120B; Sat, 21 Jun 2025 13:57:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750514263; cv=none; b=rh+mX+2db6Ag3ia68Mu7eJtXGkZVLc8KMHCI8JH1PZNZhJjz2OleOCweuKF0S+CEYOd+PcU1E7fUEhCV3+VrC133HFchAq1sGgHml+8WbmDMb7AwzKiFu6t4VSBCDHBE3/j4XqdHVxRQ+SXWaXy/VE/WXxMOjWhV7sMONMY0ju0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750514263; c=relaxed/simple; bh=V0Ki0PP0IWixyV5REiz3OtpIGehZ28ZeA9xGhY+yj9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qKCOTGEP5SKmXZZbSkRy7UnFvwHDe8TNBFpEMjpDtgKEStKdPQBY6p8KGrJDtTHNthjk1O+4DGIGWPrz3aysZBiKVAwoV1/mkz35+kNblyveATjHoOnZwaxDieCH9etTwKW9HP7skyvwOcLu+ZjgNbj2OdRGYOiSxWRHiBVE6sQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TqHKOrvb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TqHKOrvb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2B3CC4CEE7; Sat, 21 Jun 2025 13:57:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750514261; bh=V0Ki0PP0IWixyV5REiz3OtpIGehZ28ZeA9xGhY+yj9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TqHKOrvb1SeLhY7Ku5BBEl4wunCBDIKYpJ+lBhp3EsfuXqPPpmZPh2y8/k/zp9jJR wHLNwve6vXHwT2NGY/QbMZkequLpSHH5Rx8GfLO+ezH1yEisj/wq78WH/CnHRv6TM+ mjRRA1uoUAY8zj3s//vCFmnAvmk6ZvEyRSiFf5GZ06vd3sp7STUnakDa32hFhh6C0S wZiTYgOT0GGDWLIY7vL4z4+QSiwtXg/GCJCTK6mQ2vv0reGzNrFsWqaSxzJ0fgrc0q mVamolz3u0EB6QKGUwhrLMdlW58gvnZ7OPISl/ojHutpfgbFaSWkRs7jymChfZykW5 dqO6IDu6nTZkw== From: Alexey Gladkov To: Masahiro Yamada , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez , Nathan Chancellor , Nicolas Schier Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [PATCH v4 2/7] kbuild: always create intermediate vmlinux.unstripped Date: Sat, 21 Jun 2025 15:57:14 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Masahiro Yamada Generate the intermediate vmlinux.unstripped regardless of CONFIG_ARCH_VMLINUX_NEEDS_RELOCS. If CONFIG_ARCH_VMLINUX_NEEDS_RELOCS is unset, vmlinux.unstripped and vmlinux are identiacal. This simplifies the build rule, and allows to strip more sections by adding them to remove-section-y. Signed-off-by: Masahiro Yamada --- scripts/Makefile.vmlinux | 45 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index b64862dc6f08..4f2d4c3fb737 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -9,20 +9,6 @@ include $(srctree)/scripts/Makefile.lib targets := -ifdef CONFIG_ARCH_VMLINUX_NEEDS_RELOCS -vmlinux-final := vmlinux.unstripped - -quiet_cmd_strip_relocs = RSTRIP $@ - cmd_strip_relocs = $(OBJCOPY) --remove-section='.rel*' --remove-section=!'.rel*.dyn' $< $@ - -vmlinux: $(vmlinux-final) FORCE - $(call if_changed,strip_relocs) - -targets += vmlinux -else -vmlinux-final := vmlinux -endif - %.o: %.c FORCE $(call if_changed_rule,cc_o_c) @@ -61,19 +47,19 @@ targets += .builtin-dtbs-list ifdef CONFIG_GENERIC_BUILTIN_DTB targets += .builtin-dtbs.S .builtin-dtbs.o -$(vmlinux-final): .builtin-dtbs.o +vmlinux.unstripped: .builtin-dtbs.o endif -# vmlinux +# vmlinux.unstripped # --------------------------------------------------------------------------- ifdef CONFIG_MODULES targets += .vmlinux.export.o -$(vmlinux-final): .vmlinux.export.o +vmlinux.unstripped: .vmlinux.export.o endif ifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX -$(vmlinux-final): arch/$(SRCARCH)/tools/vmlinux.arch.o +vmlinux.unstripped: arch/$(SRCARCH)/tools/vmlinux.arch.o arch/$(SRCARCH)/tools/vmlinux.arch.o: vmlinux.o FORCE $(Q)$(MAKE) $(build)=arch/$(SRCARCH)/tools $@ @@ -86,17 +72,30 @@ cmd_link_vmlinux = \ $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) -targets += $(vmlinux-final) -$(vmlinux-final): scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE +targets += vmlinux.unstripped +vmlinux.unstripped: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE +$(call if_changed_dep,link_vmlinux) ifdef CONFIG_DEBUG_INFO_BTF -$(vmlinux-final): $(RESOLVE_BTFIDS) +vmlinux.unstripped: $(RESOLVE_BTFIDS) endif ifdef CONFIG_BUILDTIME_TABLE_SORT -$(vmlinux-final): scripts/sorttable +vmlinux.unstripped: scripts/sorttable endif +# vmlinux +# --------------------------------------------------------------------------- + +remove-section-y := +remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) += '.rel*' + +quiet_cmd_strip_relocs = OBJCOPY $@ + cmd_strip_relocs = $(OBJCOPY) $(addprefix --remove-section=,$(remove-section-y)) $< $@ + +targets += vmlinux +vmlinux: vmlinux.unstripped FORCE + $(call if_changed,strip_relocs) + # modules.builtin.ranges # --------------------------------------------------------------------------- ifdef CONFIG_BUILTIN_MODULE_RANGES @@ -110,7 +109,7 @@ modules.builtin.ranges: $(srctree)/scripts/generate_builtin_ranges.awk \ modules.builtin vmlinux.map vmlinux.o.map FORCE $(call if_changed,modules_builtin_ranges) -vmlinux.map: $(vmlinux-final) +vmlinux.map: vmlinux.unstripped @: endif From patchwork Sat Jun 21 13:57:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Gladkov X-Patchwork-Id: 899002 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D5C420D4E1; Sat, 21 Jun 2025 13:57:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750514267; cv=none; b=R7pPQxzy2XxP1t0hpmBh70AKHyJ/E6627RIuXUuKNFpfq87wsKBvDMkGDOA3sdZDUg83KDcVtrMrqiGP6er/rAu0M/MXtlZTjVDvWTCp8Z93HaJeqDYXYqm5qyuzrrWWlDh0KuT3QTdaU53mmZ4T3PEWYRH2F2bU0lJhtHqKDtg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750514267; c=relaxed/simple; bh=QcOgqocEZGX7M/SEIk2LBmtO7Cxt9ewPmhV9uu+zKeo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JhSmfs/QGC+EUaBAkQJRzsyJQhhYHSaP14z9fAmi/pPLxXXgVHja13muW1ErU93yueJ1etBAxSbrkxuUIl0PQ9bUU2bkR4hH7OV2e6txjlLsEwclGdoR7MLZpRgD/IIYDAKJwlRy8v9B6gybCawXNINlwVNbTLWSEQS5WfcwFNs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PHgATPsr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PHgATPsr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 657D7C4CEED; Sat, 21 Jun 2025 13:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750514267; bh=QcOgqocEZGX7M/SEIk2LBmtO7Cxt9ewPmhV9uu+zKeo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PHgATPsrwCG/JM5poSek8+RUoOLPPenjrnN6sw9ZEThNHG53reF0KHz35aRYLb32P S+m/GkNMaXoM8xT0nSfSajjVLgmHkyzIZpfJ6a2+ZwuccLUixyYxduiFlYJyjaEaHq irzP2OHP0/+SRtuSW/YY//LI2dgA0pTN6T9hQSbma7qAn0uy7h1QOj8kX3yJgZuJE3 74gZGkq0jVvzRXCO45KRhF2ZMwVjrEY7x0fZcjBVA8MrdDGsZLjTNC11aBjFVFSD8s Lc86Npa/wAsANJ57XvGd7lqA8ey4NX9EW38By5mf3+gLndeSKX/rsukHo5HZzbL04H BPsaXrwEAc58w== From: Alexey Gladkov To: Masahiro Yamada , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez , Nathan Chancellor , Nicolas Schier Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-scsi@vger.kernel.org, Alexey Gladkov Subject: [PATCH v4 4/7] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped Date: Sat, 21 Jun 2025 15:57:16 +0200 Message-ID: <38c1e5cd57158ff433c00e71a437dbab4c0285a8.1750511018.git.legion@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Masahiro Yamada Currently, we assume all the data for modules.builtin.modinfo are available in vmlinux.o. This makes it impossible for modpost, which is invoked after vmlinux.o, to add additional module info. This commit moves the modules.builtin.modinfo rule after modpost. Signed-off-by: Masahiro Yamada Signed-off-by: Alexey Gladkov --- scripts/Makefile.vmlinux | 26 ++++++++++++++++++++++++++ scripts/Makefile.vmlinux_o | 26 +------------------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index e2ceeb9e168d..fdab5aa90215 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -96,6 +96,32 @@ targets += vmlinux vmlinux: vmlinux.unstripped FORCE $(call if_changed,strip_relocs) +# modules.builtin.modinfo +# --------------------------------------------------------------------------- + +OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary + +targets += modules.builtin.modinfo +modules.builtin.modinfo: vmlinux.unstripped FORCE + $(call if_changed,objcopy) + +# modules.builtin +# --------------------------------------------------------------------------- + +__default: modules.builtin + +# The second line aids cases where multiple modules share the same object. + +quiet_cmd_modules_builtin = GEN $@ + cmd_modules_builtin = \ + tr '\0' '\n' < $< | \ + sed -n 's/^[[:alnum:]:_]*\.file=//p' | \ + tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@ + +targets += modules.builtin +modules.builtin: modules.builtin.modinfo FORCE + $(call if_changed,modules_builtin) + # modules.builtin.ranges # --------------------------------------------------------------------------- ifdef CONFIG_BUILTIN_MODULE_RANGES diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index b024ffb3e201..23c8751285d7 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only PHONY := __default -__default: vmlinux.o modules.builtin.modinfo modules.builtin +__default: vmlinux.o include include/config/auto.conf include $(srctree)/scripts/Kbuild.include @@ -73,30 +73,6 @@ vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE targets += vmlinux.o -# modules.builtin.modinfo -# --------------------------------------------------------------------------- - -OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary - -targets += modules.builtin.modinfo -modules.builtin.modinfo: vmlinux.o FORCE - $(call if_changed,objcopy) - -# modules.builtin -# --------------------------------------------------------------------------- - -# The second line aids cases where multiple modules share the same object. - -quiet_cmd_modules_builtin = GEN $@ - cmd_modules_builtin = \ - tr '\0' '\n' < $< | \ - sed -n 's/^[[:alnum:]:_]*\.file=//p' | \ - tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@ - -targets += modules.builtin -modules.builtin: modules.builtin.modinfo FORCE - $(call if_changed,modules_builtin) - # Add FORCE to the prerequisites of a target to force it to be always rebuilt. # --------------------------------------------------------------------------- From patchwork Sat Jun 21 13:57:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Gladkov X-Patchwork-Id: 899001 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C98C221540; Sat, 21 Jun 2025 13:57:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750514274; cv=none; b=Yz9oQLJb5qXEzulRLC7cXZlBZHWu/VvjolkNNj089tbm7sDnekHTc9oBFmOxtPE1oiNcjFudcyyhKUe2McCEGqiy+ZEWt7N0i4e/pUioS0DGOBWZgCEwquTPyMYun6s7Pz2xWFOGy45+CXcUuNCKERv/c1SB4RuRQAcSQ9LfbSM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750514274; c=relaxed/simple; bh=AuegPmeYvpA3eTfQDAnxQdGpla+4yg+qXxtOidi62CQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IeNKVAEPok2yhJnID4AfTe5IMgqMl53SETdEURnMGeXLAH0+lmoDdZFXrwy1qAcG8gH/wQY/B7qftMXT+bD+1RjsjQaT3vurtt+Cqhe+dl5dkBxZr3l4Mmrsuw2oPFdau6reSn0PMrI4JpC6wLUkudHqtpGq2/cgPl7+HlP+9eM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Nrrb5O7N; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Nrrb5O7N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F926C4CEEF; Sat, 21 Jun 2025 13:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750514274; bh=AuegPmeYvpA3eTfQDAnxQdGpla+4yg+qXxtOidi62CQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nrrb5O7N9VjsXmw5z9X2sNO0f4k++mtYq9sJYt10ibLmkHyJeufaYAOvOnAwi2OIc YoNHp/tNz+PJqH0uSMt3xdrSByt6wSAAoGvKAZtvea8yUUrq9fiOxA0uIdLxhZARcP kMMGsP4dYI8TEjTQbehQ2kMARDnmdOhtQgczXV+u0RJM4yOTKQfHZ/I3ABn10rnaPV uXE7dG6f+Bmeva01H5cfNG6+CvXF/AubXVDmnDHvJuP4RHtTPB1vdAnXKQBL2/wK8U Y0i5pz0fSNIQIZ16cDqD9WmJR/iHIyxYtqymEf+EmJPvvzupKIzqFG99xJTJCBGYt6 mCkeck4udQivw== From: Alexey Gladkov To: Masahiro Yamada , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez , Nathan Chancellor , Nicolas Schier Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-scsi@vger.kernel.org, Alexey Gladkov , Miguel Ojeda , Alex Gaynor Subject: [PATCH v4 6/7] modpost: Add modname to mod_device_table alias Date: Sat, 21 Jun 2025 15:57:18 +0200 Message-ID: <6e2f70b07a710e761eb68d089d96cee7b27bb2d5.1750511018.git.legion@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 At this point, if a symbol is compiled as part of the kernel, information about which module the symbol belongs to is lost. To save this it is possible to add the module name to the alias name. It's not very pretty, but it's possible for now. Cc: Miguel Ojeda Cc: Alex Gaynor Signed-off-by: Alexey Gladkov --- include/linux/module.h | 14 +++++++++++--- rust/kernel/device_id.rs | 8 ++++---- scripts/mod/file2alias.c | 18 ++++++++++++++---- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index 24fe6b865e9c..e0f826fab2ac 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -243,11 +243,19 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name); /* What your module does. */ #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) +/* Format: __mod_device_table__kmod_____ */ +#define __mod_device_table(type, name) \ + __PASTE(__mod_device_table__, \ + __PASTE(__KBUILD_MODNAME, \ + __PASTE(__, \ + __PASTE(type, \ + __PASTE(__, name))))) + #ifdef MODULE /* Creates an alias so file2alias.c can find device table. */ -#define MODULE_DEVICE_TABLE(type, name) \ -extern typeof(name) __mod_device_table__##type##__##name \ - __attribute__ ((unused, alias(__stringify(name)))) +#define MODULE_DEVICE_TABLE(type, name) \ +static typeof(name) __mod_device_table(type, name) \ + __attribute__ ((used, alias(__stringify(name)))) #else /* !MODULE */ #define MODULE_DEVICE_TABLE(type, name) #endif diff --git a/rust/kernel/device_id.rs b/rust/kernel/device_id.rs index 0a4eb56d98f2..365d8f544844 100644 --- a/rust/kernel/device_id.rs +++ b/rust/kernel/device_id.rs @@ -154,10 +154,10 @@ macro_rules! module_device_table { ($table_type: literal, $module_table_name:ident, $table_name:ident) => { #[rustfmt::skip] #[export_name = - concat!("__mod_device_table__", $table_type, - "__", module_path!(), - "_", line!(), - "_", stringify!($table_name)) + concat!("__mod_device_table__", line!(), + "__kmod_", module_path!(), + "__", $table_type, + "__", stringify!($table_name)) ] static $module_table_name: [::core::mem::MaybeUninit; $table_name.raw_ids().size()] = unsafe { ::core::mem::transmute_copy($table_name.raw_ids()) }; diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 00586119a25b..13021266a18f 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1476,8 +1476,8 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, { void *symval; char *zeros = NULL; - const char *type, *name; - size_t typelen; + const char *type, *name, *modname; + size_t typelen, modnamelen; static const char *prefix = "__mod_device_table__"; /* We're looking for a section relative symbol */ @@ -1488,10 +1488,20 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) return; - /* All our symbols are of form __mod_device_table____. */ + /* All our symbols are of form __mod_device_table__kmod_____. */ if (!strstarts(symname, prefix)) return; - type = symname + strlen(prefix); + + modname = strstr(symname, "__kmod_"); + if (!modname) + return; + modname += strlen("__kmod_"); + + type = strstr(modname, "__"); + if (!type) + return; + modnamelen = type - modname; + type += strlen("__"); name = strstr(type, "__"); if (!name)