From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by sourceware.org (Postfix) with ESMTPS id 609F33857C46 for ; Wed, 23 Sep 2020 16:52:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 609F33857C46 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=mittosystems.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jozef.l@mittosystems.com Received: by mail-wm1-x342.google.com with SMTP id s13so720762wmh.4 for ; Wed, 23 Sep 2020 09:52:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mittosystems.com; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=Xst6lMsSi1qQR3RumJk/AXejgYailsI8eXAmJ/trYac=; b=IVDVbIC59H4pB2CjiEHXpC6FTzS7I0XixsMZEsAwxnmx6AWqh93cfI6JfKXLDusS7W QxMhIoq9L7mmkZwPQQkup4uIZ+CC7NjKFIDddXHs0wnaWynf8EItus6u+Jx0aQQTTNYi 2t30XvlzmHgOKQP/B265o3fBOAYwfhl/SWKX5K/Bf34vIsZ3vSEzU0ivVR3VFjcwdGqc THoAtkdhueGkQPHPVQvlrPZPDDuuskR4GfZI5ICAV/iV61JyWx5oXXjI5zQIpHCmDonG mYPNai49H3i/qIIicfJUB8aU7qTYxCfbczeP+Hmum81KVo8ExspyEXwGZ3OPo0j5DoIH n4Vg== 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 :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=Xst6lMsSi1qQR3RumJk/AXejgYailsI8eXAmJ/trYac=; b=SVtCxarRRtJcI7GwlI0zSvjXPhHOrPPuqXtDXduvCP2IVyBescHJpB7Qgr8bipaQP/ LHF3sfX2M5m0evXMm6u8noyY6mXBkvggm7EI+fjRpIGmhaDq/fPy4+irYxAF+R6C2jkM U3LfvFM7roQxcOFlQdjCkFzDZUQb3rAax/nFUnZt/x6oADdkVs8+ubCbeTCCEvDsin3K NGgXxX/q+cUOz/FCFhqe9/QbNPCBB7XOFy8gK1YBDUgZQS2t5MUWAfzSpm8PXk5AFUen 5UetEEaHK5+t1I4OrYs8XX+3Zmr73EnBr3Ycg+ONX5+reBl0rpRpWSrP1xUpmgMuv9LW XZRg== X-Gm-Message-State: AOAM532if2iRzP0Tav03nQniqsH/UZaczJTHIes6HHuy8FpYKT6T2Fgw JAULJhXRTisy0XeuiA40o/FI0w== X-Google-Smtp-Source: ABdhPJzTlu7iX15lsd1Ud0Xnd4u3Y0dCywJXpOe8zMvh2FX4a1rETNOA1PrBdSvbsu/1+3JW+fv6uA== X-Received: by 2002:a1c:7e90:: with SMTP id z138mr489302wmc.122.1600879933330; Wed, 23 Sep 2020 09:52:13 -0700 (PDT) Received: from jozef-acer-manjaro ([2a01:4b00:87fd:900:5e1d:5c99:56da:76e8]) by smtp.gmail.com with ESMTPSA id y1sm360866wmi.36.2020.09.23.09.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 09:52:12 -0700 (PDT) Date: Wed, 23 Sep 2020 17:52:11 +0100 From: Jozef Lawrynowicz To: Michael Matz Cc: "H.J. Lu" , Binutils Subject: Re: [PATCH] Support SHF_GNU_RETAIN ELF section flag Message-ID: <20200923165211.fr4rqzp5uqqmrufq@jozef-acer-manjaro> Mail-Followup-To: Michael Matz , "H.J. Lu" , Binutils References: <20200923010930.xtc4mgmxsoesohkn@gmail.com> <20200923095818.npbwybrm63vb4ejm@jozef-acer-manjaro> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2020 16:52:15 -0000 On Wed, Sep 23, 2020 at 01:51:56PM +0000, Michael Matz wrote: > Hello, > > On Wed, 23 Sep 2020, H.J. Lu via Binutils wrote: > > > > I think that: > > > > > > > .section .text,"ax" > > > > ... > > > > foo: > > > > ... > > > > .retain > > > > retained_fn: > > > > ... > > > > > > is some nice syntactic sugar compared to: > > > > > > > .section .text,"ax" > > > > ... > > > > foo: > > > > ... > > > > .section .text,"axR" > > > > retained_fn: > > > > ... > > > > > > It's also partly for convenience; we have other directives which are > > > synonyms or short-hand for each other. > > > > > > > You don't need to keep the whole section when only one symbol should > > be kept. Please drop the .retain directive. GCC, as and ld should do the > > right thing with > > > > .section .text,"ax" > > ... > > foo: > > ... > > .section .text,"axR" > > > > retained_fn: > > > > where foo can be dropped and retained_fn will be kept. > > This is not what we discussed at the ABI list, the flag is per section, so > either the whole section is retained or not. What you describe is > something else that would work on a per symbol basis, which would have to > be specified in a different way and might or might not be a good idea. > But let's not conflate these two. Also, the linker cannot currently dissect a section and remove a particular unused symbol anyway. Since garbage collection only operates on the section level, marking the section itself as "retained" seems most appropriate. As an aside.. we would run into limitations in the ELF format if trying to mark the symbol itself as "retained". You cannot define "retain" as a new symbol type or binding, because there is not a one-to-one mapping of "retain" to the existing symbol types and bindings i.e. a retained symbol might be STT_OBJECT or STT_FUNC, or STB_LOCAL or STB_GLOBAL. st_other could be another place to store the requirement to "retain" a symbol, but all those available bits are used up (albeit some unofficially). I'm not saying there's no way it could be done, but these are the hurdles I discovered when considering that path to implementing the "retain" behavior. > About the .retain syntactic sugar: I also think it's not necessary, the > .section directive with R flag merging is good enough IMHO. I'm OK with removing the .retain directive, since there is some consensus it is not necessary. Also, I thought it made life easier for GCC to mark sections as retained by omitting the section name from the directive, but I've discovered a way around that now. Thanks, Jozef