Message ID | 20230330182223.181775-1-hi@alyssa.is |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp78110vqo; Thu, 30 Mar 2023 12:14:57 -0700 (PDT) X-Google-Smtp-Source: AKy350a4wj9p12Fef+3iTxlzHBsBYvE04f0UtAyOJLc/XhqsQvL6jFYEJZ0WKzJ6KFOk0DQYj5Ig X-Received: by 2002:aa7:9f8f:0:b0:628:9b4:a6a2 with SMTP id z15-20020aa79f8f000000b0062809b4a6a2mr21531916pfr.15.1680203697171; Thu, 30 Mar 2023 12:14:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680203697; cv=none; d=google.com; s=arc-20160816; b=bAHDlf0l8fqZxWVjXZoApfjKqUsE50YH/YOhHyDzYazQaP6lDyFp9BSmUeR6Vj0vdJ vNzvToOgRWqPmL7tajCKPXXRYh3CjGeUHNTEKnVxAvEcj11ehuH6MnJNrbJOsakXPn9a lExnR1U3ee8sYb+a1WqrjRwJIT09LYayDcmopJ513JdyM6nVgB05EA4DUvRfxS3bewT+ f16GhRjEtfLtxAwQeV/2LO6aUUSpXAXVlkXFxQJgNpSachtT4pQ71WSiUL+yXgnsmrat P0F+yYaundpe7Uo49oFbXh9XnspM/vAO5JXa4ep1liba4YW2ha2rh33oicfMSegOgQFs 55sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:feedback-id:dkim-signature :dkim-signature; bh=TDo5jZQU9IC6sywgEGOqzPOxZ7aUBvX49rI+0P5qm4M=; b=rirwO/JKv8R++EBXybMkij+Exr08UTANflDs/nLH9B99qOBo9zia9Ib9cn84qtu/l7 V1SABwxlD4R4mLYAHL/vtqsMJVshrf/PNIszpMePueaCaoK0kLRkbw58SAE9HH94lOqR fxO0V8xMaxLNxhD0s/qe5SG5vY/4TG+I+xkevrzIU3//ni70F7nzgqYKF8sb/fRiT1Zw rjz88tNRgnBFNYB5T5THt0kcJmu2wyZ9Pw/1RA+nG6swLjQLrpX1uakEpSfn6ptH+IFh UKSiRw5PLd3DNezs2ky/WLe60Tkfv/Rw267FHTWmADTZFS7wT+maLc3Vh3sDuaIDzNfk Z39g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alyssa.is header.s=fm1 header.b=YUUnIRZL; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=ajTGmETH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q65-20020a632a44000000b004fbfc2b436bsi351173pgq.517.2023.03.30.12.14.43; Thu, 30 Mar 2023 12:14:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alyssa.is header.s=fm1 header.b=YUUnIRZL; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=ajTGmETH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231379AbjC3Szt (ORCPT <rfc822;rua109.linux@gmail.com> + 99 others); Thu, 30 Mar 2023 14:55:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbjC3Szs (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 30 Mar 2023 14:55:48 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC6D2DE; Thu, 30 Mar 2023 11:55:46 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 796255C0140; Thu, 30 Mar 2023 14:55:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 30 Mar 2023 14:55:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to; s=fm1; t=1680202543; x=1680288943; bh=TDo5jZQU9I C6sywgEGOqzPOxZ7aUBvX49rI+0P5qm4M=; b=YUUnIRZLMok8GCi4FocI0W8ffH OCnwU3bxzlbM5/7WDWYUo45uJ1bg8XOdyeuze5G16V52Aww+hYfVu1D0PKbBAgH4 zkQXOQaKQu0SXIqtObwFme1g4B4Vbp8uEdBqnFseJxGS4n1MLuwtaP6waWwLfOXr KgxghKpkpR2g622ml3kXoBaZj0/vFGdIaERQxhoy8oQOtb7TcNlxFQ0140bFdmeq q4qRzIJFVyzlV1TUN9sSIOyC/GtalhQKMWBKU4gZi/m/RE6N9Syg55ZRBglmvZIg wxsNmk4zolUakgbsBB/gI5bRS/PGP/PFGwZY4n4CHSnGq4agNBujAg5iFgOw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1680202543; x=1680288943; bh=TDo5jZQU9IC6s ywgEGOqzPOxZ7aUBvX49rI+0P5qm4M=; b=ajTGmETHYzYFDrstGf22x7WNZofkA NT8vzSXDCiLD64FmeN/IdTu7WOv2vl2NLzFTlpGQgZMavTYMrp2CRo5a2/mWZPWO qz6v3pqocDBXEFJs+6Oxckah37XAJmfcHedQpQ2cpoL/2pqwuEhYyXWr76IEIkBK iQJYf+7jIxDyPDZn1bPB6kq6thoItnnyGI9cmckDzjFM6hk1SLoCgzByblbLUfH2 mAxGgmqKJRnGOhZiPfMqh7/HcZqV9/+hgmF0RKwMR3qIqrLftdCDznRDzwL0FEDv Ep39owL9m34YQLVXatTtxG/szBiYeRit+YG5WJWnpQ/qDpmnBtFMZaJ1Q== X-ME-Sender: <xms:LtslZH6_F25VBTpOAFRk0gSKxli1GSUkbbQWyUndO95RF6Y56khtWA> <xme:LtslZM7YRUqU_xB5XRYRQo5T3gPE1pkQiR2XdfMRzIbA4b72YjFqW8shok9IKKd7y dN5u-9Dr9V45t3r1w> X-ME-Received: <xmr:LtslZOe7ztlwA7GxRLBUrrirh73AZD4Sv3XAqDKBNh1LVp3_5Tda48DjHBMLL84JHgIF028L9UExtIG1wqtC6UO3ut-_uwwK> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehledgfeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgggfestdekredtredttdenucfhrhhomheptehlhihsshgr ucftohhsshcuoehhihesrghlhihsshgrrdhisheqnecuggftrfgrthhtvghrnhepueefie dvheffveegieejjeevgfejjeduveekffeiveeuvedvtedvhfelieeutdfgnecuffhomhgr ihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehhihesrghlhihsshgrrdhish X-ME-Proxy: <xmx:LtslZIL3rkl7TX1GDdSypybenFWILqzROWAeeos8jvsYoI13L-PK-Q> <xmx:LtslZLLy-bW9CXCjyB7dTbzS5NpayGemdVvygt9DAykZGpggMXaKaw> <xmx:LtslZBzedqTWGZ0FoZ-wkJLpp6DPC74p5DUGlfrYSGHSm1oc7aTIgA> <xmx:L9slZAdMAkfdHmY_WUtkjG1bTdRT_nNFH5DIHtHYZPftdRVLemcgPw> Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 30 Mar 2023 14:55:42 -0400 (EDT) Received: by x220.qyliss.net (Postfix, from userid 1000) id 3BF532412; Thu, 30 Mar 2023 18:55:41 +0000 (UTC) From: Alyssa Ross <hi@alyssa.is> To: Masahiro Yamada <masahiroy@kernel.org> Cc: Nick Cao <nickcao@nichi.co>, linux-kbuild@vger.kernel.org, Nick Desaulniers <ndesaulniers@google.com>, Nathan Chancellor <nathan@kernel.org>, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-riscv@lists.infradead.org, Tom Rix <trix@redhat.com>, Albert Ou <aou@eecs.berkeley.edu>, Palmer Dabbelt <palmer@dabbelt.com>, Paul Walmsley <paul.walmsley@sifive.com>, Alyssa Ross <hi@alyssa.is>, stable@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com> Subject: [PATCH v3] purgatory: fix disabling debug info Date: Thu, 30 Mar 2023 18:22:24 +0000 Message-Id: <20230330182223.181775-1-hi@alyssa.is> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761821271485130215?= X-GMAIL-MSGID: =?utf-8?q?1761821271485130215?= |
Series |
[v3] purgatory: fix disabling debug info
|
|
Commit Message
Alyssa Ross
March 30, 2023, 6:22 p.m. UTC
Since 32ef9e5054ec, -Wa,-gdwarf-2 is no longer used in KBUILD_AFLAGS. Instead, it includes -g, the appropriate -gdwarf-* flag, and also the -Wa versions of both of those if building with Clang and GNU as. As a result, debug info was being generated for the purgatory objects, even though the intention was that it not be. Fixes: 32ef9e5054ec ("Makefile.debug: re-enable debug info for .S files") Signed-off-by: Alyssa Ross <hi@alyssa.is> Cc: stable@vger.kernel.org Acked-by: Nick Desaulniers <ndesaulniers@google.com> --- v2: https://lore.kernel.org/r/20230326182120.194541-1-hi@alyssa.is Difference from v2: replaced asflags-remove-y with every possible debug flag with asflags-y += -g0, as suggested by Nick Desaulniers. Additionally, I've CCed the x86 maintainers this time, since Masahiro said he would like acks from subsystem maintainers, and get_maintainer.pl didn't pick them the first time around. arch/riscv/purgatory/Makefile | 7 +------ arch/x86/purgatory/Makefile | 3 +-- 2 files changed, 2 insertions(+), 8 deletions(-)
Comments
On Thu, Mar 30, 2023 at 06:22:24PM +0000, Alyssa Ross wrote: > Since 32ef9e5054ec, -Wa,-gdwarf-2 is no longer used in KBUILD_AFLAGS. > Instead, it includes -g, the appropriate -gdwarf-* flag, and also the > -Wa versions of both of those if building with Clang and GNU as. As a > result, debug info was being generated for the purgatory objects, even > though the intention was that it not be. > > Fixes: 32ef9e5054ec ("Makefile.debug: re-enable debug info for .S files") > Signed-off-by: Alyssa Ross <hi@alyssa.is> > Cc: stable@vger.kernel.org > Acked-by: Nick Desaulniers <ndesaulniers@google.com> This is definitely more future proof. Reviewed-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> > --- > v2: https://lore.kernel.org/r/20230326182120.194541-1-hi@alyssa.is > > Difference from v2: replaced asflags-remove-y with every possible > debug flag with asflags-y += -g0, as suggested by Nick Desaulniers. > > Additionally, I've CCed the x86 maintainers this time, since Masahiro > said he would like acks from subsystem maintainers, and > get_maintainer.pl didn't pick them the first time around. > > arch/riscv/purgatory/Makefile | 7 +------ > arch/x86/purgatory/Makefile | 3 +-- > 2 files changed, 2 insertions(+), 8 deletions(-) > > diff --git a/arch/riscv/purgatory/Makefile b/arch/riscv/purgatory/Makefile > index d16bf715a586..9c1e71853ee7 100644 > --- a/arch/riscv/purgatory/Makefile > +++ b/arch/riscv/purgatory/Makefile > @@ -84,12 +84,7 @@ CFLAGS_string.o += $(PURGATORY_CFLAGS) > CFLAGS_REMOVE_ctype.o += $(PURGATORY_CFLAGS_REMOVE) > CFLAGS_ctype.o += $(PURGATORY_CFLAGS) > > -AFLAGS_REMOVE_entry.o += -Wa,-gdwarf-2 > -AFLAGS_REMOVE_memcpy.o += -Wa,-gdwarf-2 > -AFLAGS_REMOVE_memset.o += -Wa,-gdwarf-2 > -AFLAGS_REMOVE_strcmp.o += -Wa,-gdwarf-2 > -AFLAGS_REMOVE_strlen.o += -Wa,-gdwarf-2 > -AFLAGS_REMOVE_strncmp.o += -Wa,-gdwarf-2 > +asflags-y += -g0 > > $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE > $(call if_changed,ld) > diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile > index 17f09dc26381..8e6c81b1c8f7 100644 > --- a/arch/x86/purgatory/Makefile > +++ b/arch/x86/purgatory/Makefile > @@ -69,8 +69,7 @@ CFLAGS_sha256.o += $(PURGATORY_CFLAGS) > CFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE) > CFLAGS_string.o += $(PURGATORY_CFLAGS) > > -AFLAGS_REMOVE_setup-x86_$(BITS).o += -Wa,-gdwarf-2 > -AFLAGS_REMOVE_entry64.o += -Wa,-gdwarf-2 > +asflags-y += -g0 > > $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE > $(call if_changed,ld) > -- > 2.37.1 > >
On Fri, Mar 31, 2023 at 7:29 AM Nathan Chancellor <nathan@kernel.org> wrote: > > On Thu, Mar 30, 2023 at 06:22:24PM +0000, Alyssa Ross wrote: > > Since 32ef9e5054ec, -Wa,-gdwarf-2 is no longer used in KBUILD_AFLAGS. > > Instead, it includes -g, the appropriate -gdwarf-* flag, and also the > > -Wa versions of both of those if building with Clang and GNU as. As a > > result, debug info was being generated for the purgatory objects, even > > though the intention was that it not be. > > > > Fixes: 32ef9e5054ec ("Makefile.debug: re-enable debug info for .S files") > > Signed-off-by: Alyssa Ross <hi@alyssa.is> > > Cc: stable@vger.kernel.org > > Acked-by: Nick Desaulniers <ndesaulniers@google.com> > > This is definitely more future proof. > > Reviewed-by: Nathan Chancellor <nathan@kernel.org> > Tested-by: Nathan Chancellor <nathan@kernel.org> I prefer v3 since it is cleaner, but unfortunately it does not work for Clang+GAS. With v3 applied, I still see the debug info. $ make LLVM=1 LLVM_IAS=0 arch/x86/purgatory/setup-x86_64.o UPD include/config/kernel.release UPD include/generated/utsrelease.h CALL scripts/checksyscalls.sh DESCEND objtool INSTALL libsubcmd_headers AS arch/x86/purgatory/setup-x86_64.o $ readelf -S arch/x86/purgatory/setup-x86_64.o There are 18 section headers, starting at offset 0x14d8: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .text PROGBITS 0000000000000000 00000040 0000000000000027 0000000000000000 AX 0 0 16 [ 2] .rela.text RELA 0000000000000000 000012f8 0000000000000060 0000000000000018 I 15 1 8 [ 3] .data PROGBITS 0000000000000000 00000067 0000000000000000 0000000000000000 WA 0 0 1 [ 4] .bss NOBITS 0000000000000000 00001000 0000000000001000 0000000000000000 WA 0 0 4096 [ 5] .rodata PROGBITS 0000000000000000 00001000 0000000000000020 0000000000000000 A 0 0 16 [ 6] .rela.rodata RELA 0000000000000000 00001358 0000000000000018 0000000000000018 I 15 5 8 [ 7] .debug_line PROGBITS 0000000000000000 00001020 000000000000005f 0000000000000000 0 0 1 [ 8] .rela.debug_line RELA 0000000000000000 00001370 0000000000000018 0000000000000018 I 15 7 8 [ 9] .debug_info PROGBITS 0000000000000000 0000107f 0000000000000027 0000000000000000 0 0 1 [10] .rela.debug_info RELA 0000000000000000 00001388 0000000000000090 0000000000000018 I 15 9 8 [11] .debug_abbrev PROGBITS 0000000000000000 000010a6 0000000000000014 0000000000000000 0 0 1 [12] .debug_aranges PROGBITS 0000000000000000 000010c0 0000000000000030 0000000000000000 0 0 16 [13] .rela.debug_[...] RELA 0000000000000000 00001418 0000000000000030 0000000000000018 I 15 12 8 [14] .debug_str PROGBITS 0000000000000000 000010f0 0000000000000054 0000000000000001 MS 0 0 1 [15] .symtab SYMTAB 0000000000000000 00001148 0000000000000168 0000000000000018 16 12 8 [16] .strtab STRTAB 0000000000000000 000012b0 0000000000000041 0000000000000000 0 0 1 [17] .shstrtab STRTAB 0000000000000000 00001448 000000000000008d 0000000000000000 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), D (mbind), l (large), p (processor specific) With -g0 given, GCC stops passing -g -gdwarf-4 down to GAS. Clang does not do anything about -g0 for the external assembler. I was thinking of dropping LLVM_IAS=0 support. When we decide to give up -fno-integrated-as, we can clean up the code in various places. Anyway, v3 does not work in the current situation. V2 works for all usecases.
On Sat, Apr 01, 2023 at 12:42:13AM +0900, Masahiro Yamada wrote: > On Fri, Mar 31, 2023 at 7:29 AM Nathan Chancellor <nathan@kernel.org> wrote: > > > > On Thu, Mar 30, 2023 at 06:22:24PM +0000, Alyssa Ross wrote: > > > Since 32ef9e5054ec, -Wa,-gdwarf-2 is no longer used in KBUILD_AFLAGS. > > > Instead, it includes -g, the appropriate -gdwarf-* flag, and also the > > > -Wa versions of both of those if building with Clang and GNU as. As a > > > result, debug info was being generated for the purgatory objects, even > > > though the intention was that it not be. > > > > > > Fixes: 32ef9e5054ec ("Makefile.debug: re-enable debug info for .S files") > > > Signed-off-by: Alyssa Ross <hi@alyssa.is> > > > Cc: stable@vger.kernel.org > > > Acked-by: Nick Desaulniers <ndesaulniers@google.com> > > > > This is definitely more future proof. > > > > Reviewed-by: Nathan Chancellor <nathan@kernel.org> > > Tested-by: Nathan Chancellor <nathan@kernel.org> > > > > I prefer v3 since it is cleaner, but unfortunately > it does not work for Clang+GAS. > > > With v3 applied, I still see the debug info. > > > > $ make LLVM=1 LLVM_IAS=0 arch/x86/purgatory/setup-x86_64.o > UPD include/config/kernel.release > UPD include/generated/utsrelease.h > CALL scripts/checksyscalls.sh > DESCEND objtool > INSTALL libsubcmd_headers > AS arch/x86/purgatory/setup-x86_64.o > $ readelf -S arch/x86/purgatory/setup-x86_64.o > There are 18 section headers, starting at offset 0x14d8: > > Section Headers: > [Nr] Name Type Address Offset > Size EntSize Flags Link Info Align > [ 0] NULL 0000000000000000 00000000 > 0000000000000000 0000000000000000 0 0 0 > [ 1] .text PROGBITS 0000000000000000 00000040 > 0000000000000027 0000000000000000 AX 0 0 16 > [ 2] .rela.text RELA 0000000000000000 000012f8 > 0000000000000060 0000000000000018 I 15 1 8 > [ 3] .data PROGBITS 0000000000000000 00000067 > 0000000000000000 0000000000000000 WA 0 0 1 > [ 4] .bss NOBITS 0000000000000000 00001000 > 0000000000001000 0000000000000000 WA 0 0 4096 > [ 5] .rodata PROGBITS 0000000000000000 00001000 > 0000000000000020 0000000000000000 A 0 0 16 > [ 6] .rela.rodata RELA 0000000000000000 00001358 > 0000000000000018 0000000000000018 I 15 5 8 > [ 7] .debug_line PROGBITS 0000000000000000 00001020 > 000000000000005f 0000000000000000 0 0 1 > [ 8] .rela.debug_line RELA 0000000000000000 00001370 > 0000000000000018 0000000000000018 I 15 7 8 > [ 9] .debug_info PROGBITS 0000000000000000 0000107f > 0000000000000027 0000000000000000 0 0 1 > [10] .rela.debug_info RELA 0000000000000000 00001388 > 0000000000000090 0000000000000018 I 15 9 8 > [11] .debug_abbrev PROGBITS 0000000000000000 000010a6 > 0000000000000014 0000000000000000 0 0 1 > [12] .debug_aranges PROGBITS 0000000000000000 000010c0 > 0000000000000030 0000000000000000 0 0 16 > [13] .rela.debug_[...] RELA 0000000000000000 00001418 > 0000000000000030 0000000000000018 I 15 12 8 > [14] .debug_str PROGBITS 0000000000000000 000010f0 > 0000000000000054 0000000000000001 MS 0 0 1 > [15] .symtab SYMTAB 0000000000000000 00001148 > 0000000000000168 0000000000000018 16 12 8 > [16] .strtab STRTAB 0000000000000000 000012b0 > 0000000000000041 0000000000000000 0 0 1 > [17] .shstrtab STRTAB 0000000000000000 00001448 > 000000000000008d 0000000000000000 0 0 1 > Key to Flags: > W (write), A (alloc), X (execute), M (merge), S (strings), I (info), > L (link order), O (extra OS processing required), G (group), T (TLS), > C (compressed), x (unknown), o (OS specific), E (exclude), > D (mbind), l (large), p (processor specific) > > > > > > > With -g0 given, GCC stops passing -g -gdwarf-4 down to GAS. > > > Clang does not do anything about -g0 for the external assembler. You're right. Thank you for your thoughtful testing — I forgot to check LLVM for v3. I thought maybe adding -Wa,-g0 would be enough, but it turns out that GAS doesn't support that. If -g has been specified, there doesn't seem to be any way to disable debug info again later in the command line. So we probably can't do better than v2 while LLVM_IAS=0 is supported. The only other option I see is (untested): asflags-y += -g0 asflags-remove-y += -Wa,-g -Wa,-gdwarf-4 -Wa,-gdwarf-5 But I don't like that option, because it means there are two completely different ways of doing it depending on the compiler setup, and it makes it even less likely anybody would remember to update asflags-remove-y when DWARF 6 comes around or whatever. > I was thinking of dropping LLVM_IAS=0 support. > When we decide to give up -fno-integrated-as, > we can clean up the code in various places. > > > Anyway, v3 does not work in the current situation. > > > V2 works for all usecases. > > > > > -- > Best Regards > Masahiro Yamada
On Sat, Apr 1, 2023 at 5:27 AM Alyssa Ross <hi@alyssa.is> wrote: > > On Sat, Apr 01, 2023 at 12:42:13AM +0900, Masahiro Yamada wrote: > > On Fri, Mar 31, 2023 at 7:29 AM Nathan Chancellor <nathan@kernel.org> wrote: > > > > > > On Thu, Mar 30, 2023 at 06:22:24PM +0000, Alyssa Ross wrote: > > > > Since 32ef9e5054ec, -Wa,-gdwarf-2 is no longer used in KBUILD_AFLAGS. > > > > Instead, it includes -g, the appropriate -gdwarf-* flag, and also the > > > > -Wa versions of both of those if building with Clang and GNU as. As a > > > > result, debug info was being generated for the purgatory objects, even > > > > though the intention was that it not be. > > > > > > > > Fixes: 32ef9e5054ec ("Makefile.debug: re-enable debug info for .S files") > > > > Signed-off-by: Alyssa Ross <hi@alyssa.is> > > > > Cc: stable@vger.kernel.org > > > > Acked-by: Nick Desaulniers <ndesaulniers@google.com> > > > > > > This is definitely more future proof. > > > > > > Reviewed-by: Nathan Chancellor <nathan@kernel.org> > > > Tested-by: Nathan Chancellor <nathan@kernel.org> > > > > > > > > I prefer v3 since it is cleaner, but unfortunately > > it does not work for Clang+GAS. > > > > > > With v3 applied, I still see the debug info. > > > > > > > > $ make LLVM=1 LLVM_IAS=0 arch/x86/purgatory/setup-x86_64.o > > UPD include/config/kernel.release > > UPD include/generated/utsrelease.h > > CALL scripts/checksyscalls.sh > > DESCEND objtool > > INSTALL libsubcmd_headers > > AS arch/x86/purgatory/setup-x86_64.o > > $ readelf -S arch/x86/purgatory/setup-x86_64.o > > There are 18 section headers, starting at offset 0x14d8: > > > > Section Headers: > > [Nr] Name Type Address Offset > > Size EntSize Flags Link Info Align > > [ 0] NULL 0000000000000000 00000000 > > 0000000000000000 0000000000000000 0 0 0 > > [ 1] .text PROGBITS 0000000000000000 00000040 > > 0000000000000027 0000000000000000 AX 0 0 16 > > [ 2] .rela.text RELA 0000000000000000 000012f8 > > 0000000000000060 0000000000000018 I 15 1 8 > > [ 3] .data PROGBITS 0000000000000000 00000067 > > 0000000000000000 0000000000000000 WA 0 0 1 > > [ 4] .bss NOBITS 0000000000000000 00001000 > > 0000000000001000 0000000000000000 WA 0 0 4096 > > [ 5] .rodata PROGBITS 0000000000000000 00001000 > > 0000000000000020 0000000000000000 A 0 0 16 > > [ 6] .rela.rodata RELA 0000000000000000 00001358 > > 0000000000000018 0000000000000018 I 15 5 8 > > [ 7] .debug_line PROGBITS 0000000000000000 00001020 > > 000000000000005f 0000000000000000 0 0 1 > > [ 8] .rela.debug_line RELA 0000000000000000 00001370 > > 0000000000000018 0000000000000018 I 15 7 8 > > [ 9] .debug_info PROGBITS 0000000000000000 0000107f > > 0000000000000027 0000000000000000 0 0 1 > > [10] .rela.debug_info RELA 0000000000000000 00001388 > > 0000000000000090 0000000000000018 I 15 9 8 > > [11] .debug_abbrev PROGBITS 0000000000000000 000010a6 > > 0000000000000014 0000000000000000 0 0 1 > > [12] .debug_aranges PROGBITS 0000000000000000 000010c0 > > 0000000000000030 0000000000000000 0 0 16 > > [13] .rela.debug_[...] RELA 0000000000000000 00001418 > > 0000000000000030 0000000000000018 I 15 12 8 > > [14] .debug_str PROGBITS 0000000000000000 000010f0 > > 0000000000000054 0000000000000001 MS 0 0 1 > > [15] .symtab SYMTAB 0000000000000000 00001148 > > 0000000000000168 0000000000000018 16 12 8 > > [16] .strtab STRTAB 0000000000000000 000012b0 > > 0000000000000041 0000000000000000 0 0 1 > > [17] .shstrtab STRTAB 0000000000000000 00001448 > > 000000000000008d 0000000000000000 0 0 1 > > Key to Flags: > > W (write), A (alloc), X (execute), M (merge), S (strings), I (info), > > L (link order), O (extra OS processing required), G (group), T (TLS), > > C (compressed), x (unknown), o (OS specific), E (exclude), > > D (mbind), l (large), p (processor specific) > > > > > > > > > > > > > > With -g0 given, GCC stops passing -g -gdwarf-4 down to GAS. > > > > > > Clang does not do anything about -g0 for the external assembler. > > You're right. Thank you for your thoughtful testing — I forgot to check > LLVM for v3. I thought maybe adding -Wa,-g0 would be enough, but it > turns out that GAS doesn't support that. If -g has been specified, > there doesn't seem to be any way to disable debug info again later in > the command line. > > So we probably can't do better than v2 while LLVM_IAS=0 is supported. > The only other option I see is (untested): > > asflags-y += -g0 > asflags-remove-y += -Wa,-g -Wa,-gdwarf-4 -Wa,-gdwarf-5 > > But I don't like that option, because it means there are two completely > different ways of doing it depending on the compiler setup, and it makes > it even less likely anybody would remember to update asflags-remove-y > when DWARF 6 comes around or whatever. Agree. This is uglier than v2. If nobody comes up with a better idea, I will pick up v2.
diff --git a/arch/riscv/purgatory/Makefile b/arch/riscv/purgatory/Makefile index d16bf715a586..9c1e71853ee7 100644 --- a/arch/riscv/purgatory/Makefile +++ b/arch/riscv/purgatory/Makefile @@ -84,12 +84,7 @@ CFLAGS_string.o += $(PURGATORY_CFLAGS) CFLAGS_REMOVE_ctype.o += $(PURGATORY_CFLAGS_REMOVE) CFLAGS_ctype.o += $(PURGATORY_CFLAGS) -AFLAGS_REMOVE_entry.o += -Wa,-gdwarf-2 -AFLAGS_REMOVE_memcpy.o += -Wa,-gdwarf-2 -AFLAGS_REMOVE_memset.o += -Wa,-gdwarf-2 -AFLAGS_REMOVE_strcmp.o += -Wa,-gdwarf-2 -AFLAGS_REMOVE_strlen.o += -Wa,-gdwarf-2 -AFLAGS_REMOVE_strncmp.o += -Wa,-gdwarf-2 +asflags-y += -g0 $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE $(call if_changed,ld) diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile index 17f09dc26381..8e6c81b1c8f7 100644 --- a/arch/x86/purgatory/Makefile +++ b/arch/x86/purgatory/Makefile @@ -69,8 +69,7 @@ CFLAGS_sha256.o += $(PURGATORY_CFLAGS) CFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE) CFLAGS_string.o += $(PURGATORY_CFLAGS) -AFLAGS_REMOVE_setup-x86_$(BITS).o += -Wa,-gdwarf-2 -AFLAGS_REMOVE_entry64.o += -Wa,-gdwarf-2 +asflags-y += -g0 $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE $(call if_changed,ld)