Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2030674pxb; Fri, 5 Mar 2021 05:57:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4Clw/karpZsYdcYHo+aBrMo2n/PqR2y6ucC06nLn/aNNxPyw1MZUk973Wc/Qp1xKi2yY/ X-Received: by 2002:a17:906:be9:: with SMTP id z9mr2254332ejg.35.1614952655665; Fri, 05 Mar 2021 05:57:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614952655; cv=none; d=google.com; s=arc-20160816; b=hz8G6EMsAkbr7THCbDNoXnSQkvX8FPN7eQrx77wfLkBNOJuA719mAeJ41GeIbi10lc iV1vvKSJ/vkQR9hAphq5QSPOOyRUXhTOAJEputNjEfBdmSVS+hQGxdxxCm2UawsuFbx7 eAhhdr//CSJwBNhrB+QmMsBVnWNcfuWGkCRs4KArho5vBjDmFZkMLkveeKGdL4UdJjpF qtOOsZGiRcOWSCpV/SjE4rbQTY3ouJNKRKlrqHrJZBvnq+5E4lz5BkF8sTJZTJ0cpWQv P3ND5I6KjTIBTemopr6BHeN8LXERvD21IqwWzJXWBFtvaxcagmno//BLAd7xsMcghyJY r7Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=gorpGuAhtEpGkHjUmP5bgqI3IOdhshyc5dAFbcNCONc=; b=iu0T//MQzl1OC2hBYovDmtn3IcbHc2xigbgVzQC3t6J6lGuglzoqS552ClkZYzFprC LNkqNmyOcA+/XgPmvIeZuT6Nu8I2V615fbcPLx2NtDM/YNNilol+2gkDQN4psjVPRKqX YPAs1kaFafoHs+Ld6BwcieIUKnPQmBgGe4cvq1BttbeuK4PN8fiAUZp8p6ArxH4yqvUO Tb9IPTwt9d86T1llQELbqoWgeWR2Ly12KKl1pXbI4fAHDDqJ4ZQW5+WPfmhh64iCfCJQ jSs2CpmyZ2/8EVD1eKrMsJM+iBTxx0s6M8Ph4B2/hm/1VHEvWkkc+yAQhCVUHAptpsw+ oFsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=BnZKt7MU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id se15si1326414ejb.204.2021.03.05.05.57.13; Fri, 05 Mar 2021 05:57:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=BnZKt7MU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230475AbhCENwa (ORCPT + 99 others); Fri, 5 Mar 2021 08:52:30 -0500 Received: from conssluserg-03.nifty.com ([210.131.2.82]:61423 "EHLO conssluserg-03.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230399AbhCENwD (ORCPT ); Fri, 5 Mar 2021 08:52:03 -0500 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (authenticated) by conssluserg-03.nifty.com with ESMTP id 125DpRxZ009590; Fri, 5 Mar 2021 22:51:27 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com 125DpRxZ009590 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1614952288; bh=gorpGuAhtEpGkHjUmP5bgqI3IOdhshyc5dAFbcNCONc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=BnZKt7MUMSs13+J/je9z+lkmhYhSyhyFPKASu9/bT58+zQ+NodOft1gJLwBl2bJJf nhHpLRF+PtvVCJDsv2i7temB/Pqm7zr7/8yfQKeXWBoiB4h3MWIqR8XHrjYQoDGZg/ bRANLS/yp5IaiLr9Vm4Z2WjTlHdqzdAVYS+xM5bCwGB3Sw5wbM5zwWYtGt/hg1g1y0 m9FaMaS+fAB9C861fs4SAH/NBJJtWmEqsV8OgkSo7eJjp3FLJviNzP7sMyuCFEDUEw E1Vob0jU+CpBCbIM45sy4EJNi7fCXNeoNs7GevfXZCW6/0E2ARcqAxmQ795WYFxQEB txVSXcsWzPPyA== X-Nifty-SrcIP: [209.85.210.175] Received: by mail-pf1-f175.google.com with SMTP id w18so2101604pfu.9; Fri, 05 Mar 2021 05:51:27 -0800 (PST) X-Gm-Message-State: AOAM530BfW4dE6ZCKdF5rcMS/Y8gdOqqt22uDJ3ZddRo8p+4MpbqYDs5 VJkBNtmtaEWDOauciLDr+st2s0MXpSSulzwnpA4= X-Received: by 2002:a63:dd49:: with SMTP id g9mr8934181pgj.175.1614952286939; Fri, 05 Mar 2021 05:51:26 -0800 (PST) MIME-Version: 1.0 References: <20210305092707.740539-1-linux@rasmusvillemoes.dk> In-Reply-To: <20210305092707.740539-1-linux@rasmusvillemoes.dk> From: Masahiro Yamada Date: Fri, 5 Mar 2021 22:50:49 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] kbuild: add CONFIG_VMLINUX_MAP expert option To: Rasmus Villemoes Cc: Jonathan Corbet , Michal Marek , Linux Kernel Mailing List , "open list:DOCUMENTATION" , Linux Kbuild mailing list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 5, 2021 at 6:27 PM Rasmus Villemoes wrote: > > It can be quite useful to have ld emit a link map file, in order to > debug or verify that special sections end up where they are supposed > to, and to see what LD_DEAD_CODE_DATA_ELIMINATION manages to get rid > of. > > The only reason I'm not just adding this unconditionally is that the > .map file can be rather large (several MB), and that's a waste of > space when one isn't interested in these things. Also make it depend > on CONFIG_EXPERT. > > Signed-off-by: Rasmus Villemoes > --- Applied to linux-kbuild. Thanks. > .gitignore | 1 + > Documentation/dontdiff | 1 + > lib/Kconfig.debug | 10 ++++++++++ > scripts/link-vmlinux.sh | 8 ++++++++ > 4 files changed, 20 insertions(+) > > diff --git a/.gitignore b/.gitignore > index 3af66272d6f1..3adea59847ce 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -59,6 +59,7 @@ modules.order > /linux > /vmlinux > /vmlinux.32 > +/vmlinux.map > /vmlinux.symvers > /vmlinux-gdb.py > /vmlinuz > diff --git a/Documentation/dontdiff b/Documentation/dontdiff > index e361fc95ca29..ac42ad8d430d 100644 > --- a/Documentation/dontdiff > +++ b/Documentation/dontdiff > @@ -252,6 +252,7 @@ vmlinux-* > vmlinux.aout > vmlinux.bin.all > vmlinux.lds > +vmlinux.map > vmlinux.symvers > vmlinuz > voffset.h > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index 5ea0c1773b0a..663c1cd5018c 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -412,6 +412,16 @@ config VMLINUX_VALIDATION > depends on STACK_VALIDATION && DEBUG_ENTRY && !PARAVIRT > default y > > +config VMLINUX_MAP > + bool "Generate vmlinux.map file when linking" > + depends on EXPERT > + help > + Selecting this option will pass "-Map=vmlinux.map" to ld > + when linking vmlinux. That file can be useful for verifying > + and debugging magic section games, and for seeing which > + pieces of code get eliminated with > + CONFIG_LD_DEAD_CODE_DATA_ELIMINATION. > + > config DEBUG_FORCE_WEAK_PER_CPU > bool "Force weak per-cpu definitions" > depends on DEBUG_KERNEL > diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh > index 3b261b0f74f0..855fd4e6f03e 100755 > --- a/scripts/link-vmlinux.sh > +++ b/scripts/link-vmlinux.sh > @@ -155,6 +155,7 @@ vmlinux_link() > local output=${1} > local objects > local strip_debug > + local map_option > > info LD ${output} > > @@ -166,6 +167,10 @@ vmlinux_link() > strip_debug=-Wl,--strip-debug > fi > > + if [ -n "${CONFIG_VMLINUX_MAP}" ]; then > + map_option="-Map=${output}.map" > + fi > + > if [ "${SRCARCH}" != "um" ]; then > if [ -n "${CONFIG_LTO_CLANG}" ]; then > # Use vmlinux.o instead of performing the slow LTO > @@ -187,6 +192,7 @@ vmlinux_link() > ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \ > ${strip_debug#-Wl,} \ > -o ${output} \ > + ${map_option} \ > -T ${lds} ${objects} > else > objects="-Wl,--whole-archive \ > @@ -200,6 +206,7 @@ vmlinux_link() > ${CC} ${CFLAGS_vmlinux} \ > ${strip_debug} \ > -o ${output} \ > + ${map_option:+-Wl,${map_option}} \ > -Wl,-T,${lds} \ > ${objects} \ > -lutil -lrt -lpthread > @@ -303,6 +310,7 @@ cleanup() > rm -f .tmp_vmlinux* > rm -f System.map > rm -f vmlinux > + rm -f vmlinux.map > rm -f vmlinux.o > } > > -- > 2.29.2 > -- Best Regards Masahiro Yamada