From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by sourceware.org (Postfix) with ESMTPS id 80813394D82D for ; Thu, 24 Sep 2020 17:18:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 80813394D82D 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-wr1-x441.google.com with SMTP id j2so4682957wrx.7 for ; Thu, 24 Sep 2020 10:18: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=aF8kJv9Nmgu6UsHcPUEJxEoHP5EQgE3oaAvvdad3xQY=; b=Q6QrBoksamCp04+iRxal++uuqNpRrpHgabfA4mWTWE/EPhCGWVu0iQXTb0M2pCZVvS HkOtI9a9tQLcApOAOswXYtFLWnxmzOYAUrCjdqs/WFVctP+3LZRwQJXiw0CPxskXlR1d n5eUsfuWMNGmtMUd2wK+ztsix/LrL2LvGF68GP0wmcQcQoI607L1oCSJO+xncw6msZgH t2+teLw/0YJvkPlL5mbp8g2CrKx76sH9k6RLSM5ps0IXF8RSy2/1TGuxyDuaHFPmoYYC 6VRA5CETrRtt0HkCQCN/j/HaAP7yiSXtXjY39pfxZ8+VM4q5V+JJdI2KkELQCeFb4rug fCTw== 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=aF8kJv9Nmgu6UsHcPUEJxEoHP5EQgE3oaAvvdad3xQY=; b=Xxaebc4tPenYcUmVhaeuxahfd0NoeD3+Ofl4XSxl/qG/Y/sSIcx88ZV8KjTCLJMd4Z yOe/XcJQvQBwxvVUFhYu96qNNTcPEGIlhv5tgtYm8HbBBPw1xgNnfhz26rozvlqKc0w9 uRrZAEAAgJoCQ2qcPxd/7E1+s8DO+X332dlU9P4Dz35rpDvqQhqIqN2yHEIjhbTdEHSt gIAD1PTtnZ8IrooYV1hEQkgwDr+0xDXnMewywIoGBy+Emd8bhXG/mnBHF8yjrCoRhFLN PdbELovqUf/z7WKyg3OP7dWYddxFSaVfFHkToIuUfxiy92R01hsPa+U+B/IiJoaBRpHI KCwQ== X-Gm-Message-State: AOAM531B6fVX5WeJaK6amGtvAkBgsZVV/kUyOv5n64o0Dthhs4WDdC+J COCnknsV1cXnu4/8rjgDfzEpDg== X-Google-Smtp-Source: ABdhPJzFUkv621dDHS4PC7Lmrn3Lk2Mm7Os6Rhb+MFkHFYJwT9dt8cL59JnEWXCWDAKrt34Y88kYRA== X-Received: by 2002:adf:ec92:: with SMTP id z18mr925624wrn.53.1600967893547; Thu, 24 Sep 2020 10:18:13 -0700 (PDT) Received: from jozef-acer-manjaro ([2a01:4b00:87fd:900:5e1d:5c99:56da:76e8]) by smtp.gmail.com with ESMTPSA id k5sm5043wmb.19.2020.09.24.10.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 10:18:10 -0700 (PDT) Date: Thu, 24 Sep 2020 18:18:08 +0100 From: Jozef Lawrynowicz To: "H.J. Lu" Cc: Binutils Subject: Re: [PATCH] Support SHF_GNU_RETAIN ELF section flag Message-ID: <20200924171808.2xr5g7tlhvt7nwbu@jozef-acer-manjaro> Mail-Followup-To: "H.J. Lu" , Binutils References: <20200923184735.4k2tji4yro452bep@jozef-acer-manjaro> <20200923200437.mnegrmwebjuzmfeu@jozef-acer-manjaro> <20200924134914.fmkyo4xqimjatf7u@jozef-acer-manjaro> <20200924165651.47smzoqsc3hx2yas@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=-4.9 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: Thu, 24 Sep 2020 17:18:17 -0000 On Thu, Sep 24, 2020 at 10:04:46AM -0700, H.J. Lu via Binutils wrote: > On Thu, Sep 24, 2020 at 9:56 AM Jozef Lawrynowicz > wrote: > > > > On Thu, Sep 24, 2020 at 06:59:07AM -0700, H.J. Lu via Binutils wrote: > > > On Thu, Sep 24, 2020 at 6:49 AM Jozef Lawrynowicz > > > wrote: > > > > > > > > On Thu, Sep 24, 2020 at 06:18:05AM -0700, H.J. Lu via Binutils wrote: > > > > > On Wed, Sep 23, 2020 at 1:17 PM H.J. Lu wrote: > > > > > > > > > > > > On Wed, Sep 23, 2020 at 1:04 PM Jozef Lawrynowicz > > > > > > wrote: > > > > > > > > > > > > > > On Wed, Sep 23, 2020 at 12:03:28PM -0700, H.J. Lu via Binutils wrote: > > > > > > > > On Wed, Sep 23, 2020 at 11:47 AM Jozef Lawrynowicz > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > On Wed, Sep 23, 2020 at 10:13:37AM -0700, H.J. Lu via Binutils wrote: > > > > > > > > > > On Wed, Sep 23, 2020 at 9:52 AM Jozef Lawrynowicz > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > 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. > > > > > > > > > > > > > > > > > > > > It can be done. If you put your branch on > > > > > > > > > > > > > > > > > > > > https://gitlab.com/x86-binutils/binutils-gdb > > > > > > > > > > > > > > > > > > > > I can help you implement it. > > > > > > > > > > > > > > > > > > It's not something I have time to look into at the moment, for now the > > > > > > > > > aim is just to prevent garbage collection of sections. > > > > > > > > > > > > > > > > Linker and assembler already support it. You just need to add SHF_GNU_RETAIN > > > > > > > > to the framework. Check how SHF_GNU_MBIND works. > > > > > > > > > > > > > > Sorry, I don't understand. > > > > > > > > > > > > > > Are you saying that LD already supports the garbage collection of > > > > > > > individual unused symbol definitions from input sections? Whilst > > > > > > > retaining other symbol definitions which are required by the program? > > > > > > > I cannot find any reference to this. > > > > > > > > > > > > > > How does that relate to SHF_GNU_MBIND? I looked at all the references > > > > > > > to "mbind" in Binutils and nothing seemed related garbage collection of > > > > > > > sections, since SHF_GNU_MBIND is just used to indicate a particular > > > > > > > section should be placed in a special memory area. > > > > > > > > > > > > For > > > > > > > > > > > > section .text,"ax" > > > > > > ... > > > > > > foo: > > > > > > ... > > > > > > .section .text,"axR" > > > > > > retained_fn: > > > > > > > > > > > > you need to create a new .text section with SHF_GNU_RETAIN for > > > > > > retained_fn. See get_section in obj-elf.c. If you want to avoid > > > > > > > > > > See users/hjl/elf/master branch at: > > > > > > > > > > https://gitlab.com/x86-binutils/binutils-gdb/-/commits/users/hjl/elf/master > > > > > > > > > > I removed the .retain directive. > > > > > > > > Thanks, the formalization of section flag merging in the assembler is > > > > nice. > > > > > > > > My only comment is that I used the "STT_*" syntax in the .type directive > > > > instead of % because some targets didn't like the % syntax and emmited > > > > an error. I don't remember which, maybe it was mmix-elf, in which case > > > > we don't care :) > > > > > > Some targets don't support @object. %object works for all targets. > > > > Ah yes, it is in fact the non-existent mmix-elf that can't assemble > > %object but it works for all real targets. > > > > However, some targets don't support the .bss pseudo op which is used in > > your new tests, so those are failing in some cases. > > > > Which ELF targets don't support .bss? gas/testsuite/gas/elf/bss.s has > > .bss > > Do they fail this test? That test only runs for i?86-*-* x86_64-*-* ia64-*-* arm-*-* aarch64-*-* The .bss directive causes an error for the following targets: arc-elf avr-elf cr16-elf cris-elf crx-elf d10v-elf d30v-elf dlx-elf epiphany-elf fr30-elf frv-elf ft32-elf h8300-elf ip2k-elf iq2000-elf lm32-elf m32r-elf m68hc11-elf m68hc12-elf mep-elf metag-elf mmix-elf mmix-elf moxie-elf msp430-elf mt-elf nios2-elf or1k-elf pj-elf ppc-elf pru-elf s12z-elf sh-elf sparc-elf tic6x-elf tilegx-elf tilepro-elf wasm32-elf xgate-elf xstormy16-elf xtensa-elf z80-elf Thanks, Jozef > > -- > H.J.