Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2446857ybv; Mon, 24 Feb 2020 05:29:17 -0800 (PST) X-Google-Smtp-Source: APXvYqy17qb6l2ognL4dO+e+ay2IucUwDcl4c2sLIqEIuxBsI1qfi8f4htta6YarvOyoeeU/zUuW X-Received: by 2002:a05:6830:1219:: with SMTP id r25mr16080660otp.180.1582550957099; Mon, 24 Feb 2020 05:29:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582550957; cv=none; d=google.com; s=arc-20160816; b=llhfcogdB0CmzcfDMvXo2uhRbZSWSGqZkaQRHwD8xwWoKP9fUVUcoK0YzkJJ3Cjrwu gRRF+LM4smLL7/y47XC9cZvErX2fCv/3HjwXc2ZL7MNUCgSzcKF9AnvX8n8LvApJ//GT BeW1VGBbqzgyGz8/MpTWoCYAzBgZUlQH4rpVkq5RJZZ2Neb95dDyD9XoaDeqJ2famHMt gFMGnV6SVV8r5rQzVxwb8K/MS/TWo5lvC3QWi6xiW341C6HwhTXJs/eYFIA9uSPLAZf2 4FLxNE4oTIu34xgQmo+ZKmY+eVNrSp+yqSlyL3ofrbYVWQB0yZ27JGEL8BcJx1fZRN2P y1sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=dd7SuRdZJyeTO3NdOLqvByk5vzqCmaPx6KxBGqi0tMo=; b=HfaiwdScxKz0nbX+VWxAiXspBeBEES2YE5YCUeyJtmP5NqduN31bgpjkK3HHZoy1xa BEDZoGeZMMK0+ATskKIt6DPXe/GZCITIma1Vgz1PfilG11Br2ogbOkTTfrEnFi8nkou4 i6hVcYoaeVK52C/JAb8Q86fLs+fFuns6TxZNkMx3XtcS2fKp+fJXomLaSeMDs9dFNgDM ow2Ss6OOjcxSNm1427c6OPAPFTfptQxrw4+RzbL31V4RhkwTmD74ARgJCfLCc44RgxXJ ZmubFwhOvhbrVGTF1rt9/b3sShYq1Nq9n3hIWT6CQ+4Y07DBGMNl8ivGNrGFs+tTnu3Y 1GzA== ARC-Authentication-Results: i=1; mx.google.com; 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 j2si6430488otk.164.2020.02.24.05.29.05; Mon, 24 Feb 2020 05:29:17 -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; 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 S1727474AbgBXN2l (ORCPT + 99 others); Mon, 24 Feb 2020 08:28:41 -0500 Received: from mx2.suse.de ([195.135.220.15]:38216 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbgBXN2l (ORCPT ); Mon, 24 Feb 2020 08:28:41 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A9C1BAB6D; Mon, 24 Feb 2020 13:28:38 +0000 (UTC) Date: Mon, 24 Feb 2020 13:28:36 +0000 (UTC) From: Michael Matz To: Nick Desaulniers cc: Arvind Sankar , Fangrui Song , Borislav Petkov , Nathan Chancellor , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , LKML , clang-built-linux , Kees Cook Subject: Re: [PATCH 2/2] x86/boot/compressed: Remove unnecessary sections from bzImage In-Reply-To: Message-ID: 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> <20200222074254.GB11284@zn.tnic> <20200222162225.GA3326744@rani.riverdale.lan> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Sat, 22 Feb 2020, Nick Desaulniers wrote: > > > > 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. > > > > > > Ok, forget what the tools do for a second: why is .shstrtab special and > > > why would one want to keep it? > > > > > > Because one still wants to know what the section names of an object are > > > or other tools need it or why? > > > > > > Thx. > > > > > > -- > > > Regards/Gruss, > > > Boris. > > > > > > https://people.kernel.org/tglx/notes-about-netiquette > > > > .shstrtab is required by the ELF specification. The e_shstrndx field in > > the ELF header is the index of .shstrtab, and each section in the > > section table is required to have an sh_name that points into the > > .shstrtab. > > Yeah, I can see it both ways. That `*` doesn't glob all remaining > sections is surprising to me, but bfd seems to be "extra helpful" in > not discarding sections that are required via ELF spec. In a way the /DISCARD/ assignment should be thought of as applying to _input_ sections (as all such section references on the RHS), not necessarily to output sections. What this then means for sections that are synthesized by the link editor is less clear. Some of them are generated regardless (as you noted, e.g. the symbol table and associated string sections, including section name string table), some of them are suppressed, and either lead to an followup error (e.g. with .gnu.hash), or to invalid output (e.g. missing .dynsym for executables simply lead to segfaults when running them). That's the reason for the perceived inconsistency with behaviour on '*': it's application to synthesized sections. Arguably bfd should be fixed to also not discard the other essential sections (or alternatively to give an error when an essential section is discarded). The lld behaviour of e.g. discarding .shstrtab (or other synthesized sections necessary for valid ELF output) doesn't make much sense either, though. Ciao, Michael.