Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp72759ybv; Fri, 21 Feb 2020 23:22:45 -0800 (PST) X-Google-Smtp-Source: APXvYqxlIQ2GREhIL62YtjGGvcDkSdlA9hzdbTcjaX74zXldsR2j26iIrV9aSrH8uPbiLEcnGq6H X-Received: by 2002:a05:6808:30d:: with SMTP id i13mr5031086oie.144.1582356165219; Fri, 21 Feb 2020 23:22:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582356165; cv=none; d=google.com; s=arc-20160816; b=TAhRmjddeKp2BFrR4J45nrOD25f+eJo8/seYWP/keXEDeHRYy4U1niiENrUhw6Iqju B2iDgwnR581fX8gI/EdcTwGrjieR6UnKPBUN9hr8FiM44C2vaqT5ryikw+pSUQJrgayC 3Wkdu6s01QXbAddX2utOsl+rBrbbXkxI0JizIHit5xcmScgD33yAFv4qAnEpfBCr4r0o /PiO2O1Xjl8/Oajr02e+PgpSWgSSUhJV4ynlkJqCdQE3Kbfgvgz4CO+gmtEK5E8+fDFk 49CY55o6T7YlZet9Y9471hYAHnFo3ogvZZ0wQMikgKzx7T34u0y+jpg/3irp7DkdrbI5 oiMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=bv75KEUd02gxsaskLabjo9rQm7ohDzez9MAAHQVvNPs=; b=uatmse7xNJJBM4rtlMBMPklwsqS1Wv2tp5QYQOqSbgIArTIDd8amYziiMVT6lJxheV 9knFQYG4arj5cPVidMw6vO0GDQIB2D1WnM2TCqJ0dtoacfaQcZaL8tna94IkvIlqk8mm fyv/L4y5FwOCAEBC40pkNxKONQS874aosX/Jp4UDUFEwNyEBeEKEOaXVILoXyMnG4cZa 2HShTesRMqwEkGIMEI40Xk0Mq9xeZ/LbJS2lSw6qnOlD3fnTNtXcLSwuv0gV3bImvbro Qc9W1CsUyIquxGEa8pDO+P4+E4jdImKtOMt2fGGpmW87N0p59a5Z12yQXidWVdz6QI4C /h9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nIIzMWrQ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13si2692432otc.228.2020.02.21.23.22.31; Fri, 21 Feb 2020 23:22:45 -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=@google.com header.s=20161025 header.b=nIIzMWrQ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727134AbgBVHVt (ORCPT + 99 others); Sat, 22 Feb 2020 02:21:49 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:45340 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726943AbgBVHVs (ORCPT ); Sat, 22 Feb 2020 02:21:48 -0500 Received: by mail-pg1-f193.google.com with SMTP id b9so2137064pgk.12 for ; Fri, 21 Feb 2020 23:21:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=bv75KEUd02gxsaskLabjo9rQm7ohDzez9MAAHQVvNPs=; b=nIIzMWrQ61vFJCdvVuu1EpE3KLUcD56k/uHQiNswwZveACfL6p0dGFnY/z2GPmi/II 4Zy7NrmsPWBiOE0tHx5jI9Ngt6UmHyU9ssMtIueOUEQYydYZ3EVjPzuJ+A3Gp6eN1Qle rZjrZufPr4kmfFcSUpiIVxukT/AItZehjG3ozd+vaV5zeMEfUp9BhqtPFgA6l6UbtxE9 gUv9aZmqzqAa7v3T2RRqrjcmj/d2Q0/kg6h1RrAs5zf+hWnlpkMavbVyb2S+B3deVJf1 X1dxOp5e03jeZ2EU72DrkIXuOpVmLOI4pS/7b5w+yguBuRkBgpdxHPwJsOdMde4s9Jo2 dikA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bv75KEUd02gxsaskLabjo9rQm7ohDzez9MAAHQVvNPs=; b=h6LdJq69jV+udJHem37XTk5OAOjQrI50R7fhYUf40upCug6Fe9sFsVaAecWL1RFaKf D6YYUHXHDXBeByElUlv7GBrT99J+t+iX1JRVH4diTFKOnE1KcGXcPg5DuN5EV8LRHuG6 +nfC+t69LIni8E8NnrSnxgB2JJi32nOxfRtwwTRaJdBScM5c2qYmeQ3DgrxrlswQA9cq lAy3dY4YcPc4tMuoHKxcVT0jZgD/1Y+pVv/jUqlxlM9lZ/iSnyR0oDNFfNQ7TYV2UCp1 gBxAUQatYbQ5TDIW2CuwEzdRkoEWgOTkVcjMvgUh1INSiY0KroSjfylFT0UrRJZz8w4n D5Wg== X-Gm-Message-State: APjAAAXK3WTACm2y10jH/TX2EIml9UdCS0DqwRgtvHfzqT7B1CKwswVL JMS3sDnprYnHqRTAa8+hf7JVNw== X-Received: by 2002:a05:6a00:2c1:: with SMTP id b1mr42205921pft.80.1582356107845; Fri, 21 Feb 2020 23:21:47 -0800 (PST) Received: from google.com ([2620:15c:2ce:0:9efe:9f1:9267:2b27]) by smtp.gmail.com with ESMTPSA id n2sm5024772pfq.50.2020.02.21.23.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2020 23:21:47 -0800 (PST) Date: Fri, 21 Feb 2020 23:21:44 -0800 From: Fangrui Song To: Nathan Chancellor , Arvind Sankar Cc: Borislav Petkov , 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 2/2] x86/boot/compressed: Remove unnecessary sections from bzImage Message-ID: <20200222072144.asqaxlv364s6ezbv@google.com> References: <20200109150218.16544-1-nivedita@alum.mit.edu> <20200109150218.16544-2-nivedita@alum.mit.edu> <20200222050845.GA19912@ubuntu-m2-xlarge-x86> <20200222065521.GA11284@zn.tnic> <20200222070218.GA27571@ubuntu-m2-xlarge-x86> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200222070218.GA27571@ubuntu-m2-xlarge-x86> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-02-22, Nathan Chancellor wrote: >On Sat, Feb 22, 2020 at 07:55:21AM +0100, Borislav Petkov wrote: >> On Fri, Feb 21, 2020 at 10:08:45PM -0700, Nathan Chancellor wrote: >> > On Thu, Jan 09, 2020 at 10:02:18AM -0500, Arvind Sankar wrote: >> > > Discarding the sections that are unused in the compressed kernel saves >> > > about 10 KiB on 32-bit and 6 KiB on 64-bit, mostly from .eh_frame. >> > > >> > > Signed-off-by: Arvind Sankar >> > > --- >> > > arch/x86/boot/compressed/vmlinux.lds.S | 5 +++++ >> > > 1 file changed, 5 insertions(+) >> > > >> > > diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S >> > > index 508cfa6828c5..12a20603d92e 100644 >> > > --- a/arch/x86/boot/compressed/vmlinux.lds.S >> > > +++ b/arch/x86/boot/compressed/vmlinux.lds.S >> > > @@ -73,4 +73,9 @@ SECTIONS >> > > #endif >> > > . = ALIGN(PAGE_SIZE); /* keep ZO size page aligned */ >> > > _end = .; >> > > + >> > > + /* Discard all remaining sections */ >> > > + /DISCARD/ : { >> > > + *(*) >> > > + } >> > > } >> > > -- >> > > 2.24.1 >> > > >> > >> > This patch breaks linking with ld.lld: >> > >> > $ make -j$(nproc) -s CC=clang LD=ld.lld O=out.x86_64 distclean defconfig bzImage >> > ld.lld: error: discarding .shstrtab section is not allowed >> >> Well, why is it not allowed? And why isn't the GNU linker complaining? > >No idea, unfortunately I am not a linker expert and the patch that >changes this in lld does not really explain why it adds this >restriction: > >https://github.com/llvm/llvm-project/commit/1e799942b37d04f30b73f6a9e792d551dadafeea > >CC'ing Fangrui as I don't know George's email and he is usually >responsive to ld.lld issues/questions. > >Cheers, >Nathan In GNU ld, it seems that .shstrtab .symtab and .strtab are special cased. Neither the input section description *(.shstrtab) nor *(*) discards .shstrtab . I feel that this is a weird case (probably even a bug) that lld should not implement. In GNU ld, the following is not useful, while lld will discard the synthesized .strtab as requested: /DISCARD/ : { *(.strtab) } I think it is better making the intention (retaining .shstrtab) explicit, by adding a .shstrtab beside /DISCARD/ : SECTIONS { ... .shstrtab : { *(.shstrtab) } /DISCARD/ : { *(*) } }