Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp87670ybv; Fri, 21 Feb 2020 23:43:20 -0800 (PST) X-Google-Smtp-Source: APXvYqz96iNH3XwhRyp8YEmLAF+VcHXD+yTlg8JAgsC/kL2h2eNX8StDoN8TPomj8o5sFc44kO01 X-Received: by 2002:a9d:4706:: with SMTP id a6mr29528804otf.331.1582357400485; Fri, 21 Feb 2020 23:43:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582357400; cv=none; d=google.com; s=arc-20160816; b=0JwycaICfXzfEGWbzi8p8D1r3tgmauzh/ik4HTaKcT3qkonaUH6SgwpAT5WpB7sKsX DCwk2d2yQbTVz4mKZPM7W72UPsHnOkjq/wGDXB3Fl111KKmlot/Ayzh206K47NIjWse0 aUaYbpE3DWsn4f2VQqrQrMXgIcmfrZk7wRhJdxaq+rnjtmy2V4cHZmVvCTeo3STrsP/6 6q5RKWRq3klHrrhlzcmzddvKwmbyGcRQLbry0bBf521J5vwFAZnnf/+1A8gALvuGIMpa NQnbFnw7xrwRP3oxgM4YO2EQu4al6cuvuC8W7w7TZeQTcuWVfV/lEcDCFvPAW4EpOMxD fcEA== 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:from:date:dkim-signature; bh=zQq+GG1QYp01vrYlwItFyogojmSp6nseyu5/GmAeVxU=; b=e7u0WHN1FGw7DUPzaMbNa70Un1e6ApfR3jkUq1lfKb44IpRK9hW8KkaQpvwUBt+ceT PdVT9koV96EFSyP9U5vU93N45DYdqP9Ump4qBTQTzViiw8vA2u1+SGadZaYRKa10F+wg kBNAKFNqYaxFJYowY46uMwRGxxq8gdppLmiWl//k3mwvklJlt0989WDC0WzMo9OIzfQk Jdmp4reaehUysefW39kBnOQdZEZbRKoTz1XPz7WU5ncHJg/WNNOGQGwvk3g4dZkcoR+n 0291DXVZwND7Jey+wRVCizr3XiCy5OnlCthCEe3iyH3MKPWJ64GhY/tF9Qqjxu3aHop3 qdOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UPealTR+; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m24si3153692otn.67.2020.02.21.23.43.07; Fri, 21 Feb 2020 23:43:20 -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=@gmail.com header.s=20161025 header.b=UPealTR+; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726763AbgBVHmp (ORCPT + 99 others); Sat, 22 Feb 2020 02:42:45 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:46896 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726294AbgBVHmp (ORCPT ); Sat, 22 Feb 2020 02:42:45 -0500 Received: by mail-ot1-f65.google.com with SMTP id g64so4194405otb.13 for ; Fri, 21 Feb 2020 23:42:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=zQq+GG1QYp01vrYlwItFyogojmSp6nseyu5/GmAeVxU=; b=UPealTR+A1lWpBpjmEQT0UuvCt8sqThRPvX+mm+73OH1c3o1zkatglYw3zFh5GHzWQ KeyZ/iVPz0P4AC4jMeje3ewgwq1y3yFVyNWKpUQzk8U3A0+Jt3W1jFZ5Ut2nBVdc0Bpq EHmfDM9fTHWhvmCrdmwfzh61LIhj4zz0M2BQAovBxAEOE8kcLB5mfRKeLw5AIqRYEsva VcNY0OTh/8RdKt4j3oobva5VVPQ6Shgzt79PEowAmezjXgd1ZIqE3OoYdVfk2Pa3tSzi L6i4lLb7tVwNHh+0R8SWoftWm07xFQB475yLXWwfgqOyL/sYNlAGdfX4vhUDWuazIbRy /GWg== 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:user-agent; bh=zQq+GG1QYp01vrYlwItFyogojmSp6nseyu5/GmAeVxU=; b=guyHCj+lqvGb0psh8UC4ifEFMwBQjNm/ZRF8+y9/mLB/699nX+FLqy3WdlurVRIuAW QARGGhpwLvCQsjSQf69vSUBZfI4cajnH6295YBiuXjQjPZNo2DxCSJ3Wymw54wRGbbaK B45g5VhqKkv69Z4+Qi3479iTJRR+QBWfjnzZ4bz3BPALnNK8ux52eQ6huqIjoj3Gp41M JDva4CKkBK6Pauv3Oqh+bBFoPeWWGSfC1vnx2AqGpWbIm2nlC4rsorKR4mTkoK03BlNS jf7fk8iPp6whhkk19xkIF8gJ9viDBNHADRcZxw5/JG21fR1zn28l1/ES+QjCeBAdDhLY 0S1Q== X-Gm-Message-State: APjAAAVKaP42pCp0lbG9OTcXjj17HO2DsdcQYfhk/wRUs/N2KXQKbluM v52i4/p1mYPBnCQdlirRPew= X-Received: by 2002:a05:6830:1296:: with SMTP id z22mr30687060otp.354.1582357364220; Fri, 21 Feb 2020 23:42:44 -0800 (PST) Received: from ubuntu-m2-xlarge-x86 ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id g5sm1972708otp.10.2020.02.21.23.42.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Feb 2020 23:42:43 -0800 (PST) Date: Sat, 22 Feb 2020 00:42:42 -0700 From: Nathan Chancellor To: Fangrui Song Cc: Arvind Sankar , 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: <20200222074242.GA17358@ubuntu-m2-xlarge-x86> 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> <20200222072144.asqaxlv364s6ezbv@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200222072144.asqaxlv364s6ezbv@google.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 21, 2020 at 11:21:44PM -0800, Fangrui Song wrote: > 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/ : { *(*) } > } Thanks for the clarity. With your suggestion (diff below), I see the following error: arch/x86/boot/compressed/vmlinux: no symbols ld.lld: error: undefined symbol: ZO_input_data >>> referenced by arch/x86/boot/header.o:(.header+0x59) ld.lld: error: undefined symbol: ZO_z_input_len >>> referenced by arch/x86/boot/header.o:(.header+0x5D) make[3]: *** [../arch/x86/boot/Makefile:108: arch/x86/boot/setup.elf] It seems like the section still isn't being added? Cheers, Nathan diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S index 12a20603d92e..a6c3c7440c27 100644 --- a/arch/x86/boot/compressed/vmlinux.lds.S +++ b/arch/x86/boot/compressed/vmlinux.lds.S @@ -74,6 +74,10 @@ SECTIONS . = ALIGN(PAGE_SIZE); /* keep ZO size page aligned */ _end = .; + .shstrtab : { + *(.shstrtab) + } + /* Discard all remaining sections */ /DISCARD/ : { *(*)