From patchwork Mon Jun 1 05:56:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581295 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 956B492A for ; Mon, 1 Jun 2020 05:57:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DEFF20734 for ; Mon, 1 Jun 2020 05:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991072; bh=dV6dqElaI/RRFpu6svcTXWU1F1Afh2gyRYfnrwK66Y0=; h=From:To:Cc:Subject:Date:List-ID:From; b=wCye6P0OTMompJNZcKFtdb4Kc65/pm1XuS2LPyyA4tBPG1P+cA7Lf1LBXBGU0Kq2a 39wQL12hdJtcVOAsoLpkyh2j9wxmKp1aG8e7fGoxDL3U3C1RAdU3Q+wYF+4rWV3U0E rJ5Im9+s2q1g5gz63UFKV03l67vfvLfPFrJayocc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726116AbgFAF5w (ORCPT ); Mon, 1 Jun 2020 01:57:52 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:39125 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725952AbgFAF5v (ORCPT ); Mon, 1 Jun 2020 01:57:51 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLe023694; Mon, 1 Jun 2020 14:57:37 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLe023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991057; bh=hClu71YjeEoM6Vu18KHeyn59euJfqdWK4cwz1ZWo+0o=; h=From:To:Cc:Subject:Date:From; b=XmwjqNOMwrMyFQrC0w92aE/uW+U/I2SuStdzkIWNxFsPbaMCBhfi4RLPM2qGKi2q8 5ntx8HhktUrVQCmQzsnoNVEq94MgXAAFRnoZRrexCV8B6RdZQdsFx4oLbuSVGatUW5 WUGwKSERNnAbWLMLmC8poQWoBwGOsCmw7/Q+bmo2kj6dyT88BTHaQ5Kn2VNRpdVJ9X FAR7ha2P0WDo0bnpmeDrudlPvJdI+AvbjOjiZ3oqa5SVoFOWPIv5W9xgmZNcK4oZF9 4e8xyLgfj/zEhkmOMBBu0NSAtN0KUfLNuJYP/+/VqQOi75H/4f3fgyAxwQSZgnUEnm CP6zjW0qrSr9g== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 01/37] kbuild: refactor subdir-ym calculation Date: Mon, 1 Jun 2020 14:56:55 +0900 Message-Id: <20200601055731.3006266-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Remove the unneeded variables, __subdir-y and __subdir-m. Signed-off-by: Masahiro Yamada --- scripts/Makefile.lib | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0d931cc0df94..748e44d5a1e3 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -39,16 +39,14 @@ ifdef need-modorder modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko)) endif +# Subdirectories we need to descend into +subdir-ym := $(sort $(subdir-y) $(subdir-m) \ + $(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m)))) + # Handle objects in subdirs # --------------------------------------------------------------------------- # o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a -# and add the directory to the list of dirs to descend into: $(subdir-y) # o if we encounter foo/ in $(obj-m), remove it from $(obj-m) -# and add the directory to the list of dirs to descend into: $(subdir-m) -__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) -subdir-y += $(__subdir-y) -__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) -subdir-m += $(__subdir-m) ifdef need-builtin obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) else @@ -56,9 +54,6 @@ obj-y := $(filter-out %/, $(obj-y)) endif obj-m := $(filter-out %/, $(obj-m)) -# Subdirectories we need to descend into -subdir-ym := $(sort $(subdir-y) $(subdir-m)) - # If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))), $(m)))) multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))), $(m)))) From patchwork Mon Jun 1 05:56:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581297 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F53460D for ; Mon, 1 Jun 2020 05:57:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8520E20734 for ; Mon, 1 Jun 2020 05:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991073; bh=IjnGfxtMw7sY3BfMOvHk4OdCXFN8sZC6Yv9jmoJbTho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=P/3BUnxmp8+Wgq0ou7+1LZZs4H2QXA1gZs7N4Ki5/jy4y+s21/IU2c7mOdODYJny0 mDDlkx63PbzcOOsK1oxlsKyrf4v6/Q4G9UpOnb7Di6aLfoW85jM6p0k/17o5v9i44x Af4p5TBUpMfWWGWpIN+vDSKZ7zJA5hINQD5a/vUs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725952AbgFAF5w (ORCPT ); Mon, 1 Jun 2020 01:57:52 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:39162 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726034AbgFAF5w (ORCPT ); Mon, 1 Jun 2020 01:57:52 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLf023694; Mon, 1 Jun 2020 14:57:37 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLf023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991057; bh=2NyQ73uu1UeT6pnuaHd0e+s75GD37BsDSG29svWi8HY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YoNGDuwdo9y7YKfTkD97kxT7o2v8593fNSNm3njllQACm2fVh8SwRCd6BEifWsA3G G1wxfXqA8vwEPzCEojkqVsYJ2vJ/bVIi31Nvf/+QlMCs28JFN4+ujWYkPEckMAeNrl 5gGsGjcdinSQbASmZz/hqB8dtJ5ReXivG4W5WQo2J62fVuqzCPoy93CzlNHbd+yLxn oZYj1WoPQGcE3DpkmEmc/E0WDKycLx0rWTgNoxD0+Ugz8Dl20wY9nopyQD2WRypexC utzgL6no+gWostonUdqbjzQV8FCeg6hnnjJ9bHQuzzg3d87HFpV/y2/sMGtqU0LxOy YwtN74uC/jaVQ== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 02/37] kbuild: refactor tagets caluculation for KBUILD_{BUILTIN,KBUILD_MODULES} Date: Mon, 1 Jun 2020 14:56:56 +0900 Message-Id: <20200601055731.3006266-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Remove lib-target, builtin-target, modorder-target, and modtargets. Instead, add targets-for-builtin and targets-for-modules. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index ee9a817e19a3..a1f09bec8c70 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -73,19 +73,24 @@ endif subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y))) subdir-modorder := $(sort $(filter %/modules.order, $(modorder))) +targets-for-builtin := $(extra-y) + ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) -lib-target := $(obj)/lib.a +targets-for-builtin += $(obj)/lib.a endif ifdef need-builtin -builtin-target := $(obj)/built-in.a +targets-for-builtin += $(obj)/built-in.a endif +targets-for-modules := $(obj-m) +targets-for-modules += $(patsubst %.o, %.mod, $(obj-m)) + ifdef need-modorder -modorder-target := $(obj)/modules.order +targets-for-modules += $(obj)/modules.order endif -mod-targets := $(patsubst %.o, %.mod, $(obj-m)) +targets += $(targets-for-builtin) $(targets-for-modules) # Linus' kernel sanity checking tool ifeq ($(KBUILD_CHECKSRC),1) @@ -284,8 +289,6 @@ cmd_mod = { \ $(obj)/%.mod: $(obj)/%.o FORCE $(call if_changed,mod) -targets += $(mod-targets) - quiet_cmd_cc_lst_c = MKLST $@ cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ @@ -359,7 +362,7 @@ $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE $(call if_changed_rule,as_o_S) targets += $(filter-out $(subdir-builtin), $(real-obj-y)) $(real-obj-m) $(lib-y) -targets += $(extra-y) $(always-y) $(MAKECMDGOALS) +targets += $(always-y) $(MAKECMDGOALS) # Linker scripts preprocessor (.lds.S -> .lds) # --------------------------------------------------------------------------- @@ -396,8 +399,6 @@ quiet_cmd_ar_builtin = AR $@ $(obj)/built-in.a: $(real-obj-y) FORCE $(call if_changed,ar_builtin) -targets += $(builtin-target) - # # Rule to create modules.order file # @@ -414,8 +415,6 @@ $(obj)/modules.order: $(subdir-modorder) FORCE $(obj)/lib.a: $(lib-y) FORCE $(call if_changed,ar) -targets += $(lib-target) - # NOTE: # Do not replace $(filter %.o,^) with $(real-prereqs). When a single object # module is turned into a multi object module, $^ will contain header file @@ -478,8 +477,8 @@ endif else -__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ - $(if $(KBUILD_MODULES),$(obj-m) $(mod-targets) $(modorder-target)) \ +__build: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \ + $(if $(KBUILD_MODULES), $(targets-for-modules)) \ $(subdir-ym) $(always-y) @: From patchwork Mon Jun 1 05:56:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581299 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27D7F159A for ; Mon, 1 Jun 2020 05:57:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0653A20734 for ; Mon, 1 Jun 2020 05:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991074; bh=2BlFie83TlJxkrdqtjqrZ2AHbl5HxIJNh7ZCIkSPxMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=M/fBDAE051rD4NUbKKUegvPtVdl75RecHetz5P24AjZaO+4KZiq1zdgf7O+gU7zZv H0qdgGEMA3L4Y6VAk2eQbWp+e2GFtmjj+XjscByfYnlGDH3aUEBr40SuMeyszQ3IZJ 4rNWMVWD3ogPYFNGL0AWeVEggUju0aptdPKsBwsQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726034AbgFAF5x (ORCPT ); Mon, 1 Jun 2020 01:57:53 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:39161 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725965AbgFAF5x (ORCPT ); Mon, 1 Jun 2020 01:57:53 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLg023694; Mon, 1 Jun 2020 14:57:38 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLg023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991058; bh=//S+CseyHNhRzgrsQ7TQ5JRIUmN4rALWWecIo96lqwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rhWEl2I60PRry0XbiWGvB7+wh11F32hrQlJSicua13NtmRsEBtQZ5dV19z8v7jou7 OqMXipjAcKVPc+aSZUbQbVXylPunua+AwyWzIQgIzz+NYFi80qGoa4z24a+eJR4FBs spxZOxgNLC0MOKJBkS1uVQHnXqgltoYGCrv/kwG8baM2DMciUSVDO61Nk+8OH8RD3+ iTladGfkelQ0nY/tAJPBYJWZGOJcRfgbKCB5LE9g4XN9ysSOBMwGMz2wheIU0ea8BA 7GaOZCQncUKKDrUAQnyt4VGncHYF/XKhN/bMlqrGaEhaXqZ+uOC5j/dDo6myVLaHsQ O9f0I3Dslv5kQ== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 03/37] kbuild: merge init-y into core-y Date: Mon, 1 Jun 2020 14:56:57 +0900 Message-Id: <20200601055731.3006266-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org No arch Makefile specifies init-y. Merge init-y into core-y. This does not change the link order. Signed-off-by: Masahiro Yamada --- Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 44921d9cf3cf..f9c37045cf64 100644 --- a/Makefile +++ b/Makefile @@ -643,12 +643,11 @@ endif ifeq ($(KBUILD_EXTMOD),) # Objects we will link into vmlinux / subdirs we need to visit -init-y := init/ +core-y := init/ usr/ drivers-y := drivers/ sound/ drivers-$(CONFIG_SAMPLES) += samples/ net-y := net/ libs-y := lib/ -core-y := usr/ virt-y := virt/ endif # KBUILD_EXTMOD @@ -1060,18 +1059,17 @@ export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps ifeq ($(KBUILD_EXTMOD),) core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ -vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ +vmlinux-dirs := $(patsubst %/,%,$(filter %/, \ $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ $(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y))) vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \ - $(patsubst %/,%,$(filter %/, $(init-) $(core-) \ + $(patsubst %/,%,$(filter %/, $(core-) \ $(drivers-) $(net-) $(libs-) $(virt-)))) build-dirs := $(vmlinux-dirs) clean-dirs := $(vmlinux-alldirs) -init-y := $(patsubst %/, %/built-in.a, $(init-y)) core-y := $(patsubst %/, %/built-in.a, $(core-y)) drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y)) net-y := $(patsubst %/, %/built-in.a, $(net-y)) @@ -1085,7 +1083,7 @@ endif virt-y := $(patsubst %/, %/built-in.a, $(virt-y)) # Externally visible symbols (used by link-vmlinux.sh) -export KBUILD_VMLINUX_OBJS := $(head-y) $(init-y) $(core-y) $(libs-y2) \ +export KBUILD_VMLINUX_OBJS := $(head-y) $(core-y) $(libs-y2) \ $(drivers-y) $(net-y) $(virt-y) export KBUILD_VMLINUX_LIBS := $(libs-y1) export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds From patchwork Mon Jun 1 05:56:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581301 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E2AD60D for ; Mon, 1 Jun 2020 05:57:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BD03206C3 for ; Mon, 1 Jun 2020 05:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991074; bh=DJhwH9p8avgLPsx/Xang5IfQtAHji1zBv+2HjxT/pM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=j0ho9vm8u5wo8QHRhMN4RRP54QOolKfFckbJPos+irYCjE69C/mHTeYdvEv6w/DGl o3ttAr0km927Lms32TcnULyR1ZUiowH+5piDLK1zDmqLkLqszXPAZad2yYpO3G0px4 nOyaiSdyBDGsdpLeZNP/LBuUYHG1FknfSySWmPpg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725965AbgFAF5x (ORCPT ); Mon, 1 Jun 2020 01:57:53 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:39169 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726100AbgFAF5x (ORCPT ); Mon, 1 Jun 2020 01:57:53 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLh023694; Mon, 1 Jun 2020 14:57:38 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLh023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991058; bh=+VE+el9BKc5nZ+psUOwHPTqn37gr8MM9TL3PeWQiFbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tEInk+p2ulAGn/s7FdGHFouGFk6w1++zHuF5etUAsbduzTLmJEvvDjLmpcS4BR8h/ lUpvCmZcv0ajug4QVsJH4QitdsMepwcpSbDkN73/tafz/KclhaCidLv1qc1zCVOCoB uHcnwVwE4tlZSE+CB0ujZ0pO3i+wy1mSVdEwZflg9qUBbIDijkSe0Ejb74kCdf4+Xm hdC7y/91wpfKmeED7LAVIy3LGd/IN9r2ZWhcncwQSKALYH8uY6HEXDzDO21+O50vHy gmDwGJOwjBE5S/2W7Eh4KeWKIc9zUmVsI8myd/4c0z9Lt+PNWM0zs8HC63QAQT5DeW zrwJYCraNLH/A== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 04/37] kbuild: merge net-y and virt-y into drivers-y Date: Mon, 1 Jun 2020 14:56:58 +0900 Message-Id: <20200601055731.3006266-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org This will slightly change the link order; drivers-y from arch Makefile will be linked after virt/built-in.a, but I guess this is not a big deal. Signed-off-by: Masahiro Yamada --- Makefile | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index f9c37045cf64..c0c086d06753 100644 --- a/Makefile +++ b/Makefile @@ -646,9 +646,8 @@ ifeq ($(KBUILD_EXTMOD),) core-y := init/ usr/ drivers-y := drivers/ sound/ drivers-$(CONFIG_SAMPLES) += samples/ -net-y := net/ +drivers-y += net/ virt/ libs-y := lib/ -virt-y := virt/ endif # KBUILD_EXTMOD # The all: target is the default when no target is given on the @@ -1061,18 +1060,17 @@ core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ vmlinux-dirs := $(patsubst %/,%,$(filter %/, \ $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ - $(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y))) + $(libs-y) $(libs-m))) vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \ $(patsubst %/,%,$(filter %/, $(core-) \ - $(drivers-) $(net-) $(libs-) $(virt-)))) + $(drivers-) $(libs-)))) build-dirs := $(vmlinux-dirs) clean-dirs := $(vmlinux-alldirs) core-y := $(patsubst %/, %/built-in.a, $(core-y)) drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y)) -net-y := $(patsubst %/, %/built-in.a, $(net-y)) libs-y2 := $(patsubst %/, %/built-in.a, $(filter %/, $(libs-y))) ifdef CONFIG_MODULES libs-y1 := $(filter-out %/, $(libs-y)) @@ -1080,11 +1078,9 @@ libs-y2 += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y))) else libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) endif -virt-y := $(patsubst %/, %/built-in.a, $(virt-y)) # Externally visible symbols (used by link-vmlinux.sh) -export KBUILD_VMLINUX_OBJS := $(head-y) $(core-y) $(libs-y2) \ - $(drivers-y) $(net-y) $(virt-y) +export KBUILD_VMLINUX_OBJS := $(head-y) $(core-y) $(libs-y2) $(drivers-y) export KBUILD_VMLINUX_LIBS := $(libs-y1) export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds export LDFLAGS_vmlinux From patchwork Mon Jun 1 05:56:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581303 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83C9392A for ; Mon, 1 Jun 2020 05:57:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 621CF206C3 for ; Mon, 1 Jun 2020 05:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991074; bh=MqE0i8mjZ5b+g8fWnL5xnNsGEGKOB67Zz17KA+SNjWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=twJuInokOAhxeY6TeeBO7x1NVoVeodMvQ5HQ873GwkNzfnSpl13W3zxxZaiUBCpyW cPYgIni4VojmkzlJU/jRhcgTx/Aj/Jv8KQJKhOqg2E4F5LcCTMf+9ZJp66I9C8EAyv g5p9OoVxfRHujSSoHkmnfO+bqbdXtIxZUANXIul0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726100AbgFAF5y (ORCPT ); Mon, 1 Jun 2020 01:57:54 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:39165 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726088AbgFAF5x (ORCPT ); Mon, 1 Jun 2020 01:57:53 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLi023694; Mon, 1 Jun 2020 14:57:38 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLi023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991059; bh=kdojAnTCQvKdlZFcTjZtYl2v8pRFRZskOxn0SX8gFdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EUbnlPCwTq+NNqpaJUFS4zgLOjFFvIsECtUQPulfR7WSfeg45XC24oQYlYizKgc6s c73HoQleQcESd25QvEl6dpVPLuQEqILLooeZmW+7qRN1FBlHVuHMqq4IqM0FRmr9sK o/bzqOp4OR05ibUuX+85Iq+dSu3R7A2nClQawm1S5VqeIG9GeLMZWLwPmYWWE+edW7 IaiU+8dp1o/JV+mA2dT03+9EDMIyrzIcB3qfDZ/AwXw5r/NqkEkWxkOxwHqsaB1YZo SH9av17nCYdu2yTWDmlCyBj9Bttvx0nNJhhmhrPnns17hcdBhynQQMuaEwnWPepAQa g5KhxW11lZktg== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 05/37] kbuild: refactor KBUILD_VMLINUX_{OBJS,LIBS} calculation Date: Mon, 1 Jun 2020 14:56:59 +0900 Message-Id: <20200601055731.3006266-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Do not overwrite core-y or drivers-y. Remove libs-y1 and libs-y2. Signed-off-by: Masahiro Yamada --- Makefile | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index c0c086d06753..0416760aeb28 100644 --- a/Makefile +++ b/Makefile @@ -1069,19 +1069,18 @@ vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \ build-dirs := $(vmlinux-dirs) clean-dirs := $(vmlinux-alldirs) -core-y := $(patsubst %/, %/built-in.a, $(core-y)) -drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y)) -libs-y2 := $(patsubst %/, %/built-in.a, $(filter %/, $(libs-y))) +# Externally visible symbols (used by link-vmlinux.sh) +KBUILD_VMLINUX_OBJS := $(head-y) $(addsuffix built-in.a, $(core-y)) +KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y))) ifdef CONFIG_MODULES -libs-y1 := $(filter-out %/, $(libs-y)) -libs-y2 += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y))) +KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y))) +KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y)) else -libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) +KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y)) endif +KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(drivers-y)) -# Externally visible symbols (used by link-vmlinux.sh) -export KBUILD_VMLINUX_OBJS := $(head-y) $(core-y) $(libs-y2) $(drivers-y) -export KBUILD_VMLINUX_LIBS := $(libs-y1) +export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds export LDFLAGS_vmlinux # used by scripts/Makefile.package From patchwork Mon Jun 1 05:57:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581305 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A0514175D for ; Mon, 1 Jun 2020 05:57:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89038206C3 for ; Mon, 1 Jun 2020 05:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991074; bh=/ebFjtw9ZJU8eYCOIEjO1pE1+p0BmRvQmUxcy9SEtIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=oL6JBZrRnHZpoMYI1cDwGFWCe5JO8kKt3IVqzqat9EmA01NrYBIFc2+oaxIEoxmWm b8QG3/65UPQS1hxY85v2JrTsKdyocvBIhawzko2kYQde2oAx5Hh/VU2fyaUD/OBgxB zZ6m1NA5ZZaCmlSaQDAA7FNBNSsUyUhnhJoLvB8E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726088AbgFAF5y (ORCPT ); Mon, 1 Jun 2020 01:57:54 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:39163 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726070AbgFAF5x (ORCPT ); Mon, 1 Jun 2020 01:57:53 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLj023694; Mon, 1 Jun 2020 14:57:39 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLj023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991059; bh=MiIQAuNVz99VHZPOpzDzpkGJknGf/5rRq3ooXYj5CKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EsX4Rwurpcsut7+teLU7j0Dj9LIaJ5WA1iiB3lyuyFnBTdxiYKOwmA9y1PmsVwcno eVVB5d9C3uOBrIzQ7MnThss5FaAnseeDtoP7JbrDq3k0BcyI1LzXtQUAjViA9fGJsO GML4MpWvcdzgDnfJMVn5z9FRgVe4Jm5y1o3pK5KAXWczPpi1+/5m7oWeksQ4SM4qc0 6P6HnONWWbM2D4hEiunzVpuEqItZKqmaqWWolikes8lgheEOE0+iLyV4bvHEsmFWMd NNMKPZi6dWpmUcxBHzlWx1xSYfQ16MWQVO87c1JjcCir61Z6Ahda6arKCgO2atwaW+ X0si/XMXvAcGQ== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 06/37] kbuild: update modules.order only when contained modules are updated Date: Mon, 1 Jun 2020 14:57:00 +0900 Message-Id: <20200601055731.3006266-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Make modules.order depend on $(obj-m), and use if_changed to build it. This will avoid unneeded update of modules.order, which will be useful to optimize the modpost stage. Currently, the second pass of modpost is always invoked. By checking the timestamp of modules.order, we can avoid the unneeded modpost. Signed-off-by: Masahiro Yamada --- Makefile | 14 +++++++++++--- scripts/Makefile.build | 21 +++++++++++++-------- scripts/Makefile.lib | 27 ++++++++++++++------------- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 0416760aeb28..b40420a0b991 100644 --- a/Makefile +++ b/Makefile @@ -1066,6 +1066,10 @@ vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \ $(patsubst %/,%,$(filter %/, $(core-) \ $(drivers-) $(libs-)))) +subdir-modorder := $(addsuffix modules.order,$(filter %/, \ + $(core-y) $(core-m) $(libs-y) $(libs-m) \ + $(drivers-y) $(drivers-m))) + build-dirs := $(vmlinux-dirs) clean-dirs := $(vmlinux-alldirs) @@ -1124,7 +1128,7 @@ targets := vmlinux # The actual objects are generated when descending, # make sure no implicit rule kicks in -$(sort $(vmlinux-deps)): descend ; +$(sort $(vmlinux-deps) $(subdir-modorder)): descend ; filechk_kernel.release = \ echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" @@ -1345,8 +1349,12 @@ PHONY += modules_check modules_check: modules.order $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $< -modules.order: descend - $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@ +cmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@ + +modules.order: $(subdir-modorder) FORCE + $(call if_changed,modules_order) + +targets += modules.order # Target to prepare building external modules PHONY += modules_prepare diff --git a/scripts/Makefile.build b/scripts/Makefile.build index a1f09bec8c70..2e8810b7e5ed 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -71,7 +71,7 @@ endif # subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...) subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y))) -subdir-modorder := $(sort $(filter %/modules.order, $(modorder))) +subdir-modorder := $(sort $(filter %/modules.order, $(obj-m))) targets-for-builtin := $(extra-y) @@ -83,8 +83,7 @@ ifdef need-builtin targets-for-builtin += $(obj)/built-in.a endif -targets-for-modules := $(obj-m) -targets-for-modules += $(patsubst %.o, %.mod, $(obj-m)) +targets-for-modules := $(patsubst %.o, %.mod, $(filter %.o, $(obj-m))) ifdef need-modorder targets-for-modules += $(obj)/modules.order @@ -361,8 +360,9 @@ endif $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE $(call if_changed_rule,as_o_S) -targets += $(filter-out $(subdir-builtin), $(real-obj-y)) $(real-obj-m) $(lib-y) -targets += $(always-y) $(MAKECMDGOALS) +targets += $(filter-out $(subdir-builtin), $(real-obj-y)) +targets += $(filter-out $(subdir-modorder), $(real-obj-m)) +targets += $(lib-y) $(always-y) $(MAKECMDGOALS) # Linker scripts preprocessor (.lds.S -> .lds) # --------------------------------------------------------------------------- @@ -404,11 +404,16 @@ $(obj)/built-in.a: $(real-obj-y) FORCE # # Create commands to either record .ko file or cat modules.order from # a subdirectory -$(obj)/modules.order: $(subdir-modorder) FORCE - $(Q){ $(foreach m, $(modorder), \ - $(if $(filter $^, $m), cat $m, echo $m);) :; } \ +# Add $(obj-m) as the prerequisite to avoid updating the timestamp of +# modules.order unless contained modules are updated. + +cmd_modules_order = { $(foreach m, $(real-prereqs), \ + $(if $(filter %/modules.order, $m), cat $m, echo $(patsubst %.o,%.ko,$m));) :; } \ | $(AWK) '!x[$$0]++' - > $@ +$(obj)/modules.order: $(obj-m) FORCE + $(call if_changed,modules_order) + # # Rule to compile a set of .o files into one .a file (with symbol table) # diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 748e44d5a1e3..e598b07e6de4 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -32,27 +32,29 @@ obj-m := $(filter-out $(obj-y),$(obj-m)) # Filter out objects already built-in lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) -# Determine modorder. -# Unfortunately, we don't have information about ordering between -y -# and -m subdirs. Just put -y's first. -ifdef need-modorder -modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko)) -endif - # Subdirectories we need to descend into subdir-ym := $(sort $(subdir-y) $(subdir-m) \ $(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m)))) -# Handle objects in subdirs -# --------------------------------------------------------------------------- -# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a -# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) +# Handle objects in subdirs: +# - If we encounter foo/ in $(obj-y), replace it by foo/built-in.a and +# foo/modules.order +# - If we encounter foo/ in $(obj-m), replace it by foo/modules.order +# +# Generate modules.order to determine modorder. Unfortunately, we don't have +# information about ordering between -y and -m subdirs. Just put -y's first. + +ifdef need-modorder +obj-m := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m)) +else +obj-m := $(filter-out %/, $(obj-m)) +endif + ifdef need-builtin obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) else obj-y := $(filter-out %/, $(obj-y)) endif -obj-m := $(filter-out %/, $(obj-m)) # If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))), $(m)))) @@ -81,7 +83,6 @@ endif extra-y := $(addprefix $(obj)/,$(extra-y)) always-y := $(addprefix $(obj)/,$(always-y)) targets := $(addprefix $(obj)/,$(targets)) -modorder := $(addprefix $(obj)/,$(modorder)) obj-m := $(addprefix $(obj)/,$(obj-m)) lib-y := $(addprefix $(obj)/,$(lib-y)) real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) From patchwork Mon Jun 1 05:57:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581367 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1804092A for ; Mon, 1 Jun 2020 05:58:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 008E7206C3 for ; Mon, 1 Jun 2020 05:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991121; bh=ZEk7VSZ7BRka6birUgnpqx0Pg7mPhjdRaAmMLQKlS8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=JlW0z8b/kmQViVYio84r26F4BlFmrtLJU9Pq7Lq1WRCHElP+33FzijwMI8iXKWc7y JYNQJ0hEIQ5zkqXAl9D70M6BlZhhS2JDaRV/F84XqrjqVDSmniFRoT6GpbhfsgCXsU 3QTqaBMZzgjMecf3cxcCC2qiLIribf3fs3v1K9yw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727061AbgFAF6k (ORCPT ); Mon, 1 Jun 2020 01:58:40 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40551 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726117AbgFAF6k (ORCPT ); Mon, 1 Jun 2020 01:58:40 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLk023694; Mon, 1 Jun 2020 14:57:39 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLk023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991060; bh=1ZY49CyuIkrR0Q5lTjivf4ezmBI0pSFT0WVUbhK5B6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kSMD8UIWW7Nl+TRNcsaBmGZVrb2amwWVECR67OsFZsKf0fsIm/vy0b/FjcjjEMViN K09jmyRSeStpkejv683jnGmT+t1Gp2SobadNpJLakAw25/psvjiUT6mo9SK8aKMVvG pJcyWT3ZpBOAaC11cg3utdErel3KkaqwEsc7rBeDdkufzc98CO4jzYg14j+ABjzgYk 1Gpf+/1FYkM1xD+ENpsgVOQrchiCHwEzs4xsGJk1XvILdhiViVdaNasnmYQNRiNg/z v1u5ZCzbICLOOxuVKXCfCNC3DP+ZOTL5ZwKWSlhBQ/ZZAUYgsFRIxyPcCMPQCvIbml m6OcLEfx3mhfg== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Guenter Roeck Subject: [PATCH 07/37] modpost: fix -i (--ignore-errors) MAKEFLAGS detection Date: Mon, 1 Jun 2020 14:57:01 +0900 Message-Id: <20200601055731.3006266-7-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org $(filter -i,$(MAKEFLAGS)) works only for some cases. The representation of $(MAKEFLAGS) depends on various factors: - GNU Make version (version 3.8x or version 4.x) - The context where $(MAKEFLAGS) is expanded (parse stage or recipe) - The presence of other flags like -j In my experiments, $(MAKEFLAGS) is expanded as follows: * GNU Make 3.8x: * without -j option: --no-print-directory -Rri * with -j option * parse stage --no-print-directory -Rri * recipe line --no-print-directory -Rr --jobserver-fds=3,4 -j -i * GNU Make 4.x: * without -j option irR --no-print-directory * with -j option * parse stage irR --no-print-directory * recipe line irR -j --jobserver-fds=3,4 --no-print-directory If you use GNU Make 4.x, the flags are grouped together like 'irR', which does not work. For the single thread build with GNU Make 3.8x, the flags are grouped like '-Rri', which does not work either. To make it work for all cases, do likewise as commit 6f0fa58e4596 ("kbuild: simplify silent build (-s) detection"). BTW, since commit ff9b45c55b26 ("kbuild: modpost: read modules.order instead of $(MODVERDIR)/*.mod"), you also need to pass -k option to build final *.ko files. 'make -i -k' ignores compile errors in modules, and build as many remaining *.ko as possible. Please note this feature is kind of dangerous because a module may depend on another module. If the prerequisite module fails to build, other modules may lack the correct module dependency or CRC. Honestly, I am not a big fan of it, but I am keeping this feature. Fixes: eed380f3f593 ("modpost: Optionally ignore secondary errors seen if a single module build fails") Cc: Guenter Roeck Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index b79bf0e30d32..451bbd16c3cd 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -66,7 +66,7 @@ __modpost: else -MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \ +MODPOST += -s -T - \ $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) ifeq ($(KBUILD_EXTMOD),) @@ -82,6 +82,10 @@ include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \ $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile) endif +ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),) +MODPOST += -n +endif + # find all modules listed in modules.order modules := $(sort $(shell cat $(MODORDER))) From patchwork Mon Jun 1 05:57:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581351 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D341692A for ; Mon, 1 Jun 2020 05:58:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEE4C20734 for ; Mon, 1 Jun 2020 05:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991106; bh=1ZdFgKf+dWs0gUl2Q2ObuPa99hNbTERyAhxKt8XebEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=z3gIAIpIxYteBe+Jz46kWJx8mzVybPAtKlow0+bEIvTSSx8gDQ/8csqMUn0WgcJP9 KEYVTf65/oui5EbsE6UNv+p1qfKB/ql+liLCbDWiHEhnuyKb3rU2xIRMy0B7LsmoTi jATkuj0Q8IFz++L2eU9+AmjdPAai0dTj0ZFwXoe8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727084AbgFAF60 (ORCPT ); Mon, 1 Jun 2020 01:58:26 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40029 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727779AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLl023694; Mon, 1 Jun 2020 14:57:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLl023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991060; bh=FDesWtJXtTHMJSYjXh/pRBsAfXid1Z+pjw3fNEOySCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CgqqHN8didlkYmaGkyaQoPEp4cMTAfL2/4YdroaNy8ESGiUTWmq5/BLEiEQlm3LLA WDfQ81OIaeSQgxv01jem4MRoA2Y4uzyCAdAFGGGqlLsTQdMr3e5yH9D19U1QhhdPIi PEFmygRgbwkyKBe4Kbd2Id6DKVJiknrEn6DvbGoc5FjWtC/H/Y6QiGjL4D2ELxKOMW l8xt80fJCyZBdjX9AaowKNCUJzdoiv9rNqc+6rmkEeYm15BjccWHxHLc5yfV+Wv1+P 7Io7u+eTiGSAEDDsd7fnwrBpR6DeiM8pI8A3PHNR5mIM29JI36NAxbhQ3YQ9+/53mF UcXIVObTCqPdg== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 08/37] modpost: move -T option close to the modpost command Date: Mon, 1 Jun 2020 14:57:02 +0900 Message-Id: <20200601055731.3006266-8-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The '-T -' option reads the file list from stdin. It is clearer to put it close to the piped command. Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 451bbd16c3cd..95f303a2323e 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -66,7 +66,7 @@ __modpost: else -MODPOST += -s -T - \ +MODPOST += -s \ $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) ifeq ($(KBUILD_EXTMOD),) @@ -92,7 +92,7 @@ modules := $(sort $(shell cat $(MODORDER))) # Read out modules.order instead of expanding $(modules) to pass in modpost. # Otherwise, allmodconfig would fail with "Argument list too long". quiet_cmd_modpost = MODPOST $(words $(modules)) modules - cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST) + cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST) -T - __modpost: $(call cmd,modpost) From patchwork Mon Jun 1 05:57:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581313 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A2FD159A for ; Mon, 1 Jun 2020 05:58:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1853720734 for ; Mon, 1 Jun 2020 05:58:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991102; bh=SmwiaZFDhbmK9JoP9eojmLEmfzI9tReH8pFYi4phpPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=GYdcLjIHVqjGXQ9VxtBJb1BtNBthjTAkRzv58Q300nSOgtf4NUA9lzIXeWxvv4+ej BZZo1H8Jm1sLMeqsRjoLAFYmIPJpjWYjG4yrWUySejZpd4rI+x0d8/RinV5SdrdPJ4 GjwIahG2T/LtVxGOyV9yTTZwRb9TFjXvBT47UcKY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726151AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:39996 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726225AbgFAF6U (ORCPT ); Mon, 1 Jun 2020 01:58:20 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLm023694; Mon, 1 Jun 2020 14:57:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLm023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991060; bh=0mcughTaNFDCYNzMHI0+9bbxtOVuVTfFQEhpUArACs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qpyNRWsrZAcnhxytF/UYngtIWRisnQFSmeowoH4BeTJt1jYXEQo0WyPQN6isQ4aZP ejnUU+F9GYldxCSZ6vKQys82l4QpgDGei1ZO8dULTb0/Y2HDgN+WkkfSoSugzi1b2L cXkhRGjPUhz921kUAqrBRJYsvoP0QRNitpFovB0Cju3VNe8Lk+EBEdHKBIACy/zg+f 5ekYOHlgkBQKl5hfFn7qHNYCPYsgMEjPOZnaV7WrPV8vH8bF9ADZLB0qNrkqdBNHvh Bw/GpCGaCGfGvrX4D5BOWMKN8FroYsi86deMWzSsC7O7ItEKIbMTXPIQmyvDwKDpE1 7EIGv8JyTQ29Q== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 09/37] modpost: pass -N option only for modules modpost Date: Mon, 1 Jun 2020 14:57:03 +0900 Message-Id: <20200601055731.3006266-9-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The built-in only code is not required to have MODULE_IMPORT_NS() to use symbols. So, the namespace is not checked for vmlinux(.o). Do not pass the meaningless -N option to the first pass of modpost. Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 95f303a2323e..02d9f08a20a7 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -53,7 +53,6 @@ MODPOST = scripts/mod/modpost \ $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ - $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) \ $(if $(KBUILD_MODPOST_WARN),-w) ifdef MODPOST_VMLINUX @@ -82,6 +81,10 @@ include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \ $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile) endif +# modpost options for modules (both in-kernel and external) +MODPOST += \ + $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) + ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),) MODPOST += -n endif From patchwork Mon Jun 1 05:57:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581311 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0ACFF1667 for ; Mon, 1 Jun 2020 05:58:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD1F920734 for ; Mon, 1 Jun 2020 05:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991101; bh=bEb5bIrmULG4+WBmjbTZlcDI8ee+HrIyNW5WT+Y15ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jHjbttd3LYY4igTwIJ5yKosfl9HXs7+lMbi26k603J6HZWM38uRoeyXvtPzL089pd LnmwdsJugvL0NBeqpnZwUO40JP/wvuWsz9FAmHS3jYu3lXc3ovuiZ1LDEnALj0bOpr /aTVioKD52qhEzh6+2Y82bNK2HIprPw7oq5a3kag= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726126AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:39998 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726151AbgFAF6U (ORCPT ); Mon, 1 Jun 2020 01:58:20 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLn023694; Mon, 1 Jun 2020 14:57:41 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLn023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991061; bh=8omp1ak2zJDPcGwE4krnaIiaOAFMT3vUAPBeNO3RNiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kb20fRFsITf3rTNBDP5MnKPt/e5Kd9qJrYfLdFpeL7CJOSqREo+lsE8SdaMeUnP1r nF8Lk/LM7CzF3V4mwD6FXhTCXgSigkP6FoWmm2r3d1JuS77rWiJeMExFS/CTuprAI5 JTJij6WM3E33tYEE1lz34x3RiS6Cr1DAAwt4yhhxttr9sRuaY0KgmUBIktuIogVqvG b/rDaAT/253Xs1vvTcZ9pi5UOAzY72bRL4J0ZYxonHHQLnd3s5ErwkOIwCZqKVGBKj j1kQw50b8KsNqFw9nsylNw3ISGjTqpXvTGeKqI7T+/syNab5W71MM12SNltRgImqRz PoGpMzGaDCCJw== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 10/37] modpost: load KBUILD_EXTRA_SYMBOLS files in order Date: Mon, 1 Jun 2020 14:57:04 +0900 Message-Id: <20200601055731.3006266-10-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Currently, modpost reads extra symbol dump files in the reverse order. If '-e foo -e bar' is given, modpost reads bar, foo, in this order. This is probably not a big deal, but there is no good reason to reverse the order. Read files in the given order. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 160139508821..5224a02edbf2 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2555,8 +2555,8 @@ int main(int argc, char **argv) int opt; int err; int n; - struct ext_sym_list *extsym_iter; struct ext_sym_list *extsym_start = NULL; + struct ext_sym_list **extsym_iter = &extsym_start; while ((opt = getopt(argc, argv, "i:e:mnsT:o:awENd:")) != -1) { switch (opt) { @@ -2566,11 +2566,9 @@ int main(int argc, char **argv) break; case 'e': external_module = 1; - extsym_iter = - NOFAIL(malloc(sizeof(*extsym_iter))); - extsym_iter->next = extsym_start; - extsym_iter->file = optarg; - extsym_start = extsym_iter; + *extsym_iter = NOFAIL(calloc(1, sizeof(**extsym_iter))); + (*extsym_iter)->file = optarg; + extsym_iter = &(*extsym_iter)->next; break; case 'm': modversions = 1; @@ -2610,10 +2608,12 @@ int main(int argc, char **argv) if (kernel_read) read_dump(kernel_read, 1); while (extsym_start) { + struct ext_sym_list *tmp; + read_dump(extsym_start->file, 0); - extsym_iter = extsym_start->next; + tmp = extsym_start->next; free(extsym_start); - extsym_start = extsym_iter; + extsym_start = tmp; } while (optind < argc) From patchwork Mon Jun 1 05:57:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581323 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6FB3175D for ; Mon, 1 Jun 2020 05:58:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F2AF206C3 for ; Mon, 1 Jun 2020 05:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991103; bh=g5Z/qMWkN2+80lsUh7sdD8ODzbVMnClofzK2I0ksKEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=C+j5b+PM2CVIS5JSgi3+d2z0pNPbnjVPq+2PSCRpRT7shBxlqa7VVeaSlz2vGKAsH oLGOzzJ8cdQ3VBOitmB3ZaRSt1WTelngRXb2BSLI+D+vR/0hLpe38Cf8vYgrWv0b4H MZIsF5AEZUv72+yCLldmkqlzr/FWwld3OSsubbEk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727013AbgFAF6X (ORCPT ); Mon, 1 Jun 2020 01:58:23 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40015 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727096AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLo023694; Mon, 1 Jun 2020 14:57:41 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLo023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991061; bh=+UGagzfZCEaC9du0sSFD0E//kPkremizC8SiAGDLSL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Liu9h2NkY5vyjoNvnz+ZPp6QkwIR0VLZbOtzTPDnxXPjMqaoZ11QEmMCYD30vpQ5s YV//+F/kORl4HNT0F0Zp8vRifkY1xCgcYkGu9D9nyGyTNaItyagK/PqwO8hU2Admaw S8urkaNSDDckl9aCwoy37qYoe8looaopGC1luCmpg3CFMpk3ytY0qZei3VLG+UWg0l 570eJ6olBuj3EEBoAuTecRHdcR0bh/I4KbRu9Z3j5lrwe/vhhGcd9yRtbV52zBGINe URMIEcz8VNZ2OyYgvUO5PLi3pRjT+W7SoVafU4aEzadFsDN3QM00nwyiyRFyYR2X8i tixyMgO00Gc5A== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 11/37] modpost: track if the symbol origin is a dump file or ELF object Date: Mon, 1 Jun 2020 14:57:05 +0900 Message-Id: <20200601055731.3006266-11-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The meaning of sym->kernel is obscure; it is set for in-kernel symbols loaded from Modules.symver. This happens only when we are building external modules, and it is used to determine whether to dump symbols to $(KBUILD_EXTMOD)/Modules.symver It is clearer to remember whether the symbol or module came from a dump file or ELF object. This changes the KBUILD_EXTRA_SYMBOLS behavior. Previously, symbols loaded from KBUILD_EXTRA_SYMBOLS are accumulated into the current $(KBUILD_EXTMOD)/Modules.symver Going forward, they will be only used to check symbol references, but not dumped into the current $(KBUILD_EXTMOD)/Modules.symver. I believe this makes more sense. sym->vmlinux will have no user. Remove it too. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 15 +++++---------- scripts/mod/modpost.h | 1 + 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 5224a02edbf2..60f35b89cea2 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -161,9 +161,6 @@ struct symbol { int crc_valid; char *namespace; unsigned int weak:1; - unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ - unsigned int kernel:1; /* 1 if symbol is from kernel - * (only for external modules) **/ unsigned int is_static:1; /* 1 if symbol is not global */ enum export export; /* Type of export */ char name[]; @@ -398,8 +395,6 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, } s->module = mod; - s->vmlinux = is_vmlinux(mod->name); - s->kernel = 0; s->export = export; return s; } @@ -2427,7 +2422,7 @@ static void write_if_changed(struct buffer *b, const char *fname) /* parse Module.symvers file. line format: * 0x12345678symbolmoduleexportnamespace **/ -static void read_dump(const char *fname, unsigned int kernel) +static void read_dump(const char *fname) { unsigned long size, pos = 0; void *file = grab_file(fname, &size); @@ -2465,9 +2460,9 @@ static void read_dump(const char *fname, unsigned int kernel) have_vmlinux = 1; mod = new_module(modname); mod->skip = 1; + mod->from_dump = 1; } s = sym_add_exported(symname, mod, export_no(export)); - s->kernel = kernel; s->is_static = 0; sym_set_crc(symname, crc); sym_update_namespace(symname, namespace); @@ -2487,7 +2482,7 @@ static int dump_sym(struct symbol *sym) { if (!external_module) return 1; - if (sym->vmlinux || sym->kernel) + if (sym->module->from_dump) return 0; return 1; } @@ -2606,11 +2601,11 @@ int main(int argc, char **argv) } if (kernel_read) - read_dump(kernel_read, 1); + read_dump(kernel_read); while (extsym_start) { struct ext_sym_list *tmp; - read_dump(extsym_start->file, 0); + read_dump(extsym_start->file); tmp = extsym_start->next; free(extsym_start); extsym_start = tmp; diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 39f6c29fb568..b8b7a82d2ff7 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -119,6 +119,7 @@ struct module { const char *name; int gpl_compatible; struct symbol *unres; + int from_dump; /* 1 if module was loaded from *.symver */ int seen; int skip; int has_init; From patchwork Mon Jun 1 05:57:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581315 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5FB1517D5 for ; Mon, 1 Jun 2020 05:58:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3ECFA206C3 for ; Mon, 1 Jun 2020 05:58:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991102; bh=j/99I8l31L9W4H9NBnDzaFsrp8pEF5DlGBCuUTTLZYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zl+8eSH94GcXc/71sHwOIJjo8vJvLG5Oz+j+DDqOZvx9CBm3OCZkfYZ2iWG7NDSbT +X6anLE5td7pTn2aGU9QXX6c5YTveOsqSJIW5H5VFYMkz/UviV6EBea3dFGxLVwMbL BroVCmEl9EF0pBWTZaqQ6sadCPzIFGRAvLGBsFww= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726225AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:39991 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbgFAF6U (ORCPT ); Mon, 1 Jun 2020 01:58:20 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLp023694; Mon, 1 Jun 2020 14:57:41 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLp023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991062; bh=T5tRGhmnaSONH3u55YdrjS1NdKpUcBqfkDd+Pt4a26E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yMoxx70SPX5tNjBBYi4jAnAeJhyGKKLzLkuASNu8ZJd4EPY2qZ4iwmhc1/o8rjHys YmlQKH6+c6WpKBrAHBuKO8wp4DxEFfuP2z4zVrHdJYpO7LZJDdSinA3KqDzSlVDUUB GFsls36kEb4pzegsf9XtDanPkkJ1JzcPxXLnROpjc3UO2iSdpt3wuPKXPPYxuxVZNM HrkkAfHTbIuc7L2echn97yRsO7Vg2hVaE9mWnv21bRSp1dmAXPV+P/JSui0O37+uwp Ym8nONDMJJpuM8smWLwALcM9ADLqp3W7EU3Crevq5GUm8cvzcGzIItxOYVVHTdvGfR HxRncNhAEiFJQ== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 12/37] modpost: allow to pass -i option multiple times to remove -e option Date: Mon, 1 Jun 2020 14:57:06 +0900 Message-Id: <20200601055731.3006266-12-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Now that there is no difference between -i and -e, they can be unified. Make modpost accept the -i option multiple times, then remove -e. I will reuse -e for a different purpose. Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 2 +- scripts/mod/modpost.c | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 02d9f08a20a7..e527bf838954 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -50,7 +50,7 @@ MODPOST = scripts/mod/modpost \ $(if $(CONFIG_MODVERSIONS),-m) \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ - $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ + $(if $(KBUILD_EXTMOD),$(addprefix -i ,$(KBUILD_EXTRA_SYMBOLS))) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ $(if $(KBUILD_MODPOST_WARN),-w) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 60f35b89cea2..28d8f5377c62 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2544,7 +2544,6 @@ int main(int argc, char **argv) { struct module *mod; struct buffer buf = { }; - char *kernel_read = NULL; char *missing_namespace_deps = NULL; char *dump_write = NULL, *files_source = NULL; int opt; @@ -2553,13 +2552,9 @@ int main(int argc, char **argv) struct ext_sym_list *extsym_start = NULL; struct ext_sym_list **extsym_iter = &extsym_start; - while ((opt = getopt(argc, argv, "i:e:mnsT:o:awENd:")) != -1) { + while ((opt = getopt(argc, argv, "i:mnsT:o:awENd:")) != -1) { switch (opt) { case 'i': - kernel_read = optarg; - external_module = 1; - break; - case 'e': external_module = 1; *extsym_iter = NOFAIL(calloc(1, sizeof(**extsym_iter))); (*extsym_iter)->file = optarg; @@ -2600,8 +2595,6 @@ int main(int argc, char **argv) } } - if (kernel_read) - read_dump(kernel_read); while (extsym_start) { struct ext_sym_list *tmp; From patchwork Mon Jun 1 05:57:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581317 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31C0792A for ; Mon, 1 Jun 2020 05:58:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FC1220734 for ; Mon, 1 Jun 2020 05:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991103; bh=AfG1UFTBgS6yto48MxKly+i510c2ckKlN/L0QoQXU98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jpCUIdBaL4ZGVSjrMKlc0JxYmOJS8dE5NDO0Sprc1F1L5LBJzegZGBW5rLMrrZktz ho5xwgTMKpZOffeCv0jTC/jzicK6rDj+VRWqORkSbO0QOtKb3wkRFLEc0DpD6SKSMY 9ZRgVXNo2JzEnZXHX952yYQX7z5KAR8OnGBXw8pk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726002AbgFAF6W (ORCPT ); Mon, 1 Jun 2020 01:58:22 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40003 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLq023694; Mon, 1 Jun 2020 14:57:42 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLq023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991062; bh=OLmg5iPguTNrk6IbHD7AokOguO5w7b27x1H5GW/sCTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gzhpz/ZstVwUmZdryhUVIdTLFoYezxL/tdjxXnH0oIjZhL8ACOcBgbHxKPyQUCxHf oT8TS0Nhxi17TXvdAhxU6TvbcJZMgamjWtszgiKnUaAUHWdJqCFtWaf2BuRm6qdMi1 +moybh1jfaVn4e6ocHG97E89weAtppBAnuxBM5C0ZtGq04xVbLYtktJHZBlpBWiLCL ASK6yLkBLRn7r0nm8AF6Jxn5GHEpcTdMpqlsYv7+MVEPzMkb5G1wzp0ubqJhFRHlXs arWLDMdNl0LW/r+7qqrSpQqRZ0lTfAhLL+uV/wdK1u3vOx9BpQZbbCQouqq+pa83wl VR3oGGEGqqj9w== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 13/37] modpost: rename ext_sym_list to dump_list Date: Mon, 1 Jun 2020 14:57:07 +0900 Message-Id: <20200601055731.3006266-13-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The -i option is used to include Modules.symver as well as files from $(KBUILD_EXTRA_SYMBOLS). Make the struct and variable names more generic. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 28d8f5377c62..b8e521f50b2d 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2535,8 +2535,8 @@ static void write_namespace_deps_files(const char *fname) free(ns_deps_buf.p); } -struct ext_sym_list { - struct ext_sym_list *next; +struct dump_list { + struct dump_list *next; const char *file; }; @@ -2549,16 +2549,17 @@ int main(int argc, char **argv) int opt; int err; int n; - struct ext_sym_list *extsym_start = NULL; - struct ext_sym_list **extsym_iter = &extsym_start; + struct dump_list *dump_read_start = NULL; + struct dump_list **dump_read_iter = &dump_read_start; while ((opt = getopt(argc, argv, "i:mnsT:o:awENd:")) != -1) { switch (opt) { case 'i': external_module = 1; - *extsym_iter = NOFAIL(calloc(1, sizeof(**extsym_iter))); - (*extsym_iter)->file = optarg; - extsym_iter = &(*extsym_iter)->next; + *dump_read_iter = + NOFAIL(calloc(1, sizeof(**dump_read_iter))); + (*dump_read_iter)->file = optarg; + dump_read_iter = &(*dump_read_iter)->next; break; case 'm': modversions = 1; @@ -2595,13 +2596,13 @@ int main(int argc, char **argv) } } - while (extsym_start) { - struct ext_sym_list *tmp; + while (dump_read_start) { + struct dump_list *tmp; - read_dump(extsym_start->file); - tmp = extsym_start->next; - free(extsym_start); - extsym_start = tmp; + read_dump(dump_read_start->file); + tmp = dump_read_start->next; + free(dump_read_start); + dump_read_start = tmp; } while (optind < argc) From patchwork Mon Jun 1 05:57:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581327 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2FB1B17D5 for ; Mon, 1 Jun 2020 05:58:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 139A7206C3 for ; Mon, 1 Jun 2020 05:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991104; bh=o9QQfMDqIXtRReLdHCtzywYkC0qSOMRM71KzlK4kYNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TqQcsFNIuJA11/DHi4eNguzxwyTok6egQ0gyd6BdXaFjqUAFAqlP+1KhMsEyA9LQw VB+0CgJ5LQPDJ5Up5AK66qw7N0q650H5Ye2OLuBLaiQgIZfh9G1CRt8USXiXdDVt6U p0xooRlQOGoDr9TYnkVhSJnudB2pVakb2stGXzd4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726289AbgFAF6X (ORCPT ); Mon, 1 Jun 2020 01:58:23 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40002 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726778AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLr023694; Mon, 1 Jun 2020 14:57:42 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLr023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991062; bh=QeQlYsVShtipD6xSMzcGZNTncldeQ++6rmoWFJayBAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HWlv/OEQts6qQgmvJCk3Qv2EiAXvhLXJQ26WDU4TH02/HjNJpyxIWeZ46jDfgwhOG 58UboniRrFY2VzR5EGUCOKS6Q3dtXCKX3r91YidJOpgQ+xy6I9VMhDxAQWSEZci2js iidI3AC9G6ZBAoSoS/BHLfTMm105y/nFKkD8JWX+et5kq5NfjfgQEweGi4bDnhMxK5 JdTTrZpuY1vKXyyb7CuWPF9bITvaxdrS9owoRtxyunjTuMl2QjCUHWIuAHsDsB1gOS P47OrGH0SjSLTCYvIRpAf/YbzchdCxaJ7FSKXQGf7dVEXUo3tiSN04JWqhhBcYwuzF rRFMPagwKzLpw== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 14/37] modpost: re-add -e to set external_module flag Date: Mon, 1 Jun 2020 14:57:08 +0900 Message-Id: <20200601055731.3006266-14-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Previously, the -i option had two functions; load a symbol dump file, and set the external_module flag. I want to assign a dedicate option for each of them. Going forward, the -i is used to load a symbol dump file, and the -e to set the external_module flag. With this, we will be able to use -i for loading in-kernel symbols. Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 4 ++++ scripts/mod/modpost.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index e527bf838954..b017085dc91a 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -79,6 +79,10 @@ src := $(obj) # Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \ $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile) + +# modpost option for external modules +MODPOST += -e + endif # modpost options for modules (both in-kernel and external) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index b8e521f50b2d..4a2f27d97bf1 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2552,10 +2552,12 @@ int main(int argc, char **argv) struct dump_list *dump_read_start = NULL; struct dump_list **dump_read_iter = &dump_read_start; - while ((opt = getopt(argc, argv, "i:mnsT:o:awENd:")) != -1) { + while ((opt = getopt(argc, argv, "ei:mnsT:o:awENd:")) != -1) { switch (opt) { - case 'i': + case 'e': external_module = 1; + break; + case 'i': *dump_read_iter = NOFAIL(calloc(1, sizeof(**dump_read_iter))); (*dump_read_iter)->file = optarg; From patchwork Mon Jun 1 05:57:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581355 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43F8A1667 for ; Mon, 1 Jun 2020 05:58:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 277B420734 for ; Mon, 1 Jun 2020 05:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991107; bh=S/zOm6Bo0Iu8D/zPsTyxw9Kmn6jVaKrEABbjbhbvFe8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=n3KhVKKN4viToi9Z24K6x7fRqPEj32DppdciUJTIv2jEAM50qgBodGmX5YGIv882u HINTWWL68fefxvlKMd8hPd9YadvvjMlC/UKZt4zZ5TTcpgd27M7MGlLwSUR6ifgXEY ofRMuiOtYXFxEXzxpQ+t+y4dJk+1Et0SLPNENBwg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727100AbgFAF60 (ORCPT ); Mon, 1 Jun 2020 01:58:26 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40021 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727119AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLs023694; Mon, 1 Jun 2020 14:57:43 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLs023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991063; bh=azQaBYAAtJn5mbVirnZw3fH+NUbaFN9gqUF5TIHKRew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PG3pXT7dz7YNioKBPtqRXqE6VcNsZrNOygL6q43dLXTbXUmzQExT0yDRWunOOtSBf NCBXgjzeLGtkrNhpciInb//PUHazwz6wZQuKnWKYI0BtTEcoGRvePnqZipxQ38ubQW P7KmeXMIo6mSCq4w6XICMf7YxpdVEaKn94zHUEmELh5kyMOXQ5hD2IfnUW43avZ/fl +RVv1Zrl9B7n6oYjbJwmz8CSdEXY+7BgKChyfPvkL93hzrk6fIPSfV+ueNEW2hBl0u SQUWp0UMgRYRAhkJFGDz2J2hMXiipPy9vARDyBsoy+hcCJs94GOJ0tDtLokPL42BAQ HnPuz8XdiJO2A== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 15/37] modpost: print symbol dump file as the build target in short log Date: Mon, 1 Jun 2020 14:57:09 +0900 Message-Id: <20200601055731.3006266-15-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The symbol dump *.symvers is the output of modpost. Print it in the short log. Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index b017085dc91a..8d000987b201 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -44,25 +44,26 @@ include include/config/auto.conf include scripts/Kbuild.include kernelsymfile := $(objtree)/Module.symvers -modulesymfile := $(KBUILD_EXTMOD)/Module.symvers MODPOST = scripts/mod/modpost \ $(if $(CONFIG_MODVERSIONS),-m) \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ - $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ + $(if $(KBUILD_EXTMOD),-i $(kernelsymfile)) \ $(if $(KBUILD_EXTMOD),$(addprefix -i ,$(KBUILD_EXTRA_SYMBOLS))) \ - $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ - $(if $(KBUILD_MODPOST_WARN),-w) + $(if $(KBUILD_MODPOST_WARN),-w) \ + -o $@ ifdef MODPOST_VMLINUX -quiet_cmd_modpost = MODPOST vmlinux.o - cmd_modpost = $(MODPOST) vmlinux.o +quiet_cmd_modpost = MODPOST $@ + cmd_modpost = $(MODPOST) $< -__modpost: +Module.symvers: vmlinux.o $(call cmd,modpost) +__modpost: Module.symvers + else MODPOST += -s \ @@ -70,6 +71,8 @@ MODPOST += -s \ ifeq ($(KBUILD_EXTMOD),) MODPOST += $(wildcard vmlinux) +output-symdump := Module.symvers + else # set src + obj - they may be used in the modules's Makefile @@ -83,6 +86,8 @@ include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \ # modpost option for external modules MODPOST += -e +output-symdump := $(KBUILD_EXTMOD)/Module.symvers + endif # modpost options for modules (both in-kernel and external) @@ -93,20 +98,22 @@ ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),) MODPOST += -n endif -# find all modules listed in modules.order -modules := $(sort $(shell cat $(MODORDER))) - -# Read out modules.order instead of expanding $(modules) to pass in modpost. +# Read out modules.order to pass in modpost. # Otherwise, allmodconfig would fail with "Argument list too long". -quiet_cmd_modpost = MODPOST $(words $(modules)) modules +quiet_cmd_modpost = MODPOST $@ cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST) -T - -__modpost: +$(output-symdump): FORCE $(call cmd,modpost) + +__modpost: $(output-symdump) ifneq ($(KBUILD_MODPOST_NOFINAL),1) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal endif +PHONY += FORCE +FORCE: + endif .PHONY: $(PHONY) From patchwork Mon Jun 1 05:57:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581337 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87C161667 for ; Mon, 1 Jun 2020 05:58:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E69B20734 for ; Mon, 1 Jun 2020 05:58:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991105; bh=VKDjsz/c4rxxRuXAif25FA7Q06SP6xvRBcGizgbsseA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=JFCvq3fs/XswPS7TbgxwJwEnoBIk8xq64+PkKsS4YNjYjqNzvzYRP96Ldf5Df1SPL RJPs9CYXIfaJc+my9F+Oyb2pFd1L6Af1ghY/4yzLFOKRLu+9RTpcQPgcoQP7j0qN/O 67qYewHdO97ItrNQaqZExPt1AIz74p4cTmYIzrcM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727056AbgFAF6Y (ORCPT ); Mon, 1 Jun 2020 01:58:24 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40022 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727118AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLt023694; Mon, 1 Jun 2020 14:57:43 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLt023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991063; bh=S7zu9zwrCmIZaiNJwTUCHb4MomgyEqPzr3MvbiVgGGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IimoL7fuVL8ZsWm1T9xORtD7bR2A2phyZSlUBDgH2d5y550mzv5A57Slf0oeL5zkV aUB0Rg5mTLlosgIyVQHdFI78A/xpJMSnK4147vI7JGKTXkFwD6puZIzHDUhwnU0xOz +BJxL3i4276Wzzp/VzGxZlXqB2fU7WwfORdMgDN+JaWTZlaA4YcruW+TvC6C48XylY FU+zGA35zhtpHCXYpreL57ZGzSnBl4aexA4mpTn1FRLekqKT8r6KapWMpNY2HlaYcC xQo9tcnpM65zpHOGsvqZPjGIXslbRwh9Dr8hJ6NcqGkDsT66SiONE52T4gJNCfA2au EGonv/xjTeAAQ== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 16/37] modpost: refactor -i option calculation Date: Mon, 1 Jun 2020 14:57:10 +0900 Message-Id: <20200601055731.3006266-16-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Prepare to use -i for in-tree modpost as well. Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 8d000987b201..6808086075b6 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -43,13 +43,9 @@ __modpost: include include/config/auto.conf include scripts/Kbuild.include -kernelsymfile := $(objtree)/Module.symvers - MODPOST = scripts/mod/modpost \ $(if $(CONFIG_MODVERSIONS),-m) \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ - $(if $(KBUILD_EXTMOD),-i $(kernelsymfile)) \ - $(if $(KBUILD_EXTMOD),$(addprefix -i ,$(KBUILD_EXTRA_SYMBOLS))) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ $(if $(KBUILD_MODPOST_WARN),-w) \ -o $@ @@ -86,12 +82,14 @@ include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \ # modpost option for external modules MODPOST += -e +input-symdump := Module.symvers $(KBUILD_EXTRA_SYMBOLS) output-symdump := $(KBUILD_EXTMOD)/Module.symvers endif # modpost options for modules (both in-kernel and external) MODPOST += \ + $(addprefix -i ,$(input-symdump)) \ $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),) From patchwork Mon Jun 1 05:57:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581325 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0DB5992A for ; Mon, 1 Jun 2020 05:58:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA2EB206C3 for ; Mon, 1 Jun 2020 05:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991104; bh=HMfxvVougyqUoMeKpVmAYvimWIyX1uaiSKf7DPnXRfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=dLKOoEgz09eTvZIOj8sohntMNTPMO0X1VihWx83O6wVTRWNLpHqHdvJt2EkAxTIgP jqVqY8Mi9vzSBqp6FLICJ9LQUp4tjZ8v0Www68VygZ8OUQKxDx16l9siFLA0BoEDD0 XLOL02xD2gEyJxSw9t6Iy5AiM001nNGffPHXSYs4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727068AbgFAF6X (ORCPT ); Mon, 1 Jun 2020 01:58:23 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40001 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726289AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLu023694; Mon, 1 Jun 2020 14:57:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLu023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991064; bh=xEwBuIuAsXFW3T3cgYIqwXll9ICSzKqdHziSibBV4r8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mE5SWFl3NGbRi+MdSUSQX6XucTSz76bYsltEVTqJ8xFczu0wbjx98koQX522dkMHb 5OXdBHUZC7C9aFqtBwscAIjtyTH0iVRoES4Z3cCIc1VMSa3wlh79vI/Ri3vfmFNirU Wm9BIw+vHFjh8lXCwInVHPlE4E1Sq/1c2cwR4AYykduXm1tYuwCwY07iG5mvyme3N7 rJSKT+YtrnjlZOn2yz4V6AemKEz2XX5tDlP8ty8aKv61EzEVH14LmgPsiyJr22JuMv 5AXFJiqydHiYvxjHXtPmYdVqvMnO1JmVlZ+JgR33ay6ZdU5u/nPOkMnvXJlF3qWW3e gLC5rzW7lRy5w== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 17/37] modpost: generate vmlinux.symvers and reuse it for the second modpost Date: Mon, 1 Jun 2020 14:57:11 +0900 Message-Id: <20200601055731.3006266-17-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The full build runs modpost twice, first for vmlinux.o and second for modules. The first pass dumps all the vmlinux symbols into Module.symvers, but the second pass parses vmlinux again instead of reusing the dump file, presumably because it needs to avoid accumulating stale symbols. Loading symbol info from a dump file is faster than parsing an ELF object. Besides, modpost deals with various issues to parse vmlinux in the second pass. A solution is to make the first pass dumps symbols into a separate file, vmlinux.symvers. The second pass reads it, and parses module .o files. The merged symbol information is dumped into Module.symvers in the same way as before. This makes further modpost cleanups possible. Also, it fixes the problem of 'make vmlinux', which previously overwrote Module.symvers, throwing away module symbols. I slightly touched scripts/link-vmlinux.sh so that vmlinux is re-linked when you cross this commit. Otherwise, vmlinux.symvers would not be generated. Signed-off-by: Masahiro Yamada --- .gitignore | 1 + Documentation/dontdiff | 1 + Makefile | 2 +- scripts/Makefile.modpost | 7 ++++--- scripts/link-vmlinux.sh | 2 -- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 2258e906f01c..87b9dd8a163b 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,7 @@ modules.order /linux /vmlinux /vmlinux.32 +/vmlinux.symvers /vmlinux-gdb.py /vmlinuz /System.map diff --git a/Documentation/dontdiff b/Documentation/dontdiff index 72fc2e9e2b63..ef9519c32c55 100644 --- a/Documentation/dontdiff +++ b/Documentation/dontdiff @@ -251,6 +251,7 @@ vmlinux-* vmlinux.aout vmlinux.bin.all vmlinux.lds +vmlinux.symvers vmlinuz voffset.h vsyscall.lds diff --git a/Makefile b/Makefile index b40420a0b991..6280c7597a2d 100644 --- a/Makefile +++ b/Makefile @@ -1416,7 +1416,7 @@ endif # CONFIG_MODULES # make distclean Remove editor backup files, patch leftover files and the like # Directories & files removed with 'make clean' -CLEAN_FILES += include/ksym \ +CLEAN_FILES += include/ksym vmlinux.symvers \ modules.builtin modules.builtin.modinfo modules.nsdeps # Directories & files removed with 'make mrproper' diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 6808086075b6..6db692a5d547 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -55,10 +55,10 @@ ifdef MODPOST_VMLINUX quiet_cmd_modpost = MODPOST $@ cmd_modpost = $(MODPOST) $< -Module.symvers: vmlinux.o +vmlinux.symvers: vmlinux.o $(call cmd,modpost) -__modpost: Module.symvers +__modpost: vmlinux.symvers else @@ -66,7 +66,8 @@ MODPOST += -s \ $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) ifeq ($(KBUILD_EXTMOD),) -MODPOST += $(wildcard vmlinux) + +input-symdump := vmlinux.symvers output-symdump := Module.symvers else diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index d09ab4afbda4..d5af6be50b50 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -218,8 +218,6 @@ on_signals() } trap on_signals HUP INT QUIT TERM -# -# # Use "make V=1" to debug this script case "${KBUILD_VERBOSE}" in *1*) From patchwork Mon Jun 1 05:57:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581347 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 55163175D for ; Mon, 1 Jun 2020 05:58:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BC5E20734 for ; Mon, 1 Jun 2020 05:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991106; bh=05lyhn5Db4iKyDdh5KOTfjrqjJBrVh2kkD/ILUziKwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Nn9zguSM2WM552Mzvi9ROuBgFtw6OrbC7qDnBxUyz8Nr5bpeACDMEbc7eiNbyG6AD mSInLDp/NpFpzhSbSQy5ZqXeAa9VhkQsiKRZXaMMSk7HasvWpWPmRNG/psX28Sj223 SC8E1ELRxTY2/ZoM9o056+Ocv81pVONC9039bMIA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727121AbgFAF6Z (ORCPT ); Mon, 1 Jun 2020 01:58:25 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40008 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727063AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLv023694; Mon, 1 Jun 2020 14:57:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLv023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991064; bh=M0QIACDAMEg1I/5ZJ7oG1lK0GQ0SehV+xiXMe4lYcZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UE+O7ja251FnXiORhxf21kmwXLzIMLWPOo4V961eafT9BH9/OZxk0yCATWvf+Q8TM 3BbXh7msM352iAD5WrhAw9xOvLNqWBp8q1HkWTv0DvJh/NgOYw0z5HkcWJFZ4XPfGF 6MmbbBnUXRvDdMP6xlji/hcQ++XPKQB1AqpPkT9LEfbsbtO8hq/4n2EAwDdN4l67t8 PRev8ihn6UiThGlRIUxKXomdCfLoeB4V3Wo1FdOLvcb+yLxMBYOWHMF56esIhqifnB ssEbVlE7+5nVwdYL4RSUv5Pr+d9K2jJsjSEGFEL8HOmEpwh8HPNZTubsdu8+WJwoyo tVDsWRw3+Qx3w== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 18/37] modpost: invoke modpost only when input files are updated Date: Mon, 1 Jun 2020 14:57:12 +0900 Message-Id: <20200601055731.3006266-18-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Currently, the second pass of modpost is always invoked when you run 'make' or 'make modules' even if none of modules is changed. Use if_changed to invoke it only when it is necessary. Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 20 ++++++++++++++++---- scripts/mod/modpost.c | 32 +++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 6db692a5d547..7d564a39f938 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -90,20 +90,25 @@ endif # modpost options for modules (both in-kernel and external) MODPOST += \ - $(addprefix -i ,$(input-symdump)) \ + $(addprefix -i ,$(wildcard $(input-symdump))) \ $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),) MODPOST += -n endif +$(input-symdump): + @: + # Read out modules.order to pass in modpost. # Otherwise, allmodconfig would fail with "Argument list too long". quiet_cmd_modpost = MODPOST $@ - cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST) -T - + cmd_modpost = sed 's/ko$$/o/' $< | $(MODPOST) -T - -$(output-symdump): FORCE - $(call cmd,modpost) +$(output-symdump): $(MODORDER) $(input-symdump) FORCE + $(call if_changed,modpost) + +targets += $(output-symdump) __modpost: $(output-symdump) ifneq ($(KBUILD_MODPOST_NOFINAL),1) @@ -113,6 +118,13 @@ endif PHONY += FORCE FORCE: +existing-targets := $(wildcard $(sort $(targets))) + +-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) + +PHONY += FORCE +FORCE: + endif .PHONY: $(PHONY) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 4a2f27d97bf1..b839c48689df 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2375,6 +2375,25 @@ static void add_srcversion(struct buffer *b, struct module *mod) } } +static void write_buf(struct buffer *b, const char *fname) +{ + FILE *file; + + file = fopen(fname, "w"); + if (!file) { + perror(fname); + exit(1); + } + if (fwrite(b->p, 1, b->pos, file) != b->pos) { + perror(fname); + exit(1); + } + if (fclose(file) != 0) { + perror(fname); + exit(1); + } +} + static void write_if_changed(struct buffer *b, const char *fname) { char *tmp; @@ -2407,16 +2426,7 @@ static void write_if_changed(struct buffer *b, const char *fname) close_write: fclose(file); write: - file = fopen(fname, "w"); - if (!file) { - perror(fname); - exit(1); - } - if (fwrite(b->p, 1, b->pos, file) != b->pos) { - perror(fname); - exit(1); - } - fclose(file); + write_buf(b, fname); } /* parse Module.symvers file. line format: @@ -2508,7 +2518,7 @@ static void write_dump(const char *fname) symbol = symbol->next; } } - write_if_changed(&buf, fname); + write_buf(&buf, fname); free(buf.p); } From patchwork Mon Jun 1 05:57:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581307 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ADB1192A for ; Mon, 1 Jun 2020 05:58:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 893F0206C3 for ; Mon, 1 Jun 2020 05:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991101; bh=v/UiojZJaJchyiU+NcA/rXOOTDMaDrCiiAaBP96x5Ko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=vvQXaUSnOm1bB3eE0yzvEZYSLkidLNbSnCDQVb2cnxe51wtafB/WuJroTbFpd5NR4 4dhFykqr1MkIRrkuv734k1SxSER3QhqfRjMDcGf2QYfWsgHlHXY2djV307SGB9IScn 8TtFOAY6rBuAuFJUMPomvBo9y8qEiPWMnc/qGYxQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727802AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:39993 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726070AbgFAF6U (ORCPT ); Mon, 1 Jun 2020 01:58:20 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLw023694; Mon, 1 Jun 2020 14:57:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLw023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991064; bh=9VqqB2s4BsnlGF3SwC/MwZVfCWNmLbttMQU+F6+MrbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V613Jb2WQ+Z+N8wkkr8HrX2S6qtVI4hOAoUlFLo/GPqdagaPtcjlXs9vf/eFwfSH1 92hFpWf/JaZ81BOfAsJO1VGlbUTehxus7lilnW5ASzRAxFbzyDDiYTXOWsLty5Hjxh X6iqgd3oGS0EsgG3SVfe/sBsRdsFFCdvkkpMYDBGr6nbbSUMHOD6YjBcyn0y2nyHty qzcWCq/6IzB64ZntQFHojmW0SXtCMsjQNk8YHCWgH9y8aa/EpZUWx5taBYuLwFCsnc Dh7VoaDwsoVBMRKQSMXM5BlRdy897O1GvRm+15CnB42Qo8AfIefjP0grAQdSQW1QnH 0uUUS3TXcAJJQ== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 19/37] modpost: show warning if vmlinux is not found when processing modules Date: Mon, 1 Jun 2020 14:57:13 +0900 Message-Id: <20200601055731.3006266-19-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org check_exports() does not print warnings about unresolved symbols if vmlinux is missing because there would be too many. This situation happens when you do 'make modules' from the clean tree, or compile external modules against a kernel tree that has not been completely built. It is dangerous to not check unresolved symbols because you might be building useless modules. At least it should be warned. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index b839c48689df..3df26789c2e6 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2001,8 +2001,6 @@ static void read_symbols(const char *modname) mod = new_module(modname); - /* When there's no vmlinux, don't print warnings about - * unresolved symbols (since there'll be too many ;) */ if (is_vmlinux(modname)) { have_vmlinux = 1; mod->skip = 1; @@ -2623,6 +2621,13 @@ int main(int argc, char **argv) if (files_source) read_symbols_from_files(files_source); + /* + * When there's no vmlinux, don't print warnings about + * unresolved symbols (since there'll be too many ;) + */ + if (!have_vmlinux) + warn("Symbol info of vmlinux is missing. Unresolved symbol check will be entirely skipped.\n"); + err = 0; for (mod = modules; mod; mod = mod->next) { From patchwork Mon Jun 1 05:57:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581365 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4473E60D for ; Mon, 1 Jun 2020 05:58:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D43B2074B for ; Mon, 1 Jun 2020 05:58:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991108; bh=spQjUPAf92tmy9Go2bq2xvuZXvdko3/li7sFCMe0PNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Cllev3tDheWxJyqSizlhz1oIUzOooEvoOhetSAh2lG21wjBT3iRai09Ekiuy+FA+6 uXpRxgFx/VJX21xr8kxtCV8r3bL4LRwjtVKbnfk8+YArF65AtxHI8Gs4htMLPkdREl ORsotW6xfQbS3zrlHfpFgFx9JhkzcW+H/eeKNUDw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbgFAF61 (ORCPT ); Mon, 1 Jun 2020 01:58:27 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40007 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727061AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaLx023694; Mon, 1 Jun 2020 14:57:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaLx023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991065; bh=ImoqVVy6jnEvNzCO7Q2Smi7Gogn5sA+4zyEr4FkJDYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QckgFaypJIHPk8LmmhthUyviDgdS++KPZsCrrrU/LYhfPdCQmA7pcJtYkguedzRfa JSu6gA5sBohtChjtMw/Nbx7RYZLULye765JjgIlLPB2J1eAlkjLDYSejVfhLgaITDn 9Unt4qVsoO1FBybN9e05G0oB1uGZ/5+g0Q4CCyUPkHgUQ6O7LljAUfOHbFjCkGv/t/ NLbbUTHJ4rMtkB6qL43ZCyeECgYK4T1UNdouHIDjPFwdnpWwq/g+1di49JiRSwXO/E ubFYcp48QVX5CitF+G898/XNrjgdnCz+CjbLnhI7DZ1rb373CtEtmBOa73TULq2D/R KfNLYDAgHCOwg== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 20/37] modpost: show warning if any of symbol dump files is missing Date: Mon, 1 Jun 2020 14:57:14 +0900 Message-Id: <20200601055731.3006266-20-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org If modpost fails to load a symbol dump file, it cannot check unresolved symbols, hence module dependency will not be added. Nor CRCs can be added. Currently, external module builds check only $(objtree)/Module.symvers, but it should check files specified by KBUILD_EXTRA_SYMBOLS as well. Move the warning message from the top Makefile to scripts/Makefile.modpost and print the warning if any dump file is missing. Signed-off-by: Masahiro Yamada --- Makefile | 10 +--------- scripts/Makefile.modpost | 5 ++++- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 6280c7597a2d..f80c4ff93ec9 100644 --- a/Makefile +++ b/Makefile @@ -1649,17 +1649,9 @@ else # KBUILD_EXTMOD # We are always building modules KBUILD_MODULES := 1 -PHONY += $(objtree)/Module.symvers -$(objtree)/Module.symvers: - @test -e $(objtree)/Module.symvers || ( \ - echo; \ - echo " WARNING: Symbol version dump $(objtree)/Module.symvers"; \ - echo " is missing; modules will have no dependencies and modversions."; \ - echo ) - build-dirs := $(KBUILD_EXTMOD) PHONY += modules -modules: descend $(objtree)/Module.symvers +modules: descend $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost PHONY += modules_install diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 7d564a39f938..16fe19724c34 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -97,8 +97,11 @@ ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),) MODPOST += -n endif +# Clear VPATH to not search for *.symvers in $(srctree). Check only $(objtree). +VPATH := $(input-symdump): - @: + @echo >&2 'WARNING: Symbol version dump "$@" is missing.' + @echo >&2 ' Modules may not have dependencies or modversions.' # Read out modules.order to pass in modpost. # Otherwise, allmodconfig would fail with "Argument list too long". From patchwork Mon Jun 1 05:57:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581321 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B66260D for ; Mon, 1 Jun 2020 05:58:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82F62206C3 for ; Mon, 1 Jun 2020 05:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991103; bh=Sw9HMrb05oanvB9ukA+N97qFa7YY7TsCL6oQEPAq7LU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=e04LYr5DAacM7p57hgH3scIcOAMggRe63+xdDv3S6nZ2UOyoVaFmCgVyAfdCxej8+ dWlvxBnPVNP6cfrWTmop9Xb0usohq03y0P2utPj7bSFLVQvb42ls400rffu3ThMWUR X/htA3t2QTCSTMwJKx4FoDO8Rq0A8L4udtqytAwE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725973AbgFAF6W (ORCPT ); Mon, 1 Jun 2020 01:58:22 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:39992 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726056AbgFAF6U (ORCPT ); Mon, 1 Jun 2020 01:58:20 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaM0023694; Mon, 1 Jun 2020 14:57:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaM0023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991066; bh=A8ZNE7lF0YmzyG3nrffQEG/n5KXH1UkTXudtbTEqgq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KOoJVQgxSipYMNLVqi3fqK0AR8hJvfbHOQzNkbmmWZ+75g7IJ9gPJ8lObFzgfLEsC vHrFnZfP3qdsAbal8u/2jafZ2dlBWFkvbCKtWDoxyjbDuMxy9sLEUsX8BMjfXHGZnc 3h/cwBTuXInXIk8iC1XnGhdhlBAu8W5BneSrbhR04VSbamD9FsqQvzU0tc0qBI6lQf wN3EthNzjPf6PLkVdY4qPCt9x8FwA4sqZkDBwc6cgy4aSUNCq3sdvU8JzKwGztyj0T fpnCoEWKo4ETbe3ztkgjJf5zg91LjQ36MZUnSL0PMtFyY7OX9WXdtStPCbMVJlRhMq efkqCm/W8kbEw== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 21/37] modpost: drop RCS/CVS $Revision handling in MODULE_VERSION() Date: Mon, 1 Jun 2020 14:57:15 +0900 Message-Id: <20200601055731.3006266-21-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org As far as I understood, this code gets rid of '$Revision$' or '$Revision:' of CVS, RCS or whatever in MODULE_VERSION() tags. Remove the primeval code. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 3 -- scripts/mod/modpost.h | 4 --- scripts/mod/sumversion.c | 66 ---------------------------------------- 3 files changed, 73 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 3df26789c2e6..fbb3d3391e52 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2066,9 +2066,6 @@ static void read_symbols(const char *modname) check_sec_ref(mod, modname, &info); version = get_modinfo(&info, "version"); - if (version) - maybe_frob_rcs_version(modname, version, info.modinfo, - version - (char *)info.hdr); if (version || (all_versions && !is_vmlinux(modname))) get_src_version(modname, mod->srcversion, sizeof(mod->srcversion)-1); diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index b8b7a82d2ff7..f728e250b8d2 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -188,10 +188,6 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, void add_moddevtable(struct buffer *buf, struct module *mod); /* sumversion.c */ -void maybe_frob_rcs_version(const char *modfilename, - char *version, - void *modinfo, - unsigned long modinfo_offset); void get_src_version(const char *modname, char sum[], unsigned sumlen); /* from modpost.c */ diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index 63062024ce0e..f27f22420cbc 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -429,69 +429,3 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen) release: release_file(file, len); } - -static void write_version(const char *filename, const char *sum, - unsigned long offset) -{ - int fd; - - fd = open(filename, O_RDWR); - if (fd < 0) { - warn("changing sum in %s failed: %s\n", - filename, strerror(errno)); - return; - } - - if (lseek(fd, offset, SEEK_SET) == (off_t)-1) { - warn("changing sum in %s:%lu failed: %s\n", - filename, offset, strerror(errno)); - goto out; - } - - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) { - warn("writing sum in %s failed: %s\n", - filename, strerror(errno)); - goto out; - } -out: - close(fd); -} - -static int strip_rcs_crap(char *version) -{ - unsigned int len, full_len; - - if (strncmp(version, "$Revision", strlen("$Revision")) != 0) - return 0; - - /* Space for version string follows. */ - full_len = strlen(version) + strlen(version + strlen(version) + 1) + 2; - - /* Move string to start with version number: prefix will be - * $Revision$ or $Revision: */ - len = strlen("$Revision"); - if (version[len] == ':' || version[len] == '$') - len++; - while (isspace(version[len])) - len++; - memmove(version, version+len, full_len-len); - full_len -= len; - - /* Preserve up to next whitespace. */ - len = 0; - while (version[len] && !isspace(version[len])) - len++; - memmove(version + len, version + strlen(version), - full_len - strlen(version)); - return 1; -} - -/* Clean up RCS-style version numbers. */ -void maybe_frob_rcs_version(const char *modfilename, - char *version, - void *modinfo, - unsigned long version_offset) -{ - if (strip_rcs_crap(version)) - write_version(modfilename, version, version_offset); -} From patchwork Mon Jun 1 05:57:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 03EB917D5 for ; Mon, 1 Jun 2020 05:58:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0FBA206C3 for ; Mon, 1 Jun 2020 05:58:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991105; bh=4hdZWmnfxiD2gcD4X56aRaZIk0ydzr9Y6BdedvPbHnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=bI3BOgY0jOU9s1AwBx/oZI0ChhWq2RHIF9O5aNP0Vkhv0WIL1itMnngpyq1nFDiRJ 454zdpLHxl6N1ly0jMU301zDm8b4i1ce5mWIcm3frzCd0EAjCAOu9gtGJEI964YFPt fj6yGpM7TMYHwsEW3/+FX0u4uwRZNI3mV2aJwHTc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726322AbgFAF6Z (ORCPT ); Mon, 1 Jun 2020 01:58:25 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40004 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726825AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaM1023694; Mon, 1 Jun 2020 14:57:46 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaM1023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991066; bh=NDURC0gwy0my51O5joUWpLmpjipdF2W8sA79dvxXloM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qX5lZGtA39IRKlZM77A0TF4ELVvLJp5aooUmFSbuTyXr9eDeYHOS8I8m/HzgAo2r/ CIjMl6daPE0J722Edg9zXqAbelQJ3DZ4aSNbyZa3kNVJ1rRa2UuIQVKwnLs7Ou9zES gNV6Mq0OsK1bm3vdVo3EM2/BvWmjx0TxYWpFls+/GVLmbBFhrNa8+zGgzjIqmEYDOZ zjVx4l/TVR34fU/y1PTzEi4Jx1EVbWYCStoRfK0Ss4s/iWdfAUT/zWxiLLnS1LyZRt vwby+XXDwmvhgL9NqubzqoEwuD2CvA7dToXOM9e2gyaykXdtLvUfRJg1tKyp7FS5HP IE6PY1F/+hAog== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 22/37] modpost: do not call get_modinfo() for vmlinux(.o) Date: Mon, 1 Jun 2020 14:57:16 +0900 Message-Id: <20200601055731.3006266-22-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The three calls of get_modinfo() ("license", "import_ns", "version") always return NULL for vmlinux(.o) because the built-in module info is prefixed with __MODULE_INFO_PREFIX. It is harmless to call get_modinfo(), but there is no point to search for what apparently does not exist. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 45 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index fbb3d3391e52..a5da633af700 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2006,25 +2006,26 @@ static void read_symbols(const char *modname) mod->skip = 1; } - license = get_modinfo(&info, "license"); - if (!license && !is_vmlinux(modname)) - warn("missing MODULE_LICENSE() in %s\n" - "see include/linux/module.h for " - "more information\n", modname); - while (license) { - if (license_is_gpl_compatible(license)) - mod->gpl_compatible = 1; - else { - mod->gpl_compatible = 0; - break; + if (!is_vmlinux(modname)) { + license = get_modinfo(&info, "license"); + if (!license) + warn("missing MODULE_LICENSE() in %s\n", modname); + while (license) { + if (license_is_gpl_compatible(license)) + mod->gpl_compatible = 1; + else { + mod->gpl_compatible = 0; + break; + } + license = get_next_modinfo(&info, "license", license); } - license = get_next_modinfo(&info, "license", license); - } - namespace = get_modinfo(&info, "import_ns"); - while (namespace) { - add_namespace(&mod->imported_namespaces, namespace); - namespace = get_next_modinfo(&info, "import_ns", namespace); + namespace = get_modinfo(&info, "import_ns"); + while (namespace) { + add_namespace(&mod->imported_namespaces, namespace); + namespace = get_next_modinfo(&info, "import_ns", + namespace); + } } for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { @@ -2065,10 +2066,12 @@ static void read_symbols(const char *modname) if (!is_vmlinux(modname) || vmlinux_section_warnings) check_sec_ref(mod, modname, &info); - version = get_modinfo(&info, "version"); - if (version || (all_versions && !is_vmlinux(modname))) - get_src_version(modname, mod->srcversion, - sizeof(mod->srcversion)-1); + if (!is_vmlinux(modname)) { + version = get_modinfo(&info, "version"); + if (version || all_versions) + get_src_version(modname, mod->srcversion, + sizeof(mod->srcversion) - 1); + } parse_elf_finish(&info); From patchwork Mon Jun 1 05:57:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581349 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8BE4D60D for ; Mon, 1 Jun 2020 05:58:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73FF32074B for ; Mon, 1 Jun 2020 05:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991106; bh=kCNFsfFt+92dd/6a3JR6u5SBAWJ18Q11MK1xjSba0sQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=iyJotWmianKFY9agCZ+at3p94vRHOIOwwaIYOEX8A8MkQpWSAf/Hx433s4q3OxKnk Lv2hq3bHBBurod+3tGvIVwC1Wh+yBkQYtxv947QcWs+D1PIAEP/jWHhb7XTekeEGEq 8UrCo77Z+aDzufj9+OqARbhVJ9Erkk3+Ydwl6rT8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727063AbgFAF60 (ORCPT ); Mon, 1 Jun 2020 01:58:26 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40016 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727084AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaM2023694; Mon, 1 Jun 2020 14:57:46 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaM2023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991066; bh=AvQUsiRI7MJB3yiarf2NJzUVwoBoz3XsvXCX7iTbaYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M7I5cNXkA8ZKcfjqqYovO4aoe15SagFyU+3RaJ+dJDH6zR22yYJqHcAdCNNBxegwY 3tFrR0An1AHY2UHl6ryHtev77LfGahCjt9M9pm0Yeaek5yhn+DvsAjsXw1w09jyYQs uwNVjbuWwpYh57SwLmsaFnSt1IpuMPD2aXjEt/e3U6qkIzSPtqN2IkBtPzo7x9QNSI gbPca8Q3rcomWmRt1ftW+rfDP3SO4vGipGM0r85WJHFLE381B+cuARySl0Q7AKWQOt R5/tBasG0rWwdeyadGDpqEIsGHe5VXbYc+Gz8iFMWtP65e1typO0YKuItwOG53cKXO JJZRPTsIz/ppg== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 23/37] modpost: add read_text_file() and get_line() helpers Date: Mon, 1 Jun 2020 14:57:17 +0900 Message-Id: <20200601055731.3006266-23-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org modpost uses grab_file() to open a file, but it is not suitable for a text file because the mmap'ed file is not terminated by null byte. Actually, I see some issues for the use of grab_file(). The new helper, read_text_file() loads the whole file content into a malloc'ed buffer, and appends a null byte. Then, get_line() reads each line. To handle text files, I intend to replace as follows: grab_file() -> read_text_file() get_new_line() -> get_line() Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 49 +++++++++++++++++++++++++++++++++++++++++++ scripts/mod/modpost.h | 2 ++ 2 files changed, 51 insertions(+) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index a5da633af700..0a844902998e 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -112,6 +112,55 @@ void *do_nofail(void *ptr, const char *expr) return ptr; } +char *read_text_file(const char *filename) +{ + struct stat st; + size_t nbytes; + int fd; + char *buf; + + fd = open(filename, O_RDONLY); + if (fd < 0) { + perror(filename); + exit(1); + } + + if (fstat(fd, &st) < 0) { + perror(filename); + exit(1); + } + + buf = NOFAIL(malloc(st.st_size + 1)); + + nbytes = st.st_size; + + while (nbytes) { + ssize_t bytes_read; + + bytes_read = read(fd, buf, nbytes); + if (bytes_read < 0) { + perror(filename); + exit(1); + } + + nbytes -= bytes_read; + } + buf[st.st_size] = '\0'; + + close(fd); + + return buf; +} + +char *get_line(char **stringp) +{ + /* do not return the unwanted extra line at EOF */ + if (*stringp && **stringp == '\0') + return NULL; + + return strsep(stringp, "\n"); +} + /* A list of all modules we processed */ static struct module *modules; diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index f728e250b8d2..205afc90b08a 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -191,6 +191,8 @@ void add_moddevtable(struct buffer *buf, struct module *mod); void get_src_version(const char *modname, char sum[], unsigned sumlen); /* from modpost.c */ +char *read_text_file(const char *filename); +char *get_line(char **stringp); void *grab_file(const char *filename, unsigned long *size); char* get_next_line(unsigned long *pos, void *file, unsigned long size); void release_file(void *file, unsigned long size); From patchwork Mon Jun 1 05:57:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581345 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35F5D159A for ; Mon, 1 Jun 2020 05:58:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E2DD206C3 for ; Mon, 1 Jun 2020 05:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991106; bh=20UJDrysxHO9Z9sL4XftY/vGmZRPmtKe2nHuonXlPgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=HjQpC5Dgrzkrl62pQPIHuAeNLLWpHaBQ4+E7XWoT2qDg1bl2EWcnBaCy1KBVQ6lw7 qqam+uiAEQ/S8LTxXZ1bIdwNpVlFFCyqQzQ5quRxBA8bT60EUEUT9tllVuvJRspnkC IpvYLeJVQ9GuP/B7kIriKiPSu9tCKuT4V7avW+SA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726825AbgFAF6Z (ORCPT ); Mon, 1 Jun 2020 01:58:25 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40028 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727776AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaM3023694; Mon, 1 Jun 2020 14:57:47 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaM3023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991067; bh=PkEcky+2nbSPL/QvtYB9+TkDgKl7m2g6/MD3lgv36Sg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EqnZF4jtiO4Etk00MVJYWUDRUOG3Wcr/YlB5GD2n8HIa4/rZMeY1zZ+97M7ocqZz0 f2mv137lhxWeKiVMkJ4j4A7wEJT3ULuyqiKr86Q+uG2QvBd72Z5OhRqATMOlwLaj/Q zWZZcD4ymLZ6YBIOxlZ+fSP+fsVJLzeUOT14KjF1bWT/aDVo9Bzr4RuJ93bZiiIPx0 P1OR2R4BIX0oqaL7S3kruDIPZI+PIRLH4D5PEqKW86q2OupXR1X5mCbHs9DqOz62Fi pGJAMvIMzb+9K2tJvWyYkn8SVKJhm3mHJxi7MKiocRG6idrMUs4DWUZYML88PYUokX H6BxEZTKQ6iwQ== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 24/37] modpost: fix potential mmap'ed file overrun in get_src_version() Date: Mon, 1 Jun 2020 14:57:18 +0900 Message-Id: <20200601055731.3006266-24-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org I do not know how reliably this function works, but it looks dangerous to me. strchr(sources, '\n'); ... continues searching until it finds '\n' or it reaches the '\0' terminator. In other words, 'sources' should be a null-terminated string. However, grab_file() just mmaps a file, so 'sources' is not terminated with null byte. If the file does not contain '\n' at all, strchr() will go beyond the mmap'ed memory. Use read_text_file(), which loads the file content into a malloc'ed buffer, appending null byte. Here we are interested only in the first line of *.mod files. Use get_line() helper to get the first line. This also makes missing *.mod file a fatal error. Commit 4be40e22233c ("kbuild: do not emit src version warning for non-modules") ignored missing *.mod files. I do not fully understand what that commit addressed, but commit 91341d4b2c19 ("kbuild: introduce new option to enhance section mismatch analysis") introduced partial section checks by using modpost. built-in.o was parsed by modpost. Even modules had a problem because *.mod files were created after the modpost check. Commit b7dca6dd1e59 ("kbuild: create *.mod with full directory path and remove MODVERDIR") stopped doing that. Now that modpost is only invoked after the directory descend, *.mod files should always exist at the modpost stage. Signed-off-by: Masahiro Yamada --- scripts/mod/sumversion.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index f27f22420cbc..5fb142db6195 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -392,40 +392,34 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md) /* Calc and record src checksum. */ void get_src_version(const char *modname, char sum[], unsigned sumlen) { - void *file; - unsigned long len; + char *buf, *pos, *firstline; struct md4_ctx md; - char *sources, *end, *fname; + char *fname; char filelist[PATH_MAX + 1]; /* objects for a module are listed in the first line of *.mod file. */ snprintf(filelist, sizeof(filelist), "%.*smod", (int)strlen(modname) - 1, modname); - file = grab_file(filelist, &len); - if (!file) - /* not a module or .mod file missing - ignore */ - return; + buf = read_text_file(filelist); - sources = file; - - end = strchr(sources, '\n'); - if (!end) { + pos = buf; + firstline = get_line(&pos); + if (!firstline) { warn("bad ending versions file for %s\n", modname); - goto release; + goto free; } - *end = '\0'; md4_init(&md); - while ((fname = strsep(&sources, " ")) != NULL) { + while ((fname = strsep(&firstline, " "))) { if (!*fname) continue; if (!(is_static_library(fname)) && !parse_source_files(fname, &md)) - goto release; + goto free; } md4_final_ascii(&md, sum, sumlen); -release: - release_file(file, len); +free: + free(buf); } From patchwork Mon Jun 1 05:57:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581353 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06F4D159A for ; Mon, 1 Jun 2020 05:58:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE0A820734 for ; Mon, 1 Jun 2020 05:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991106; bh=j25pAhzuY2STX0FDXX2ii9Bx8i3odERC6T+q9H4eQnk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=dvIwxZ4jcZ3RU//C5AXE6TozCPDpnwTFd/z8ieXMDyeXvd8JjuEF3d0ZbRflZOrkV q3QgKh3BJM06Pux4qis1bisbnbi9lZcWK+I+bwFgzE7OMaiuyCFZEh+8DEJOLOsoYB 5wNTTWPMZzfi3h+6fRgmUpHv62O5vPfhiJTNpiyc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727776AbgFAF60 (ORCPT ); Mon, 1 Jun 2020 01:58:26 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40014 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727100AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaM4023694; Mon, 1 Jun 2020 14:57:47 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaM4023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991067; bh=NNfK89CfnTgijoPBmttFTxdTMae5a/018My66C136sA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iRUDIuCXI+gEE0brl9QGrUF1YCsi00wmXXBfMKp2ppPJvoefxCq6Y3jvs68+yjjUl 70LKp8PbWonRSMU74NczfZVhVubDtkDwNF1x5cIQYLZBUruW6g6iMPEvLsVDc04aX/ DFEh2wdvxtlyCQWZDl3Si91aIfC4yVeK5IefjNXpHrwR73FqpzBISjFja+7xArvmiy YV6ElYXdSuzVAUno2V2JQb8PuoSDHC5FYQYbwtG3mB+yE+5/oVNFW9rUvYgXVTu7OO mIZHA0v5RicSIAD232aLfSx7VxqapioYYHn02Rfy/C/GFfZBKJiH74BT21dGS+sN8j o7ZQhZIsbZ5Ww== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 25/37] modpost: avoid false-positive file open error Date: Mon, 1 Jun 2020 14:57:19 +0900 Message-Id: <20200601055731.3006266-25-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org One problem of grab_file() is that it cannot distinguish the following two cases: - It cannot read the file (the file does not exist, or read permission is not set) - It can read the file, but the file size is zero This is because grab_file() calls mmap(), which requires the mapped length is greater than 0. Hence, grab_file() fails for both cases. If an empty header file were included for checksum calculation, the following warning would be printed: WARNING: modpost: could not open ...: Invalid argument An empty file is a valid source file, so it should not fail. Use read_text_file() instead. It can read a zero-length file. Then, parse_file() will succeed with doing nothing. Going forward, the first case (it cannot read the file) is a fatal error. If the source file from which an object was compiled is missing, something went wrong. Signed-off-by: Masahiro Yamada --- scripts/mod/sumversion.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index 5fb142db6195..9f77c9dfce20 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -258,9 +258,8 @@ static int parse_file(const char *fname, struct md4_ctx *md) char *file; unsigned long i, len; - file = grab_file(fname, &len); - if (!file) - return 0; + file = read_text_file(fname); + len = strlen(file); for (i = 0; i < len; i++) { /* Collapse and ignore \ and CR. */ @@ -287,7 +286,7 @@ static int parse_file(const char *fname, struct md4_ctx *md) add_char(file[i], md); } - release_file(file, len); + free(file); return 1; } /* Check whether the file is a static library or not */ From patchwork Mon Jun 1 05:57:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581329 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 718FC159A for ; Mon, 1 Jun 2020 05:58:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57F7620734 for ; Mon, 1 Jun 2020 05:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991104; bh=wi6JWtOdv/R252TEGPfZEd2XAyyPXkm+/Y0B6LELFSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=evf6wMjXc/rdbVFTfx2FXGVpyOOBsuyqf8yTNT3ke/jwv8YuellyvcnCFV/DmVVSS uKK7N0L17xyWwH7GNu2b+Wm/fz/6lz+oY+2jNKvznnATtxue6bux7foQF+Z+99HmRT fGiaS87AjeYSqJp3bOiNSif9vtHCYLb/oC9M4568= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726778AbgFAF6X (ORCPT ); Mon, 1 Jun 2020 01:58:23 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:39999 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaM5023694; Mon, 1 Jun 2020 14:57:47 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaM5023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991068; bh=vJ1bcU41SVw+9iIP9yCFsC6bv60+CGWNZO2UgHrbg9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nAuj8yaeskkWpQWM/67EqUuYw26lJRN4KScbkWc//UkLr/b0K5FTBFMCMFIn8mUVo LHyhFasH5PfmMbNiyQnPKcjilmZlD0CE9vMy1C7E1JSrPFWljnlVekWSK6YUDy/Xum gakDcwlnIStNclAOAMO9DwqQSXqVbhSLpaYkMxr5QgN0nCrbD7HF4M0l2/1klfjfvh kgfDGIhvb1TUh0W24n/lmH/zL8LvCH5flcpFrKj1R/TOFys/MktPSlb7dWPrqLxBFj +pA5W73oWRp8xvaiagakTb58z0iaSL+hsE+yqRSMwpN32JGluY65DvKP0FahA4yZ0z I40OugEnATRsg== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 26/37] modpost: use read_text_file() and get_line() for reading text files Date: Mon, 1 Jun 2020 14:57:20 +0900 Message-Id: <20200601055731.3006266-26-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org grab_file() mmaps a file, but it is not so efficient here because get_next_line() copies every line to the temporary buffer anyway. read_text_file() and get_line() are simpler. get_line() exploits the library function strchr(). Going forward, the missing *.symvers or *.cmd is a fatal error. This should not happen because scripts/Makefile.modpost guards the -i option files with $(wildcard $(input-symdump)). Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 15 ++++++++------- scripts/mod/sumversion.c | 16 ++++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 0a844902998e..4fdf992e9729 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2481,15 +2481,16 @@ static void write_if_changed(struct buffer *b, const char *fname) **/ static void read_dump(const char *fname) { - unsigned long size, pos = 0; - void *file = grab_file(fname, &size); - char *line; + char *buf, *pos, *line; - if (!file) + buf = read_text_file(fname); + if (!buf) /* No symbol versions, silently ignore */ return; - while ((line = get_next_line(&pos, file, size))) { + pos = buf; + + while ((line = get_line(&pos))) { char *symname, *namespace, *modname, *d, *export; unsigned int crc; struct module *mod; @@ -2524,10 +2525,10 @@ static void read_dump(const char *fname) sym_set_crc(symname, crc); sym_update_namespace(symname, namespace); } - release_file(file, size); + free(buf); return; fail: - release_file(file, size); + free(buf); fatal("parse error in symbol dump file\n"); } diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index 9f77c9dfce20..d587f40f1117 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -303,9 +303,8 @@ static int is_static_library(const char *objfile) * to figure out source files. */ static int parse_source_files(const char *objfile, struct md4_ctx *md) { - char *cmd, *file, *line, *dir; + char *cmd, *file, *line, *dir, *pos; const char *base; - unsigned long flen, pos = 0; int dirlen, ret = 0, check_files = 0; cmd = NOFAIL(malloc(strlen(objfile) + sizeof("..cmd"))); @@ -323,14 +322,12 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md) strncpy(dir, objfile, dirlen); dir[dirlen] = '\0'; - file = grab_file(cmd, &flen); - if (!file) { - warn("could not find %s for %s\n", cmd, objfile); - goto out; - } + file = read_text_file(cmd); + + pos = file; /* Sum all files in the same dir or subdirs. */ - while ((line = get_next_line(&pos, file, flen)) != NULL) { + while ((line = get_line(&pos))) { char* p = line; if (strncmp(line, "source_", sizeof("source_")-1) == 0) { @@ -381,8 +378,7 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md) /* Everyone parsed OK */ ret = 1; out_file: - release_file(file, flen); -out: + free(file); free(dir); free(cmd); return ret; From patchwork Mon Jun 1 05:57:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581363 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 267A8175D for ; Mon, 1 Jun 2020 05:58:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EF1A2074B for ; Mon, 1 Jun 2020 05:58:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991108; bh=KtIRJwcWpw11/c1Sn9byQFSRqLY/B5I6u3UQ9qPI6qs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=AhajueUQHwxW0bOrporOhJdHAjxVEcc5XqDwz0vRC6YW58K1ioSEAKi9kenBGGjTZ /R35gCao/vkEpaU9gh58fh4za5GGomrDM7m49T0qxV+gr0yOJKawtBFJJ/gUBhCo11 AgKHKUVXWu+Skyv9SXt+AQ8Z0pzsrpVE+P/ertg4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727779AbgFAF61 (ORCPT ); Mon, 1 Jun 2020 01:58:27 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40025 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727772AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaM6023694; Mon, 1 Jun 2020 14:57:48 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaM6023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991068; bh=IE3dCzGw0wBYOJQFUIJyhMWn7v6kWwb0YRHV/C0pXQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qELjpyptFMUHIQRRtzYaet5668rMbmn9wGCPRlTzKIzVoVCDAW2b1jIANN7zQrwLX ZSW3jTy3KptaoczTPl/ExDrNXFjNnLDTYPMKk0CVq0egRQKo4AIhcZ2hjfhbeWExB3 45PQZf2JUbMHBRVghFnWcGTJoqC0r/0leA4NYApqd4Rq2O+pnFbZBACwfncIwa5Y3z ErSgQYNbRMArhAb20WxG7rRXT/WqNnuxf8YeKGrqLz6BI3fYiL9ykq1PXr1tvs0xfx FCIDIiuxbjvht0/R3XlaLiNsMG3b9sD0xs38d4zjjAzprz2Vj29BsZIEAGXIGlTH9I E4ExxDPnmKXwg== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 27/37] modpost: remove get_next_text() and make {grab,release_}file static Date: Mon, 1 Jun 2020 14:57:21 +0900 Message-Id: <20200601055731.3006266-27-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org get_next_line() is no longer used. Remove. grab_file() and release_file() are only used in modpost.c. Make them static. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 38 ++------------------------------------ scripts/mod/modpost.h | 3 --- 2 files changed, 2 insertions(+), 39 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 4fdf992e9729..93019349f022 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -463,7 +463,7 @@ static void sym_set_crc(const char *name, unsigned int crc) s->crc_valid = 1; } -void *grab_file(const char *filename, unsigned long *size) +static void *grab_file(const char *filename, unsigned long *size) { struct stat st; void *map = MAP_FAILED; @@ -485,41 +485,7 @@ void *grab_file(const char *filename, unsigned long *size) return map; } -/** - * Return a copy of the next line in a mmap'ed file. - * spaces in the beginning of the line is trimmed away. - * Return a pointer to a static buffer. - **/ -char *get_next_line(unsigned long *pos, void *file, unsigned long size) -{ - static char line[4096]; - int skip = 1; - size_t len = 0; - signed char *p = (signed char *)file + *pos; - char *s = line; - - for (; *pos < size ; (*pos)++) { - if (skip && isspace(*p)) { - p++; - continue; - } - skip = 0; - if (*p != '\n' && (*pos < size)) { - len++; - *s++ = *p++; - if (len > 4095) - break; /* Too long, stop */ - } else { - /* End of string */ - *s = '\0'; - return line; - } - } - /* End of buffer */ - return NULL; -} - -void release_file(void *file, unsigned long size) +static void release_file(void *file, unsigned long size) { munmap(file, size); } diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 205afc90b08a..aaf3c4ad5d60 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -193,9 +193,6 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen); /* from modpost.c */ char *read_text_file(const char *filename); char *get_line(char **stringp); -void *grab_file(const char *filename, unsigned long *size); -char* get_next_line(unsigned long *pos, void *file, unsigned long size); -void release_file(void *file, unsigned long size); enum loglevel { LOG_WARN, From patchwork Mon Jun 1 05:57:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581357 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7464A60D for ; Mon, 1 Jun 2020 05:58:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CBBC2074B for ; Mon, 1 Jun 2020 05:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991107; bh=tw/D3Sy0uRZeEoISDMLeip2acvp9YzRLvNZXUHJ3J8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xu1QqSK9pIAVxQjuA3va+8ZPgnO8D7BukszmI1cIsrtiFjp10L1c7KPHr6OL7FEf1 usS3BcV9S4KJhDgvrSS+2g9YTIGjXWlKokW5LD9JFsKsTa7ana869o2LEYGEZi4S8I La9pPqO4ckwtxLEpL80M/tIrUoyT783rGYogTFvQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727119AbgFAF60 (ORCPT ); Mon, 1 Jun 2020 01:58:26 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40027 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727769AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaM7023694; Mon, 1 Jun 2020 14:57:48 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaM7023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991068; bh=JWm42uDBESIlwmxMe3fixzXBNn5Kpf5cMwSmCatQK2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nKwLRGM7ihqMeT0F+2mw540O5BJ+GCnYxhLXTSh0yV4Jh6UVrUwZHnssIEzfCC96n ZNqdnso8cELZOw/SH8DHo0ZEoW5JJnH7xpZ2J7yfM9UcrhFeDGGXPi4nLeJOnHVorG CjDV8S4WPuUfyf0uBnEaoctzyLaFdW5MfYUzLPyv+d7SV4OyDlQyfKbnkpt26SvR3x uW5YFTaDRRz/1m5LGawDbu88YSJPet/vEv/WG27yA9fbBh9DcXPFbprR5ohDSeEa3M N0QMCJOEsz8aHhH7oDG3bri9KWulh+t1lsy/B6ldxN8MWsEtI9+DSWyOV4gY6NqvQD jpfkPtcoYQsYw== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 28/37] modpost: remove -s option Date: Mon, 1 Jun 2020 14:57:22 +0900 Message-Id: <20200601055731.3006266-28-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The -s option was added by commit 8d8d8289df65 ("kbuild: do not do section mismatch checks on vmlinux in 2nd pass"). Now that the second pass does not parse vmlinux, this option is unneeded. Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 2 +- scripts/mod/modpost.c | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 16fe19724c34..bc9a03e8208d 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -62,7 +62,7 @@ __modpost: vmlinux.symvers else -MODPOST += -s \ +MODPOST += \ $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) ifeq ($(KBUILD_EXTMOD),) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 93019349f022..b667f531a645 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -30,8 +30,6 @@ static int have_vmlinux = 0; static int all_versions = 0; /* If we are modposting external module set to 1 */ static int external_module = 0; -/* Warn about section mismatch in vmlinux if set to 1 */ -static int vmlinux_section_warnings = 1; /* Only warn about unresolved symbols */ static int warn_unresolved = 0; /* How a symbol is exported */ @@ -2078,8 +2076,7 @@ static void read_symbols(const char *modname) } } - if (!is_vmlinux(modname) || vmlinux_section_warnings) - check_sec_ref(mod, modname, &info); + check_sec_ref(mod, modname, &info); if (!is_vmlinux(modname)) { version = get_modinfo(&info, "version"); @@ -2576,7 +2573,7 @@ int main(int argc, char **argv) struct dump_list *dump_read_start = NULL; struct dump_list **dump_read_iter = &dump_read_start; - while ((opt = getopt(argc, argv, "ei:mnsT:o:awENd:")) != -1) { + while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) { switch (opt) { case 'e': external_module = 1; @@ -2599,9 +2596,6 @@ int main(int argc, char **argv) case 'a': all_versions = 1; break; - case 's': - vmlinux_section_warnings = 0; - break; case 'T': files_source = optarg; break; From patchwork Mon Jun 1 05:57:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581309 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D368660D for ; Mon, 1 Jun 2020 05:58:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B26ED20772 for ; Mon, 1 Jun 2020 05:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991101; bh=53n2+gjsqZPWjILrXauKyj+fB3eTeGlOepMtV3AcVc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=yyHKs/BeH6GQ+J7taFtXjw7POrOo9O/aJx8t/g5Y4bpzO345aYKNqpftvc5UqZV10 W3rNQGreUEYy8NLn0xo3Ag+MWaxU6mhJkKwD98p9xtp91p/s42fmgYCqAI2AGj5XIi PBQhPTJccw7cBmY/F/ENknOuHgqWR9n2nC211ls4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726070AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:39995 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbgFAF6U (ORCPT ); Mon, 1 Jun 2020 01:58:20 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaM8023694; Mon, 1 Jun 2020 14:57:49 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaM8023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991069; bh=EEkuqypsPSXsQ9T/zeWNA2J6IytD75K1+COyRh3G20M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EP/cqLp02VyDziXPkOqmlvP8ucNKQEkhLUpJOxgsSQ17XgnoR+mWd1I0MVM4R3qsH oQyivlFgd/nP32T5kwX9LOUaqr6zGScLVzkfBVNZL9i1U5xFjz6+9xXx23a1t3l66u 3kl/IGL6yCo66SNvztSRDahHj6HlnCkUe51c3MK2EQrQrAyBbdGnq6QRYD75oTUMvq 8Fcy+koYv04ebeWkdJzmLdZkKdkaTWKk/X5JTQpH3hW5qKjCLAjdf7XKMjePentDqv xKDKLCXLIQ1mK6MjvzKkRzEE3qxSY547cFyyayxalaa1bRQE98GmugC6dWg/OI3+Su 4eYcUyAd04N4g== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 29/37] modpost: move -d option in scripts/Makefile.modpost Date: Mon, 1 Jun 2020 14:57:23 +0900 Message-Id: <20200601055731.3006266-29-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Collect options for modules into a single place. Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index bc9a03e8208d..b0c3634ff462 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -62,9 +62,6 @@ __modpost: vmlinux.symvers else -MODPOST += \ - $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) - ifeq ($(KBUILD_EXTMOD),) input-symdump := vmlinux.symvers @@ -91,6 +88,7 @@ endif # modpost options for modules (both in-kernel and external) MODPOST += \ $(addprefix -i ,$(wildcard $(input-symdump))) \ + $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \ $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),) From patchwork Mon Jun 1 05:57:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581359 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D943292A for ; Mon, 1 Jun 2020 05:58:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1F332074B for ; Mon, 1 Jun 2020 05:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991107; bh=ZWHtmQUpaaCFJPebqn9rYjDMUknqVPntwGS/O2B0QFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=UrfPr/NaKgDmXpUWSECeibxKV3qkkhUmg1A2hoqxBtdynKbD56Rmk/wVe1q2rTwYw zkQI9v5IgOlZi50AUKiRvzd0JSWIXctCfpL7n1YTBfNekBFKHvLa4RU7ek4L0VvNrH SQ6Mj5SlAY7mEGzbS4nd4chHhlxl+eHRArK2PBAw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727113AbgFAF61 (ORCPT ); Mon, 1 Jun 2020 01:58:27 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40030 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727795AbgFAF6W (ORCPT ); Mon, 1 Jun 2020 01:58:22 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaM9023694; Mon, 1 Jun 2020 14:57:49 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaM9023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991069; bh=B5XoUr3+P9jJDKs/v6Pdcf+6nsJRfynUwhGv5nMnhqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Smh5tCU70zQa5NW2HdMyzuqrN5GUd2vdAOfGo2Qv/jYsW/H2eUURbwXrOSzZO2RkL /hLJGHjrzxIPp1oCCY82isT1luQz/4XG6WRUokDmpFzEan3FNmzfyGRLdhD/u+1Gke qBdk+Co9qz06WV0yJ9OvCC0qMWf4xP/W5wgVLXBFC5GHVGsrrAGRZPP5WoBt1EBOsI Amr7aSg7jHeKfNbyh9l4POuSwt93xjDHDZSggwxm3PWUdKhMQIgh/1d0pUHSe4o5cz 9/vMOS2jn9e0iHXIlApXHaCjh60X27cTLd7nKp8dXBlBXqwHg8WqE8lxNkceI2Z1VF kb0Wtf+jUA/2A== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 30/37] modpost: remove mod->is_dot_o struct member Date: Mon, 1 Jun 2020 14:57:24 +0900 Message-Id: <20200601055731.3006266-30-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Previously, there were two cases where mod->is_dot_o is unset: [1] the executable 'vmlinux' in the second pass of modpost [2] modules loaded by read_dump() I think [1] was intended usage to distinguish 'vmlinux.o' and 'vmlinux'. Now that modpost does not parse the executable 'vmlinux', this case does not happen. [2] is obscure, maybe a bug. Module.symver stores module paths without extension. So, none of modules loaded by read_dump() has the .o suffix, and new_module() unsets ->is_dot_o. Anyway, it is not a big deal because handle_symbol() is not called for the case. To sum up, all the parsed ELF files are .o files. mod->is_dot_o is unneeded. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 14 ++------------ scripts/mod/modpost.h | 1 - 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index b667f531a645..bc00bbac50bb 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -182,10 +182,8 @@ static struct module *new_module(const char *modname) p = NOFAIL(strdup(modname)); /* strip trailing .o */ - if (strends(p, ".o")) { + if (strends(p, ".o")) p[strlen(p) - 2] = '\0'; - mod->is_dot_o = 1; - } /* add to list */ mod->name = p; @@ -716,8 +714,7 @@ static void handle_symbol(struct module *mod, struct elf_info *info, enum export export; const char *name; - if ((!is_vmlinux(mod->name) || mod->is_dot_o) && - strstarts(symname, "__ksymtab")) + if (strstarts(symname, "__ksymtab")) export = export_from_secname(info, get_secindex(info, sym)); else export = export_from_sec(info, get_secindex(info, sym)); @@ -2676,13 +2673,6 @@ int main(int argc, char **argv) struct symbol *s; for (s = symbolhash[n]; s; s = s->next) { - /* - * Do not check "vmlinux". This avoids the same warnings - * shown twice, and false-positives for ARCH=um. - */ - if (is_vmlinux(s->module->name) && !s->module->is_dot_o) - continue; - if (s->is_static) warn("\"%s\" [%s] is a static %s\n", s->name, s->module->name, diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index aaf3c4ad5d60..554f02c69ac2 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -126,7 +126,6 @@ struct module { int has_cleanup; struct buffer dev_table_buf; char srcversion[25]; - int is_dot_o; // Missing namespace dependencies struct namespace_list *missing_namespaces; // Actual imported namespaces From patchwork Mon Jun 1 05:57:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581319 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E66F159A for ; Mon, 1 Jun 2020 05:58:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5AE3420734 for ; Mon, 1 Jun 2020 05:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991103; bh=FTU+x9y+4CX1J70o8LAmcKMpx5W7//2e+wu8pAi/Jsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=GXtduLzxCk3ELqdpERv7Yebeb4Q+f8fKex+DUJKYSxGNotr0gwxIj6MAlpL5IR28X w5OXErusEpvmRqxYRNitv7Two2e0b3Lj+QaHQnjLxzkDwwTXIdX+5dMYiaQEZIuOWc eujLDP+VJkKygmSxWZ30tZw9oVTZPpyal2WUpW4Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726056AbgFAF6X (ORCPT ); Mon, 1 Jun 2020 01:58:23 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40013 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727068AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaMA023694; Mon, 1 Jun 2020 14:57:50 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaMA023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991070; bh=1Q3KADhnY+OelPioGoGxZ8yWqtmvAGxr4lH7F3uc4aI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g/A1qfI8lAF0r7Y3vANaQdxrJ5IlZoBLgAjhbNDLx+ayjAz9xR1dV5UHvqFCWUwXr lIN3YHdaFb+tvGjth+/iApLXqLSiYKCfNEns2+70jLwqcVIjvdJEEz/SJ6K+Txz5IR b78A0QtvHQsRnlDCd/dmOwPLDdsDKhGHg+s87KXgJzGSmdnSKEjoFxQfSnqnCi8Nwf pZR5eSZBO5svjepG2cWCET1VVcUEYoi+ws5u+lD8QgJatjNSr1BavoT/CEwHcOkPT6 BUMPgCmMyNFei00RLxBkSrZURJxziT9dUFlXugM3EjpNkicgbsvpaTjT4MJmnLj9LL t4mWeIzgYkZQw== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 31/37] modpost: remove is_vmlinux() call in check_for_{gpl_usage,unused}() Date: Mon, 1 Jun 2020 14:57:25 +0900 Message-Id: <20200601055731.3006266-31-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org check_exports() is never called for vmlinux because mod->skip is set for vmlinux. Hence, check_for_gpl_usage() and check_for_unused() are not called for vmlinux, either. is_vmlinux() is always false here. Remove the is_vmlinux() calls, and hard-code the ".ko" suffix. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index bc00bbac50bb..84a642c14775 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2144,20 +2144,18 @@ void buf_write(struct buffer *buf, const char *s, int len) static void check_for_gpl_usage(enum export exp, const char *m, const char *s) { - const char *e = is_vmlinux(m) ?"":".ko"; - switch (exp) { case export_gpl: - fatal("GPL-incompatible module %s%s " - "uses GPL-only symbol '%s'\n", m, e, s); + fatal("GPL-incompatible module %s.ko uses GPL-only symbol '%s'\n", + m, s); break; case export_unused_gpl: - fatal("GPL-incompatible module %s%s " - "uses GPL-only symbol marked UNUSED '%s'\n", m, e, s); + fatal("GPL-incompatible module %s.ko uses GPL-only symbol marked UNUSED '%s'\n", + m, s); break; case export_gpl_future: - warn("GPL-incompatible module %s%s " - "uses future GPL-only symbol '%s'\n", m, e, s); + warn("GPL-incompatible module %s.ko uses future GPL-only symbol '%s'\n", + m, s); break; case export_plain: case export_unused: @@ -2169,13 +2167,11 @@ static void check_for_gpl_usage(enum export exp, const char *m, const char *s) static void check_for_unused(enum export exp, const char *m, const char *s) { - const char *e = is_vmlinux(m) ?"":".ko"; - switch (exp) { case export_unused: case export_unused_gpl: - warn("module %s%s " - "uses symbol '%s' marked UNUSED\n", m, e, s); + warn("module %s.ko uses symbol '%s' marked UNUSED\n", + m, s); break; default: /* ignore */ From patchwork Mon Jun 1 05:57:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581333 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 09E2260D for ; Mon, 1 Jun 2020 05:58:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6061206C3 for ; Mon, 1 Jun 2020 05:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991104; bh=KyeAq5j2kIgtveooCLdcsPUhzaPeRVELcgNbb1HPqrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=P9ckYJVoB7wroxwnyPqw4T9AbXnuxDJeyHSB7ctk2donQEbFmLNEQ2iNJTnZzpeHC e2CmyybPnufgg1D0XIZfFpca3NPrmqb22ACkm8iv3koIRWGO3LMl888E1PDLxyFAsR rF3dnqTkrwJxztbaYg6DLzf85pYAoSFymT+iN1FI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727096AbgFAF6Y (ORCPT ); Mon, 1 Jun 2020 01:58:24 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40005 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727004AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaMB023694; Mon, 1 Jun 2020 14:57:50 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaMB023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991070; bh=N9ggMV3jZpsUdGnVC6O2MPQKtVwZyZD9wkuxtkA5VXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NDo7yatnj8okGaZJBAbWXYhHOctYtG6BBW8eplaNmuHD3ufFnDxAO4z17zyDu3JLZ zCMY7tiE7onHI1hYOm2Rv79US0NQc1DTekNk7+XH2DN1NlV//+c04WBsYCLppfk42V zrEhGgzeG7fPVAyqmV9ciulGLBIg4jJTyNecdSzwsvUSGP9DBBXFlbLDWKyOjptM4F dkfoyYQaIBI7h7LXzU7BxdTMVjtlmVQKjjgaAHZSBJDS/gRFxsp03JqqDxdO7wpew4 XsVELBF4Jg5d/VzP6uDLkZbF49ht60bi0VnVSmL1lx7x0PqicGRimJ5brILcwG1wT8 Vw+F0/XSeKYDg== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 32/37] modpost: add mod->is_vmlinux struct member Date: Mon, 1 Jun 2020 14:57:26 +0900 Message-Id: <20200601055731.3006266-32-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org is_vmlinux() is called in several places to check whether the current module is vmlinux or not. It is faster and clearer to check mod->is_vmlinux flag. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 19 ++++++++++--------- scripts/mod/modpost.h | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 84a642c14775..167700a7b80f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -187,6 +187,7 @@ static struct module *new_module(const char *modname) /* add to list */ mod->name = p; + mod->is_vmlinux = is_vmlinux(modname); mod->gpl_compatible = -1; mod->next = modules; modules = mod; @@ -431,11 +432,11 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, if (!s) { s = new_symbol(name, mod, export); - } else if (!external_module || is_vmlinux(s->module->name) || + } else if (!external_module || s->module->is_vmlinux || s->module == mod) { warn("%s: '%s' exported twice. Previous export was in %s%s\n", mod->name, name, s->module->name, - is_vmlinux(s->module->name) ? "" : ".ko"); + s->module->is_vmlinux ? "" : ".ko"); return s; } @@ -692,7 +693,7 @@ static void handle_modversion(const struct module *mod, if (sym->st_shndx == SHN_UNDEF) { warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n", - symname, mod->name, is_vmlinux(mod->name) ? "":".ko"); + symname, mod->name, mod->is_vmlinux ? "" : ".ko"); return; } @@ -2011,12 +2012,12 @@ static void read_symbols(const char *modname) mod = new_module(modname); - if (is_vmlinux(modname)) { + if (mod->is_vmlinux) { have_vmlinux = 1; mod->skip = 1; } - if (!is_vmlinux(modname)) { + if (!mod->is_vmlinux) { license = get_modinfo(&info, "license"); if (!license) warn("missing MODULE_LICENSE() in %s\n", modname); @@ -2075,7 +2076,7 @@ static void read_symbols(const char *modname) check_sec_ref(mod, modname, &info); - if (!is_vmlinux(modname)) { + if (!mod->is_vmlinux) { version = get_modinfo(&info, "version"); if (version || all_versions) get_src_version(modname, mod->srcversion, @@ -2345,7 +2346,7 @@ static void add_depends(struct buffer *b, struct module *mod) /* Clear ->seen flag of modules that own symbols needed by this. */ for (s = mod->unres; s; s = s->next) if (s->module) - s->module->seen = is_vmlinux(s->module->name); + s->module->seen = s->module->is_vmlinux; buf_printf(b, "\n"); buf_printf(b, "MODULE_INFO(depends, \""); @@ -2470,9 +2471,9 @@ static void read_dump(const char *fname) goto fail; mod = find_module(modname); if (!mod) { - if (is_vmlinux(modname)) - have_vmlinux = 1; mod = new_module(modname); + if (mod->is_vmlinux) + have_vmlinux = 1; mod->skip = 1; mod->from_dump = 1; } diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 554f02c69ac2..ec717ab20b98 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -120,6 +120,7 @@ struct module { int gpl_compatible; struct symbol *unres; int from_dump; /* 1 if module was loaded from *.symver */ + int is_vmlinux; int seen; int skip; int has_init; From patchwork Mon Jun 1 05:57:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581341 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB52792A for ; Mon, 1 Jun 2020 05:58:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BAAAF206C3 for ; Mon, 1 Jun 2020 05:58:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991105; bh=UNXLoDKal4yAGSnkF6blLbxv6qjpKco974HvxJNBDwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=X7jECQyW7Fr2tCsND4h1WOnX79ZGSriKIwR5Us1Uu1YdYwmKYIZ5i5zDcJGnGFTMb fJYhZmpyiyEiYFGVi3AYqWSOrzDKm1eIPEL5IGORjZWc1z8wK4CWnxNPO9vZ/r0Xr/ dTq2X9hQUk8KfjEAJD2DRU60ZnZVTG9q6EepWZ7w= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727120AbgFAF6Z (ORCPT ); Mon, 1 Jun 2020 01:58:25 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40000 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726322AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaMC023694; Mon, 1 Jun 2020 14:57:50 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaMC023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991071; bh=VAJHNh7EIqe1z6GfKL5VHbCk4PdYVPoyqPWw1vwo8ac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pVeZcUhVZBTUoUa3n3L4pwKy5yVrpfir+pvbH5wtGhBHULoJYlctdskxVOdf7HxIA PX9bD0qIdUV8OXt+LmvkaDK0SjHBBK6S/arl8w8CHlPqmQACfvtzoSf8B7XnZIAvxM bPXosAy6h7UIakWmZj8smJMoXrMd5LrT8s/R80NhYM+o4aCG2GEglwZ5+sSQvtwYyA wFhayWqWXJkIlVUwzB3LmemTtzdKYWC4mIU2Ejeein0ReUKZlx7c2jzCCI/BYhg3Zu 1TAdwxxpwOpc/iq1+R4F86PvImmUipmli/j973RyX3sD92GRndbdQOK308GX9LwluV D18Mk0LpHQiPQ== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 33/37] modpost: remove mod->skip struct member Date: Mon, 1 Jun 2020 14:57:27 +0900 Message-Id: <20200601055731.3006266-33-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The meaning of 'skip' is obscure since it does not explain "what to skip". mod->skip is set when it is vmlinux or the module info came from a dump file. So, mod->skip is equivalent to (mod->is_vmlinux || mod->from_dump). For the check in write_namespace_deps_files(), mod->is_vmlinux is unneeded because the -d option is not passed in the first pass of modpost. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 9 +++------ scripts/mod/modpost.h | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 167700a7b80f..925c1a1856aa 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2012,10 +2012,8 @@ static void read_symbols(const char *modname) mod = new_module(modname); - if (mod->is_vmlinux) { + if (mod->is_vmlinux) have_vmlinux = 1; - mod->skip = 1; - } if (!mod->is_vmlinux) { license = get_modinfo(&info, "license"); @@ -2474,7 +2472,6 @@ static void read_dump(const char *fname) mod = new_module(modname); if (mod->is_vmlinux) have_vmlinux = 1; - mod->skip = 1; mod->from_dump = 1; } s = sym_add_exported(symname, mod, export_no(export)); @@ -2535,7 +2532,7 @@ static void write_namespace_deps_files(const char *fname) for (mod = modules; mod; mod = mod->next) { - if (mod->skip || !mod->missing_namespaces) + if (mod->from_dump || !mod->missing_namespaces) continue; buf_printf(&ns_deps_buf, "%s.ko:", mod->name); @@ -2637,7 +2634,7 @@ int main(int argc, char **argv) for (mod = modules; mod; mod = mod->next) { char fname[PATH_MAX]; - if (mod->skip) + if (mod->is_vmlinux || mod->from_dump) continue; buf.pos = 0; diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index ec717ab20b98..264c0c51defa 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -122,7 +122,6 @@ struct module { int from_dump; /* 1 if module was loaded from *.symver */ int is_vmlinux; int seen; - int skip; int has_init; int has_cleanup; struct buffer dev_table_buf; From patchwork Mon Jun 1 05:57:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581339 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B41AD60D for ; Mon, 1 Jun 2020 05:58:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93154206C3 for ; Mon, 1 Jun 2020 05:58:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991105; bh=+LR1ypWoN0+6DbxHEo0jXA00M1l0iwfThB2ya+tGINM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=g5T29wY4mTNIqwOEufwoAgbDYaY/IC6nJniTcbCF4Bskla+fifmWUxAGaXMlkonwN l1MMdwfDH47K7HSI3tHgH0QE9rf0kn8n1wqRy4RAJKaCu6pqCYGB55mUt494Xldysu VAYqr29MDRF6LN7s2UuR0wd4thD9pkOTvNp8o7Ig= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727118AbgFAF6Z (ORCPT ); Mon, 1 Jun 2020 01:58:25 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40023 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727120AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaMD023694; Mon, 1 Jun 2020 14:57:51 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaMD023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991072; bh=X2mnKq0uk81/TUNdPVJWiFn594T+YFAh//6L+SaEZQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G5sI2+GE6eHDaWKyPaqqolF5xseS8aqXop3Ua0vqPqDX32O97iHniebnV3AAnljqv VO7XOp1pc+2YuUGnOSTNdn5Cy+UUct24G6uxfcLNNwvZ37HKjPT4vHZNMGism+X8qE ONvMr27EvHLetEEMQx8vGaJ5pi2oFNUl70CjU15JHPmU0ExiYzIePt9mhswqcPgUth Q+y00l/b+ASctOmkF6hxuMdg5deNeXRVLLbyJDgjOj/meh7u+23QG6pvPbgToIg7mG jHeIX3EcGMqqgHgIO1rh5kVfKBP+n3H5BatGPSk6cbLC7o4Tms/jYwQdDbh/G4m6gc DBd3JFxfKfjbA== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 34/37] modpost: set have_vmlinux in new_module() Date: Mon, 1 Jun 2020 14:57:28 +0900 Message-Id: <20200601055731.3006266-34-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Set have_vmlinux flag in a single place. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 925c1a1856aa..b317328ae21b 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -192,6 +192,9 @@ static struct module *new_module(const char *modname) mod->next = modules; modules = mod; + if (mod->is_vmlinux) + have_vmlinux = 1; + return mod; } @@ -2012,9 +2015,6 @@ static void read_symbols(const char *modname) mod = new_module(modname); - if (mod->is_vmlinux) - have_vmlinux = 1; - if (!mod->is_vmlinux) { license = get_modinfo(&info, "license"); if (!license) @@ -2470,8 +2470,6 @@ static void read_dump(const char *fname) mod = find_module(modname); if (!mod) { mod = new_module(modname); - if (mod->is_vmlinux) - have_vmlinux = 1; mod->from_dump = 1; } s = sym_add_exported(symname, mod, export_no(export)); From patchwork Mon Jun 1 05:57:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581361 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 043ED1667 for ; Mon, 1 Jun 2020 05:58:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDBE220734 for ; Mon, 1 Jun 2020 05:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991107; bh=EZoiBA8D6RzIHCi9Nw7lWrnO2LHxiSbR7Odq/6K2kn4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=m31fuIOms3/xZijfwqGHlMqQJHrh+W1huSdPssqeA52noFzP9VQQU9CrAWZWqEi9C 7l66FAzncnmqLn9P+2q6QLXMXG5v+vcr+LwUKxG3WwGJJjzAf3/dnGzrlsi/Mtihxy 8/kC8+34A9BsSzIybKb4V6/VhoOvu5VPr4v08okM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727769AbgFAF61 (ORCPT ); Mon, 1 Jun 2020 01:58:27 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40017 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727113AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaME023694; Mon, 1 Jun 2020 14:57:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaME023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991072; bh=iaGl1hq94TVvmDBdToo8EuwT120NWdz2T7JRJMxrlcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UsRtJsMxMFPKu9OBg+0iP8b5CNFjsCyWgWXjpaoPH+y29OO7YA8icZfOH+SJhF5LO mDG+RLotXKvknqqC8aG3y3fXQBc14RVHY8zLw4kzCGT1T/05ejdji6m0HA/y5YPvP4 nYSpOz07J5X1iVDQBLUCxA2Ww82NjCsbmWIwLfGOSM4nkngrj2J0+nwwX/XPVZQitf INqnvGW4YKgxNXyZK9GGVWmqcarEEIgf+nEbZdTw2hsiPpSI63Ec+CpzLaEuUwZIER +8US/ltcprI8QXG1T3JglwFGojKlaO+fcQ57aNHfoNMOakeAJUHsSpECxeunGQe/KS uFTcM93Q7sgCw== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 35/37] modpost: strip .o from modname before calling new_module() Date: Mon, 1 Jun 2020 14:57:29 +0900 Message-Id: <20200601055731.3006266-35-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org new_module() conditionally strips the .o because the modname has .o suffix when it is called from read_symbols(), but no .o when it is called from read_dump(). It is clearer to strip .o in read_symbols(). I also used flexible-array for mod->name. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 20 +++++++++++--------- scripts/mod/modpost.h | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index b317328ae21b..ebfa9b76ba92 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -175,18 +175,12 @@ static struct module *find_module(const char *modname) static struct module *new_module(const char *modname) { struct module *mod; - char *p; - mod = NOFAIL(malloc(sizeof(*mod))); + mod = NOFAIL(malloc(sizeof(*mod) + strlen(modname) + 1)); memset(mod, 0, sizeof(*mod)); - p = NOFAIL(strdup(modname)); - - /* strip trailing .o */ - if (strends(p, ".o")) - p[strlen(p) - 2] = '\0'; /* add to list */ - mod->name = p; + strcpy(mod->name, modname); mod->is_vmlinux = is_vmlinux(modname); mod->gpl_compatible = -1; mod->next = modules; @@ -2013,7 +2007,15 @@ static void read_symbols(const char *modname) if (!parse_elf(&info, modname)) return; - mod = new_module(modname); + { + char *tmp; + + /* strip trailing .o */ + tmp = NOFAIL(strdup(modname)); + tmp[strlen(tmp) - 2] = '\0'; + mod = new_module(tmp); + free(tmp); + } if (!mod->is_vmlinux) { license = get_modinfo(&info, "license"); diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 264c0c51defa..1df87d204c9a 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -116,7 +116,6 @@ struct namespace_list { struct module { struct module *next; - const char *name; int gpl_compatible; struct symbol *unres; int from_dump; /* 1 if module was loaded from *.symver */ @@ -130,6 +129,7 @@ struct module { struct namespace_list *missing_namespaces; // Actual imported namespaces struct namespace_list *imported_namespaces; + char name[]; }; struct elf_info { From patchwork Mon Jun 1 05:57:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581331 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C74CA92A for ; Mon, 1 Jun 2020 05:58:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEF1A206C3 for ; Mon, 1 Jun 2020 05:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991104; bh=9dDjrmBdNrHV1ch2r7em4o/AF94SZfyP2peO3PC4X9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=rsTR57H0XIc7aptVQCO/bvCevIrsnwYhJYx4NuLuqfbLnIPomR97VCVZhRtWPfT+u DNv2P7cWRoZgFa22qLgOikTTnT6iy/uaT2EysrgREKJ8dUfD9EQ87NBgqpYn1MBrs2 B9nBkjHSe/Fbgyt3QDM5t1wwbtyV1MOt+5U578JY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726265AbgFAF6Y (ORCPT ); Mon, 1 Jun 2020 01:58:24 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40026 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727121AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaMF023694; Mon, 1 Jun 2020 14:57:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaMF023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991072; bh=WmqEx7oXxUtLIW9w8WYHcY4WT5S6a7AqK82zGiT0xZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sAkMYyJYr6Y3oc9YYfu2PEljwb2DsmCPiLTqLo53r2vPghtV5ZOky2y+xrvhxOjad IMu4/FR6AwYA7bbmOYE16NY1oWSJEm97aqrcAhU9Zys5aWwsCUPjrDrIMQoh1mjXUV ZXpYYL8UMw15DWKEliiY7IEoVoKoypiiMtuucc2joRDues9v2uew3TAPSYRuwdvQ4H 8M6wElB8VzFctZVWEaM444TwrioPavMQgqRYttaQJ2vD6QGyRyqYqrXxadkTaTq0DT 2gp5v7Vo+cSrBeoGDlqzjfwX/2fiGyoQUh+V0KlIG5JET1PWvTBSnw74IMAiwffWQ0 HbnhWLu6fHAKg== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 36/37] modpost: remove is_vmlinux() helper Date: Mon, 1 Jun 2020 14:57:30 +0900 Message-Id: <20200601055731.3006266-36-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Now that is_vmlinux() is called only in new_module(), we can inline the function call. modname is the basename with '.o' is stripped. No need to compare it with 'vmlinux.o'. vmlinux is always located at the current working directory. No need to strip the directory path. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index ebfa9b76ba92..a3ffabf4eca5 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -88,20 +88,6 @@ static inline bool strends(const char *str, const char *postfix) return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0; } -static int is_vmlinux(const char *modname) -{ - const char *myname; - - myname = strrchr(modname, '/'); - if (myname) - myname++; - else - myname = modname; - - return (strcmp(myname, "vmlinux") == 0) || - (strcmp(myname, "vmlinux.o") == 0); -} - void *do_nofail(void *ptr, const char *expr) { if (!ptr) @@ -181,7 +167,7 @@ static struct module *new_module(const char *modname) /* add to list */ strcpy(mod->name, modname); - mod->is_vmlinux = is_vmlinux(modname); + mod->is_vmlinux = (strcmp(modname, "vmlinux") == 0); mod->gpl_compatible = -1; mod->next = modules; modules = mod; From patchwork Mon Jun 1 05:57:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11581335 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60514159A for ; Mon, 1 Jun 2020 05:58:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3CB84206C3 for ; Mon, 1 Jun 2020 05:58:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590991105; bh=7bk6x8xccaqAogJDgl3tIxldH8MtA7Akgx16XVcIwHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RzUuEt7tZnLLsAAwVqDIGGOmoZdt2LnP3IQ4GQFktHr7H7D0u8K95+0+gp+DpnQdg 97Mjl8nwt4+8clWuLgpgnXBfHi1atezjkKU23nYLwLaUlq/r9U8qrRI2kq22KqKNfM LWQDE8Hpodm6Fr+HhhSROzFgDNTamDezGk0gB4jI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbgFAF6Y (ORCPT ); Mon, 1 Jun 2020 01:58:24 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40006 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727056AbgFAF6V (ORCPT ); Mon, 1 Jun 2020 01:58:21 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 0515vaMG023694; Mon, 1 Jun 2020 14:57:53 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 0515vaMG023694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1590991073; bh=oCf4bI+4OjqqzXqDWdSRzSLjiycwo5uTHdKWxxwXsSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QC2oqW/HPAHMAnlGn+xt+0sm0t4k4LE2M8Ex1DVt2VVZT+yBpuyk8AeE3HoGmn7XG N9g8ktKcIxIlBPyEZDmqTeebOVl/aR0D/1L3kpwj32kYHAYBASuTcf/YP6A2MV7wCN 1Eh8M7kmwUTjEtTkgylgfAFVdxt5UKZO5hNnPe1GwqXnAdYJKwhvlNmpJW0vNevIxw 5yZoIDvm/mrT00laQqddUIfO/J6hH3hWfOdn1JOfcA09XpUhq2lz4wxf9dECwwb13Z W42zKh/g+BdI3jItvMaeWZbKFDUaKqS3H8QS+v0DlTeLJqT44tw7gscv9ccJuIBAba QXLr+s8gNjrbQ== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada Subject: [PATCH 37/37] modpost: change elf_info->size to size_t Date: Mon, 1 Jun 2020 14:57:31 +0900 Message-Id: <20200601055731.3006266-37-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601055731.3006266-1-masahiroy@kernel.org> References: <20200601055731.3006266-1-masahiroy@kernel.org> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Align with the mmap / munmap APIs. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 9 ++++----- scripts/mod/modpost.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index a3ffabf4eca5..e5cee2367d5e 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -443,7 +443,7 @@ static void sym_set_crc(const char *name, unsigned int crc) s->crc_valid = 1; } -static void *grab_file(const char *filename, unsigned long *size) +static void *grab_file(const char *filename, size_t *size) { struct stat st; void *map = MAP_FAILED; @@ -465,7 +465,7 @@ static void *grab_file(const char *filename, unsigned long *size) return map; } -static void release_file(void *file, unsigned long size) +static void release_file(void *file, size_t size) { munmap(file, size); } @@ -521,9 +521,8 @@ static int parse_elf(struct elf_info *info, const char *filename) /* Check if file offset is correct */ if (hdr->e_shoff > info->size) { - fatal("section header offset=%lu in file '%s' is bigger than " - "filesize=%lu\n", (unsigned long)hdr->e_shoff, - filename, info->size); + fatal("section header offset=%lu in file '%s' is bigger than filesize=%zu\n", + (unsigned long)hdr->e_shoff, filename, info->size); return 0; } diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 1df87d204c9a..efb74dba19e2 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -133,7 +133,7 @@ struct module { }; struct elf_info { - unsigned long size; + size_t size; Elf_Ehdr *hdr; Elf_Shdr *sechdrs; Elf_Sym *symtab_start;