Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp683555ybv; Sat, 22 Feb 2020 12:18:56 -0800 (PST) X-Google-Smtp-Source: APXvYqwEy1N7/kUv7AIH+Y7/pnQJzYfr6OaV7tAoilUGMOCyj0/FboQbYXlyyqnwvqEV1shkuZeu X-Received: by 2002:aca:c401:: with SMTP id u1mr7286680oif.62.1582402736396; Sat, 22 Feb 2020 12:18:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582402736; cv=none; d=google.com; s=arc-20160816; b=YLYo8XlkRHpygcWICiHRUjwLbQmphVfOqwA1Mc/YBv96VBi0PpHJRntWZsSs9Bjz+X d7onGn2wOBx3lDCf457bGXJJNwuULMaPNhkMAK4kUHU4B7eY72GOhKGGEGJYnWMzueW0 epuZdW1iSLjb/Nc8po0lifCB0WM9B6n5NE77l2rDLd2P+1DlAnfJZDORSDBsoMrO8/Q9 kF6D7R96C9TKWlIGpMLTb5qeI4jh/PpZLejvERf3NA9sKLisynz2UyGwHRNqz0kEHBkl 6J8wOpz4xzEeuH19WXHtZ20xxBu9Q8IWTdn2b87jgJwFXFUZGgDCEKp0rQQskWmxrHBr 8v5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=b/ySdKTZFlFCT4Win5U1jB4XU2Vrkoz7ZLdDWOfcGHA=; b=gOLa7RHKCHKE6kooEXGUKCdNJg+9G5AKIm2uyC6dFGEQ4s4pPxSGNj08IwPbUES99r GMgA+sw5gO0EVV5U12pEdl4wJ2U3Vtq3QlW0DjTAlru5zvBSg01AUzWQzAA42o8zEdW1 eWK66mo39UUmN9+n2/3NkkFDZCwCmYzK54FgaJPhKR24WqR8+rLRtfWUXHW/Yyx2B8FK kojuw2nA2I07SsuikU1w62Ixf1GXT8Nkm53zv+gKGltNVGiC6vpBZnBj3bisVx0kQukx WVDn07cXQmXEYIjhKjdHgio2AKhTUQGs8qRtwyHnMstVtH9e0ylCnRXv9wrtUg8EKIVH rAaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=F53zer16; 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 g6si3664696otk.171.2020.02.22.12.18.44; Sat, 22 Feb 2020 12:18:56 -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=fail header.i=@gmail.com header.s=20161025 header.b=F53zer16; 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 S1726875AbgBVURT (ORCPT + 99 others); Sat, 22 Feb 2020 15:17:19 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:33518 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726730AbgBVURT (ORCPT ); Sat, 22 Feb 2020 15:17:19 -0500 Received: by mail-qk1-f196.google.com with SMTP id h4so5299254qkm.0 for ; Sat, 22 Feb 2020 12:17:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=b/ySdKTZFlFCT4Win5U1jB4XU2Vrkoz7ZLdDWOfcGHA=; b=F53zer16nQMz28VvlSk6jANwD4MQI/lAVH31QS062jUTSPs5LhKMEHsMhmQ28aLSca 7Dot+DR3XCREZlRBZaFqog/U8E0J1bB8jNwjElz3xNzHssOYXREDXWY2ARaYDifJ7J1j U6ebjFjikomqd4X+SafP0OOkihJE7eYal/XAgmqZ+GUn5OYsACW/FVytvAiV2wkB+oln GvlJAQ+t/al8gQ8+02RrTRalz2rkMSBM+coCpwwHtpN3VpRLcxMnZ/APKhPLPxeGVrUh wKL2QEVRdq33RexuXFgD3d7y6HZQl+op4ugK3685RuRu3SAGoh7vviSEEJURHHJuUpWv rdXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=b/ySdKTZFlFCT4Win5U1jB4XU2Vrkoz7ZLdDWOfcGHA=; b=jCG5a4raH6UUA/91kxSOFiwsR0MIiH+a/BsLy4HG2F3cSP8O4wK6fl0ekXpxW7EQPi PMzw0ZI7nO85gOGa2IfBT49O1d5PvdgPWHcnHPGFuBppQrMzjV5JDp2RpxyX4mvMQUz9 G0r97zrJBCHQzaK23uqfqQQI46DzDXp1r9imrfpLooA3OKCDY7b3JJoC4Fjj0vUoQuxq /IWtGTU/rgHqLaHL9hALYodf2+srnOKUj9TUAkXhXZQ+qcCTM3Ofz4hOh8GnDJiiNXN5 Vsnkl6QbZLAgCyYiox9PnT/JteMcOKweXRLHLgoj3/Kc2ZD5rhGw2JmL7OgIs3yc4zhA 4wKw== X-Gm-Message-State: APjAAAUkQTLdIhziOaPNFTibgGrL0gsriSqTndspFFxm0NMTKsX2MGIJ mFddQs+PZsoI0Gw00/+nweAzFTZMMoZEgQ== X-Received: by 2002:ae9:dcc1:: with SMTP id q184mr39777273qkf.480.1582402638244; Sat, 22 Feb 2020 12:17:18 -0800 (PST) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id w60sm3543568qte.39.2020.02.22.12.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Feb 2020 12:17:17 -0800 (PST) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Sat, 22 Feb 2020 15:17:16 -0500 To: Fangrui Song Cc: Arvind Sankar , Borislav Petkov , Nathan Chancellor , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Michael Matz Subject: Re: [PATCH] x86/boot/compressed: Fix compressed kernel linking with lld Message-ID: <20200222201715.GA3674682@rani.riverdale.lan> References: <20200222164419.GB3326744@rani.riverdale.lan> <20200222171859.3594058-1-nivedita@alum.mit.edu> <20200222181413.GA22627@ubuntu-m2-xlarge-x86> <20200222185806.ywnqhfqmy67akfsa@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200222185806.ywnqhfqmy67akfsa@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 22, 2020 at 10:58:06AM -0800, Fangrui Song wrote: > On 2020-02-22, Nathan Chancellor wrote: > >On Sat, Feb 22, 2020 at 12:18:59PM -0500, Arvind Sankar wrote: > >> Commit TBD ("x86/boot/compressed: Remove unnecessary sections from > >> bzImage") discarded unnecessary sections with *(*). While this works > >> fine with the bfd linker, lld tries to also discard essential sections > >> like .shstrtab, .symtab and .strtab, which results in the link failing > >> since .shstrtab is required by the ELF specification. .symtab and > >> .strtab are also necessary to generate the zoffset.h file for the > >> bzImage header. > >> > >> Since the only sizeable section that can be discarded is .eh_frame, > >> restrict the discard to only .eh_frame to be safe. > >> > >> Signed-off-by: Arvind Sankar > >> --- > >> Sending as a fix on top of tip/x86/boot. > >> > >> arch/x86/boot/compressed/vmlinux.lds.S | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S > >> index 12a20603d92e..469dcf800a2c 100644 > >> --- a/arch/x86/boot/compressed/vmlinux.lds.S > >> +++ b/arch/x86/boot/compressed/vmlinux.lds.S > >> @@ -74,8 +74,8 @@ SECTIONS > >> . = ALIGN(PAGE_SIZE); /* keep ZO size page aligned */ > >> _end = .; > >> > >> - /* Discard all remaining sections */ > >> + /* Discard .eh_frame to save some space */ > >> /DISCARD/ : { > >> - *(*) > >> + *(.eh_frame) > >> } > >> } > >> -- > >> 2.24.1 > >> > > > >FWIW: > > > >Tested-by: Nathan Chancellor > > I am puzzled. Doesn't -fno-asynchronous-unwind-tables suppress > .eh_frame in the object files? Why are there still .eh_frame? > > Though, there is prior art: arch/s390/boot/compressed/vmlinux.lds.S also discards .eh_frame The compressed kernel doesn't use the regular flags and it seems it doesn't have that option. Maybe we should add it in to avoid generating those in the first place. The .eh_frame discard in arch/x86/kernel/vmlinux.lds.S does seem superfluous though.