Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2939811ybv; Mon, 24 Feb 2020 14:52:44 -0800 (PST) X-Google-Smtp-Source: APXvYqwm+0FZT/SvjNsZEjtLM9h8IFD65W2PbDt3pH2TPZxDOkBcpR5bAygVTQpn03p7U80S8ofj X-Received: by 2002:aca:37c3:: with SMTP id e186mr1123537oia.155.1582584764685; Mon, 24 Feb 2020 14:52:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582584764; cv=none; d=google.com; s=arc-20160816; b=LnT0vE8ocFBko9HDzhPLdsZvftCjLxD+4fypH9NyjrFXlL3YDeYlLoiiV0HsRTLiOE eev7q18DJCv2MnKjQXr1q4chra3bMDyh5lluOf6HfUtQetz5BMZKWC6vnMypMw/sLHE1 5P2YDR8kw8q7U2Eh0gBhbVQSW8vkfwFsBl5f3O4oD/o3JOsX342LoqvBl0E2voq5pkaq v2q2Ld+gdu7ZO7al6J38xi8yQoolO9HEHIaQRqb8b2l0ehFf7ZVWN/GYijF1oPpZv50Y BjVcVADhLkZPTICLWqbHrwBj3tyZ2cVEQQTi/A+OQxcZg4OgEcFv3tzpshIXnqTv0yrF Y09g== 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=csKoX99wXjSZzk96rey5IsInzo47PM9NCitxp5N6Ioc=; b=EQQ6XyJILx/iFUi02PfIBhV6wkms0qSy5OKAIXTluiFXrNKWAGKWGt2Q/Z78PNQ4UR TdOEkceGifNyV8aAnefXuDYLULjM5wHrM21QMHLxGOJBJTTo8Xg8igRzxBYMt7q80Fe6 3YyA9Iz0AILir1llpUu+oNbQX/I0VhwzYSuc8qYTYx2VbkKkzZyXRwP0fhlwYGpCtVM6 1d6Qvjjd5ACeBz0i9UyUr0bjDiZ+RqWnZZ2wZcBKixBaEgNrT+/KN/skNOv1rqncmw3I Bwd+Yhy0n/qlt9u1KD5CwE3HA2EP8GlWch38X0788xvDeGEC8nZHT5YD5i+PP0YS0zvf Dcww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JBsprV2Z; 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 o23si4346005oic.127.2020.02.24.14.52.32; Mon, 24 Feb 2020 14:52:44 -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=JBsprV2Z; 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 S1728252AbgBXWvE (ORCPT + 99 others); Mon, 24 Feb 2020 17:51:04 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43739 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727459AbgBXWvD (ORCPT ); Mon, 24 Feb 2020 17:51:03 -0500 Received: by mail-pg1-f195.google.com with SMTP id u12so5859613pgb.10 for ; Mon, 24 Feb 2020 14:51:03 -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=csKoX99wXjSZzk96rey5IsInzo47PM9NCitxp5N6Ioc=; b=JBsprV2ZLAIyNTLRN+r6ILxG8+TbFtBYW2Vas2aSlSWdE92/TbkPGBwaSn9lgcXnaU KKaMu4qqae+0B7r8DPvRbAhIfMCBpOjzAKBQ6wjUh1PWZYrO/xpKnMNDzxLYUguC0Fyz EExngqXog17tgU8cnxBvI8nwuajadec7oLXYPm6en77KfXyBMHMGlQeSTXpWJSnF+/Iy elhxf95xO0dwWyaKPW7hA9072YpdMImNRS9v+IYGPQtEw2NNASBTO3owiQ0tUywCJF+c X/X6mHoZKiqrXZ+NIfIXc7C4yUnBRn2dfeQbpOOzOSrhTuRFn3xd0Md7KXuM/OZA/SU8 lxbA== 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=csKoX99wXjSZzk96rey5IsInzo47PM9NCitxp5N6Ioc=; b=pK0tX0ELacNQcuA9YAxk5YlLtHw1DL1Bq1PWPU02/GNBzHBw0sg3dEtpW+DuPdUJ6k La5UAdQ7jegmUu4qPXCllZ31EEplNbRpR/k7SWFW9b9elx/iIUf8LhYigPFdP7FEVFw9 U+eoYYjFmzYlVa1rWDUkVgjIRYLlK3ylN/BjN7CjQ6ipiO4sCtcN5pGAjwqB8EVrlG2g QF3eLf2hjEICDsHGkTBQFpuDsxR2nGFMCLW7nMvGARmWDBTxG7Gitr2ufDdkoOm3XArV xfjpf/VS2fPCOwoNoP6yLcJ7VdK7fo0PItMge/Y44elWbEsCcNJNDtWYBzHC+BmIlhWK e5tw== X-Gm-Message-State: APjAAAXQV+Au21sS38WaEn4SRbXFW2LE8WxUozxiTRfIBksI44ZDETWX Imipo2IkDpC/N5IJxFelJz62+A== X-Received: by 2002:a62:1456:: with SMTP id 83mr54643458pfu.186.1582584662629; Mon, 24 Feb 2020 14:51:02 -0800 (PST) Received: from google.com ([2620:15c:2ce:0:9efe:9f1:9267:2b27]) by smtp.gmail.com with ESMTPSA id z4sm13622592pfn.42.2020.02.24.14.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 14:51:02 -0800 (PST) Date: Mon, 24 Feb 2020 14:50:59 -0800 From: Fangrui Song To: Arvind Sankar Cc: Nick Desaulniers , Michael Matz , 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 Message-ID: <20200224225059.2scjklfi4g7wwdkp@google.com> References: <20200222072144.asqaxlv364s6ezbv@google.com> <20200222074254.GB11284@zn.tnic> <20200222162225.GA3326744@rani.riverdale.lan> <20200224212828.xvxl3mklpvlrdtiw@google.com> <20200224214845.GC409112@rani.riverdale.lan> <20200224221703.eqql5hrx4ccngwa5@google.com> <20200224224343.GA572699@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200224224343.GA572699@rani.riverdale.lan> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-02-24, Arvind Sankar wrote: >On Mon, Feb 24, 2020 at 02:17:03PM -0800, Fangrui Song wrote: >> On 2020-02-24, Arvind Sankar wrote: >> >On Mon, Feb 24, 2020 at 01:28:28PM -0800, Fangrui Song wrote: >> >> Hi Michael, please see my other reply on this thread: https://lkml.org/lkml/2020/2/24/47 >> >> >> >> Synthesized sections can be matched as well. For example, SECTIONS { .pltfoo : { *(.plt) }} can rename the output section .plt to .pltfoo >> >> It seems that in GNU ld, the synthesized section is associated with the >> >> original object file, so it can be written as: >> >> >> >> SECTIONS { .pltfoo : { a.o(.plt) }} >> >> >> >> In lld, you need a wildcard to match the synthesized section *(.plt) >> >> >> >> .rela.dyn is another example. >> >> >> > >> >With the BFD toolchain, file matching doesn't actually seem to work at >> >least for .rela.dyn. I've tried playing around with it in the past and >> >if you try to use file-matching to capture relocations from a particular >> >input file, it just doesn't work sensibly. >> >> I think most things are working in GNU ld... >> >> /* a.x */ >> SECTIONS { >> .rela.pltfoo : { a.o(.rela.plt) } /* *(.rela.plt) with lld */ >> .rela.dynfoo : { a.o(.rela.data) } /* *(.rela.dyn) with lld */ >> } > >The file matching doesn't do anything sensible. If you split your .data >section out into b.s, and update the linker script so it filters for >b.o(.rela.data), .rela.dynfoo doesn't get created, instead the default >.rela.dyn will contains the .data section relocation. If you keep the >filter as a.o(.rela.data), you get .rela.dynfoo, even though a.o doesn't >actually contain any .rela.data section any more. I raised the examples to support my viewpoint "synthesized sections can be matched, as well as input sections." If there is really a need (rare, not recommended) to rename output sections only consisting of synthesized sections (e.g. .plt .rela.dyn), for linker portability, it is better using a wildcard for the input filename pattern. As another example, SECTIONS { /DISCARD/ : { *(.rela.*) } } discards synthesized .rela.* >> >> % cat < a.s >> .globl foo >> foo: >> call bar >> .data >> .quad quz >> e >> % as a.s -o a.o >> % ld.bfd -T a.x a.o -shared -o a.so