From patchwork Wed Jan 16 23:47:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 155776 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1275459jaa; Wed, 16 Jan 2019 15:48:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN4KK0r89yXf5RKpv687eUjzrXeBD1e79pKATWh0d5GlDuUnkKJOKYcMUEp8HSHLRXx9jBqN X-Received: by 2002:a63:381c:: with SMTP id f28mr11376444pga.330.1547682501788; Wed, 16 Jan 2019 15:48:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547682501; cv=none; d=google.com; s=arc-20160816; b=AqZGnCULEkcLwgzlbPNnycnYO0TfpWUR0p2gl+GlfOY3PH8Gt4Hyw3igU/CSlAocgK Jb5CC4OtsEfiYxlnJ+2NR5CdKMjJaMlYIpXmu0doX6ggHicc6MMM9RWqk6SIqNvxVKXa tweL26QFYPYsQY9kfSi6A3gPQYHD+Wl46UhkdoddxS7qJ5al8qN6ySIX4ncMXeBmS9IS bi11PlP5XxJhllbsQ0KXS3r07Gjht0PuTr03iHW0m8f3Os+F/v9X/wXQ1MZik2ikOV4d Zd6jCEsGzgoWUyP1Atn6bbRybxnn9llvrYT4RVM0dUE5HLGJUf4PMwGO7lRqdw4ZKw/h TneA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=1niHfBQ4p084/1Rej36WNDvd4xsjnCJJlL75317mYQc=; b=tMtsNQGfJwf9J1ovHYNY2yaYoAQ/PF0f30ULpWp+PVC1DppOX7TiBbaFpNFyPp3qky AX6MzVoYZ5D6FkXXfy8T9MGtAjWTyggTENKrsEF3nvKl5jacM42sldcXoVvn9lF86UC0 yrAucMFHiNB/hVhvu9aoP96u7nX5UKyQ4MGRa94UOWyd64Ve5/khgQaiJreI5M8dK4Gz IP1Lwu6UaUBCrh2V1plsctBPmAlb3Pl9iOwnw2G0e0dHpbFRYJIwrSBOjlJA/J1pmi2E f4jwX0eQUuYKQde3RmgiZ94+jXQijc1IqfE3gmEsnFtFdv6tQ8I2vpwFr2dvNIzWoI58 TSNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=KIlD2UY8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2si7440333pgs.96.2019.01.16.15.48.21; Wed, 16 Jan 2019 15:48:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=KIlD2UY8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727831AbfAPXsU (ORCPT + 22 others); Wed, 16 Jan 2019 18:48:20 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:44582 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727756AbfAPXsU (ORCPT ); Wed, 16 Jan 2019 18:48:20 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-10.nifty.com with ESMTP id x0GNlUSc007588; Thu, 17 Jan 2019 08:47:30 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com x0GNlUSc007588 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1547682451; bh=1niHfBQ4p084/1Rej36WNDvd4xsjnCJJlL75317mYQc=; h=From:To:Cc:Subject:Date:From; b=KIlD2UY8lqP1VCg/UqxO4uloEnUpBs/mYODJD+IhlCBhK1daA6Srp283ZMwz/VVvK Fsd1/XRYl9EsFx+ex2jy/ky+qJdweoznbu18hMO9P1z7xbsPCxqRldJnMGo5s10u/9 1ou6wfjIQSmgmVzwPetHEc2MrMe6k/ZmRWx1Td7Pq8JjnOhnVyVC3s1+1ocldKFxGs bfWBMZtI8zsM+VHIcFsddO5p6vFnaqzoVE2+bof0VdCzSyM8fbg+PLxaPhO6IVgDpW rjxGj8C+1sHi1LjP/Cpk6Ed2RAd6HF9aGgCtXTTkPZAUH2t4YqmacgcaPreq7O19bs iSpplNbtTR2Hg== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Stephen Rothwell , Nicholas Piggin , Masahiro Yamada , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Corbet , Michal Marek Subject: [PATCH v2 1/2] kbuild: remove top-level built-in.a Date: Thu, 17 Jan 2019 08:47:24 +0900 Message-Id: <1547682445-15114-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The symbol table in the final archive is unneeded; the linker does not require the symbol table after the --whole-archive option. Every object file in the archive is included in the link anyway. Pass thin archives from subdirectories directly to the linker, and remove the final archiving step. Fix up the document and comments as well. Signed-off-by: Masahiro Yamada Acked-by: Nicholas Piggin --- Changes in v2: - Update the document and comments - Add Nicholas' Ack Documentation/kbuild/makefiles.txt | 9 ++------- scripts/Makefile.build | 8 ++------ scripts/link-vmlinux.sh | 30 ++++++------------------------ 3 files changed, 10 insertions(+), 37 deletions(-) -- 2.7.4 diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index bf28c47..48eab0b 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -154,13 +154,8 @@ more details, with real examples. Kbuild compiles all the $(obj-y) files. It then calls "$(AR) rcSTP" to merge these files into one built-in.a file. - This is a thin archive without a symbol table, which makes it - unsuitable as a linker input. - - The scripts/link-vmlinux.sh script later makes an aggregate - built-in.a with "${AR} rcsTP", which creates the thin archive - with a symbol table and an index, making it a valid input for - the final vmlinux link passes. + This is a thin archive without a symbol table. It will be later + linked into vmlinux by scripts/link-vmlinux.sh The order of files in $(obj-y) is significant. Duplicates in the lists are allowed: the first instance will be linked into diff --git a/scripts/Makefile.build b/scripts/Makefile.build index fd03d60..681ab58 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -394,14 +394,10 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler $(sort $(subdir-obj-y)): $(subdir-ym) ; # -# Rule to compile a set of .o files into one .o file +# Rule to compile a set of .o files into one .a file (without symbol table) # ifdef builtin-target -# built-in.a archives are made with no symbol table or index which -# makes them small and fast, but unable to be used by the linker. -# scripts/link-vmlinux.sh builds an aggregate built-in.a with a symbol -# table and index. quiet_cmd_ar_builtin = AR $@ cmd_ar_builtin = rm -f $@; \ $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(filter $(real-obj-y), $^) @@ -426,7 +422,7 @@ $(modorder-target): $(subdir-ym) FORCE $(Q)(cat /dev/null; $(modorder-cmds)) > $@ # -# Rule to compile a set of .o files into one .a file +# Rule to compile a set of .o files into one .a file (with symbol table) # ifdef lib-target quiet_cmd_link_l_target = AR $@ diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index c8cf453..4788def 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -44,24 +44,6 @@ info() fi } -# Thin archive build here makes a final archive with symbol table and indexes -# from vmlinux objects INIT and MAIN, which can be used as input to linker. -# KBUILD_VMLINUX_LIBS archives should already have symbol table and indexes -# added. -# -# Traditional incremental style of link does not require this step -# -# built-in.a output file -# -archive_builtin() -{ - info AR built-in.a - rm -f built-in.a; - ${AR} rcsTP${KBUILD_ARFLAGS} built-in.a \ - ${KBUILD_VMLINUX_INIT} \ - ${KBUILD_VMLINUX_MAIN} -} - # Link of vmlinux.o used for section mismatch analysis # ${1} output file modpost_link() @@ -69,7 +51,8 @@ modpost_link() local objects objects="--whole-archive \ - built-in.a \ + ${KBUILD_VMLINUX_INIT} \ + ${KBUILD_VMLINUX_MAIN} \ --no-whole-archive \ --start-group \ ${KBUILD_VMLINUX_LIBS} \ @@ -88,7 +71,8 @@ vmlinux_link() if [ "${SRCARCH}" != "um" ]; then objects="--whole-archive \ - built-in.a \ + ${KBUILD_VMLINUX_INIT} \ + ${KBUILD_VMLINUX_MAIN} \ --no-whole-archive \ --start-group \ ${KBUILD_VMLINUX_LIBS} \ @@ -99,7 +83,8 @@ vmlinux_link() -T ${lds} ${objects} else objects="-Wl,--whole-archive \ - built-in.a \ + ${KBUILD_VMLINUX_INIT} \ + ${KBUILD_VMLINUX_MAIN} \ -Wl,--no-whole-archive \ -Wl,--start-group \ ${KBUILD_VMLINUX_LIBS} \ @@ -160,7 +145,6 @@ cleanup() rm -f .tmp_System.map rm -f .tmp_kallsyms* rm -f .tmp_vmlinux* - rm -f built-in.a rm -f System.map rm -f vmlinux rm -f vmlinux.o @@ -217,8 +201,6 @@ fi; # final build of init/ ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init -archive_builtin - #link vmlinux.o info LD vmlinux.o modpost_link vmlinux.o From patchwork Wed Jan 16 23:47:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 155775 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1275372jaa; Wed, 16 Jan 2019 15:48:14 -0800 (PST) X-Google-Smtp-Source: ALg8bN4H29FFnuHcZ9uYIn7xBYP18/VOzsprDUSivZRJ3OXbypz+iwhaR6bVmU6rtKdIBgNUxLuj X-Received: by 2002:a63:a401:: with SMTP id c1mr11309648pgf.403.1547682494629; Wed, 16 Jan 2019 15:48:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547682494; cv=none; d=google.com; s=arc-20160816; b=Lfjx2CAgqVei+vc38GDizglP1OvrB33b9yiMcd1jPpwDOx1XiGn7IensNkpHds7dQ+ +baSz4cFLUY/CGFBxthTkOXT4mIscgzjOAliBhKpbwBaXmgGBzsfGH+AD2j4VliNNf7v tEgI/oFRCzpJF7X6zGo9dzwGkHXRoSr6N5RD/ZWCPjzLy5rxZDFGhXzxoLWYcDFd1g2Z blvymIRTmlYOtPIxHen7+NfCUaMSue3enCU+syd7vPe9VRchdyLAy8Wx1NfUas6xA28y xp4fJMkqClTka6hvSkfuB7tnOoNG4aE7f2MJAXFrrlYIe9wcMJkmvP3b7Co/659tplz3 kw1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=ucmPOdkEWFm7KeFxfqYj+lx9TtDNtOXjPde+MbjHfJs=; b=mpToa2mDOwqEBIGGDbnvUkTCp79ikwdr9UhKKS75TZNU05wQDYBs7DexwGCTzTWMHB M3YFDTj+lRVSvQ23iWgo+Niq1FjhLpWbXkeqsok0PUjuArYVAv78WuNSNUKGTr8GzGHu k/3R3HKf0ltSpERUHQyJqGMig5GIDy/Mfnmz/Kuu/2QKdteMrFWaetqsU19Y1uN/ayCC fLzSHgJCnTOEjapdM6OtTQxTSSuSSQK+dPTks6PzZw+Jyd1JVmUDnCYQHMNA+svhlA8K 2M86tAe8ElF21D2Y7sLPqxvpFRmV5TJbE+6shT6nT6s4HnsS/HHzEaGUFStwalFxy7fT OTkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=zyaLYwpL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r28si7002653pgm.317.2019.01.16.15.48.14; Wed, 16 Jan 2019 15:48:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=zyaLYwpL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727801AbfAPXsN (ORCPT + 22 others); Wed, 16 Jan 2019 18:48:13 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:44401 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727762AbfAPXsN (ORCPT ); Wed, 16 Jan 2019 18:48:13 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-10.nifty.com with ESMTP id x0GNlUSd007588; Thu, 17 Jan 2019 08:47:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com x0GNlUSd007588 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1547682452; bh=ucmPOdkEWFm7KeFxfqYj+lx9TtDNtOXjPde+MbjHfJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zyaLYwpLd+qhCqBYWy3pcVVRilpMqDH/nIBmjqdgT6fHZNP2OB1tSMIIfCcbD1lXd Rd4rix/PEeaDE03JPV1mu4CdNSAvJOnKtt2XYbaVIqdLYOcFW/ms2L7tZm4yddVR2N FKRUiIi+MUBguHdpgzzGpiueK1tICnfOB5Yf5MngS/FiEW00k9RmcLwjUl7LrGWfcN Teqm3lDpYaseuz/IrzeRpLefGBrAIpdGtwUDEj8kQa6/0wUlzEnfaN9chiECiPb6if y/oA1PsaKNbEdJrIJl+O9uPDLq+7onrlA1sSIuv69+GJH3vuMNabRmwQpkdmhh1wiy zMPwO/VR0U38A== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Stephen Rothwell , Nicholas Piggin , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] kbuild: merge KBUILD_VMLINUX_{INIT, MAIN} into KBUILD_VMLINUX_OBJS Date: Thu, 17 Jan 2019 08:47:25 +0900 Message-Id: <1547682445-15114-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547682445-15114-1-git-send-email-yamada.masahiro@socionext.com> References: <1547682445-15114-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The top Makefile does not need to export KBUILD_VMLINUX_INIT and KBUILD_VMLINUX_MAIN separately. Put every built-in.a into KBUILD_VMLINUX_OBJS. The order of $(head-y), $(init-y), $(core-y), ... is still retained. Signed-off-by: Masahiro Yamada --- Changes in v2: None Makefile | 6 +++--- scripts/link-vmlinux.sh | 28 ++++++++++------------------ 2 files changed, 13 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index 499b968..68898cc 100644 --- a/Makefile +++ b/Makefile @@ -975,15 +975,15 @@ libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y))) virt-y := $(patsubst %/, %/built-in.a, $(virt-y)) # Externally visible symbols (used by link-vmlinux.sh) -export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) -export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-y) +export KBUILD_VMLINUX_OBJS := $(head-y) $(init-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 export LDFLAGS_vmlinux # used by scripts/package/Makefile export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) -vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) +vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) # Recurse until adjust_autoksyms.sh is satisfied PHONY += autoksyms_recursive diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 4788def..bc7f1fc 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -3,22 +3,17 @@ # # link vmlinux # -# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and -# $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.a files -# from top-level directories in the kernel tree, others are specified in -# arch/$(ARCH)/Makefile. Ordering when linking is important, and -# $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives -# which are linked conditionally (not within --whole-archive), and do not -# require symbol indexes added. +# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_OBJS) and +# $(KBUILD_VMLINUX_LIBS). Most are built-in.a files from top-level directories +# in the kernel tree, others are specified in arch/$(ARCH)/Makefile. +# $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally +# (not within --whole-archive), and do not require symbol indexes added. # # vmlinux # ^ # | -# +-< $(KBUILD_VMLINUX_INIT) -# | +--< init/version.o + more -# | -# +--< $(KBUILD_VMLINUX_MAIN) -# | +--< drivers/built-in.a mm/built-in.a + more +# +--< $(KBUILD_VMLINUX_OBJS) +# | +--< init/built-in.a drivers/built-in.a mm/built-in.a + more # | # +--< $(KBUILD_VMLINUX_LIBS) # | +--< lib/lib.a + more @@ -51,8 +46,7 @@ modpost_link() local objects objects="--whole-archive \ - ${KBUILD_VMLINUX_INIT} \ - ${KBUILD_VMLINUX_MAIN} \ + ${KBUILD_VMLINUX_OBJS} \ --no-whole-archive \ --start-group \ ${KBUILD_VMLINUX_LIBS} \ @@ -71,8 +65,7 @@ vmlinux_link() if [ "${SRCARCH}" != "um" ]; then objects="--whole-archive \ - ${KBUILD_VMLINUX_INIT} \ - ${KBUILD_VMLINUX_MAIN} \ + ${KBUILD_VMLINUX_OBJS} \ --no-whole-archive \ --start-group \ ${KBUILD_VMLINUX_LIBS} \ @@ -83,8 +76,7 @@ vmlinux_link() -T ${lds} ${objects} else objects="-Wl,--whole-archive \ - ${KBUILD_VMLINUX_INIT} \ - ${KBUILD_VMLINUX_MAIN} \ + ${KBUILD_VMLINUX_OBJS} \ -Wl,--no-whole-archive \ -Wl,--start-group \ ${KBUILD_VMLINUX_LIBS} \