Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1778974pxa; Sun, 2 Aug 2020 21:14:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkOyxCf3dBBzraty3tSl7B3npCENXk8E9zF2Vb/rj4HDt5TToAFVq9Q5iWLIMDWNt+cMTu X-Received: by 2002:a17:906:1911:: with SMTP id a17mr14035805eje.431.1596428094463; Sun, 02 Aug 2020 21:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596428094; cv=none; d=google.com; s=arc-20160816; b=TBAzC6p+0RY/na6ohOCxjSqlasgLCBX7VZuxofKrUgQmDEDQpAN9ZAKzv05oL818+r nZ522M1rzxJfplyT0pWQIbMMUlLujs+M+j9Mzrlp6iZOQ2noDPdisyTrBUaPnn4xU3rF 4B6acdiLYELaMYEtcjZstnOTzLNj3bvC/a5dNa9XK95uzx2c80uzjLi3FKnzpA+udzmu /p0uqBVVj7bwQk5cSbvMNTlQM1SDfNQKoWsSlu7ec2Z03h41RNTSgQQTuQbjD/Xehleu 4yzvnBday2+NYwOc500lP8OwV//gcMfnXGFqmjD4Go3sR8K15+FUeMxTnW9/M7aZ84tL wC7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=OKUq/09yys4sflqmrLiIWtDtY45NuaZPyhKbOjzDqNQ=; b=OMl/lnOQrC7yWJ/6SM7Qvsh7dDUBc4eFSdigVfD1O/1dCqtkShlfpjK27KrEycwwKu LfHylbvhFgDidH5z/d3LO6WG812le9AD/jsuhF8bmgZFQ0MQ0H2XeHzSDHHa1DVZoWYu 4Inh0UDyoCpKNobj43AIYamJXiTW/0tNBC1T+LTphE/DrzlrT1xXCgksosScU8L4xXwb zQpLavtHgV7OzO3sslKUwf6scsS2X2xSMFz5vTXnijzspeOjYfkyK14zIYfc8+jfO30p YsXTu5mKHWxdRMqv3GmCbjcyiM0MlGNM3ST59RagczE+8GdYJ5GC+1bE9blwFxwzsAXy 398w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DefaKfGI; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v24si10476436edl.35.2020.08.02.21.14.31; Sun, 02 Aug 2020 21:14:54 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=DefaKfGI; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725926AbgHCENY (ORCPT + 99 others); Mon, 3 Aug 2020 00:13:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbgHCENY (ORCPT ); Mon, 3 Aug 2020 00:13:24 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFD8BC06174A for ; Sun, 2 Aug 2020 21:13:23 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id v6so21974363iow.11 for ; Sun, 02 Aug 2020 21:13:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OKUq/09yys4sflqmrLiIWtDtY45NuaZPyhKbOjzDqNQ=; b=DefaKfGI1MDSo2amOyXhNeK+74EnbqXJroVxkuLakvpi7bDIfG9uwfA6pJraRu/cxl QYI7qZyCzzsKIycfiTLSbmngKLLuUZ34cPtvhCiJ6gIwv1xBYXpNQx7uvFfQ0kJw732a l2q5UALhHB7iJI+mtunTomwrr1eA7vtODEui/zV1wsNOePlzwtDh0CMMqW8Vkdw801aO +W+iNFkQA4MukuBi7WY/+/NRE9PG/A1uwxxoYK4RkzgSfS/iW76/ntTRwrHvrqHaJ4aM iYrGyXEUU3yug+G9qP2rhGbru8+QgxZC0Qy3B2dOKJNjGHd019orAlVYEpEZWJ7wJURI jvPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OKUq/09yys4sflqmrLiIWtDtY45NuaZPyhKbOjzDqNQ=; b=BUhmVMRPqutR3typwzodzwEIGuk0UlAlkOa2w1ZhsLcpxMmPO7DV3dZpW2xXUATunc vuEgdd80eOD03SvpCLVmV5tosC5ZgFnib8rM0YLZ44/NU16lqfezLwJRDujOAsmkFvSz oKXJASxutDgmOn0DZ1/Y5U+J5sa0lNrJ3Jw/NDlq2KAEPBb/w4JyTEQ++aLgGy8jNiLK CL5aBHaUQP422ZEPi8DAWmJvfun7ICa7S5gVAz9VFiM9b1EeSqrjI8Rdjdka0auFhok0 Vfq4vMAk8jOf46/7Yvmnq4+vU8GX/msr+wpEbSCTHSWdNKZKA7Vn4/u0L/c1Itmn6OrM O/JQ== X-Gm-Message-State: AOAM532WWUjNKNU/0M62IptG6vOpKesGVKFzGzIheUmJvP4IuGEzK/34 vn85ZSaDY+tDzCbVdTm4/bmSFbsXLYLonrfJgA== X-Received: by 2002:a05:6602:2246:: with SMTP id o6mr10117511ioo.35.1596428003100; Sun, 02 Aug 2020 21:13:23 -0700 (PDT) MIME-Version: 1.0 References: <1596097609-14118-1-git-send-email-kernelfans@gmail.com> In-Reply-To: From: Pingfan Liu Date: Mon, 3 Aug 2020 12:13:11 +0800 Message-ID: Subject: Re: [PATCH] x86/purgatory: strip debug info To: Nick Desaulniers Cc: Steve Wahl , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Hans de Goede , Arvind Sankar , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 1, 2020 at 2:18 AM Nick Desaulniers wrote: > > On Fri, Jul 31, 2020 at 2:36 AM Pingfan Liu wrote: > > > > On Fri, Jul 31, 2020 at 7:11 AM Nick Desaulniers > > wrote: > > > > > > On Thu, Jul 30, 2020 at 1:27 AM Pingfan Liu wrote: > > > > > > > > It is useless to keep debug info in purgatory. And discarding them saves > > > > about 200K space. > > > > > > > > Original: > > > > 259080 kexec-purgatory.o > > > > Stripped: > > > > 29152 kexec-purgatory.o > > > > > > > > Signed-off-by: Pingfan Liu > > > > Cc: Thomas Gleixner > > > > Cc: Ingo Molnar > > > > Cc: Borislav Petkov > > > > Cc: "H. Peter Anvin" > > > > Cc: Hans de Goede > > > > Cc: Nick Desaulniers > > > > Cc: Arvind Sankar > > > > Cc: Steve Wahl > > > > Cc: linux-kernel@vger.kernel.org > > > > To: x86@kernel.org > > > > > > I don't see any code in > > > arch/x86/purgatory/ > > > arch/x86/include/asm/purgatory.h > > > include/linux/purgatory.h > > > include/uapi/linux/kexec.h > > > kernel/kexec* > > > include/linux/kexec.h > > > include/linux/crash_dump.h > > > kernel/crash_dump.c > > > arch/x86/kernel/crash* > > > https://github.com/horms/kexec-tools/tree/master/kexec/arch/x86_64 > > > that mentions any kind of debug info section. I'm not sure what you'd > > > do with the debug info anyway for this binary. So I suspect this > > > information should ok to discard. > > > > > > This works, but it might be faster to build to not generate the > > > compile info in the first place via compile flag `-g0`, which could be > > > added `ifdef CONFIG_DEBUG_INFO` or even just unconditionally. That > > > way we're not doing additional work to generate debug info, then > > > additional work to throw it away. > > What about: > > diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile > > index 088bd76..7e1ad9e 100644 > > --- a/arch/x86/purgatory/Makefile > > +++ b/arch/x86/purgatory/Makefile > > @@ -32,7 +32,7 @@ KCOV_INSTRUMENT := n > > # make up the standalone purgatory.ro > > > > PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel > > -PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss > > +PURGATORY_CFLAGS := -mcmodel=large -ffreestanding > > -fno-zero-initialized-in-bss -g0 > > PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING > > PURGATORY_CFLAGS += $(call cc-option,-fno-stack-protector) > > I tested your patch but still see .debug_* sections in the .ro from a few .o. > > At least on > * setup-x86_64.o > * entry64.o > > If you add the following hunk to your diff: > ``` > @@ -64,6 +64,9 @@ 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 > + Go through man as and gcc, and can not find a simpler method than your suggestion. > $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE > $(call if_changed,ld) > ``` > then that should do it. Then you can verify the .ro file via: > $ llvm-readelf -S arch/x86/purgatory/purgatory.ro | not grep debug_ > (no output, should return zero) Thank you for your good suggestion and I will update V2 Regards, Pingfan