From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by sourceware.org (Postfix) with ESMTPS id 50E563857C44 for ; Fri, 2 Oct 2020 14:11:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 50E563857C44 Received: by mail-pg1-x543.google.com with SMTP id 7so836795pgm.11 for ; Fri, 02 Oct 2020 07:11:16 -0700 (PDT) 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:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ETGf5N68XnIDfHhWkDUqdKEe1+Fd7CVxxMsngGTfSvs=; b=WR0oCvfBwlDwrS7+0zfDkv6pR7qG0/TKVc6fpBuUGvQcs8lID6CLxFaPdLO7AMRpLG eIkya1j9WQ/kxVhBpbaIYQZBHrSu5w4cNnhk0ueTIGlrm48En+VKlRyyQjf09xF2DY0C JtIPt0oALMZvBEhVKvC8USy2rk1uEWn9p7rDPZ+u15q+vIWQHKC/qcSqpw1q0hvATvR8 xddA4N7r5zizi8Q/1iAvgAYWJw6mej1VmxmXhpgUjtAvuZf23T1KCt5QPIU4yspgTHa4 5JTec2iDrSH1oApASpW0wnB/GnhbHh+V6pbBAxp4xGAIyCl/BHlsIUQN0N/qyKAprKwW 62uQ== X-Gm-Message-State: AOAM531prdOmyXf+eYDnyd/apd90lASZZTR/74CoIzkHwPoe918Ozi+E YVHYp10JoLdMRC7JFrsUu7HcK6gj5HEJag== X-Google-Smtp-Source: ABdhPJxtFx0xh78GzlBSdYEifxIj0i8TUUFfUt0grhUnAZuhV2GFUrio0sRA8GDo2b/wdR2nyKmPHg== X-Received: by 2002:a62:fc06:0:b029:142:2501:397d with SMTP id e6-20020a62fc060000b02901422501397dmr2882521pfh.66.1601647875426; Fri, 02 Oct 2020 07:11:15 -0700 (PDT) Received: from bubble.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id 14sm1681118pjn.48.2020.10.02.07.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2020 07:11:14 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 9434282A1A; Fri, 2 Oct 2020 23:41:10 +0930 (ACST) Date: Fri, 2 Oct 2020 23:41:10 +0930 From: Alan Modra To: "H.J. Lu" , Binutils Subject: Re: [PATCH v2] Support for SHF_GNU_RETAIN ELF Section Flag Message-ID: <20201002141110.GS15011@bubble.grove.modra.org> References: <20200928132613.btkqaoomv4fdnupn@jozef-acer-manjaro> <20201001105033.4eniyhry5o6epu4x@jozef-acer-manjaro> <20201001113907.GK15011@bubble.grove.modra.org> <20201002123023.xr7fnqmuuq6xd7xh@jozef-acer-manjaro> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201002123023.xr7fnqmuuq6xd7xh@jozef-acer-manjaro> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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: Fri, 02 Oct 2020 14:11:17 -0000 On Fri, Oct 02, 2020 at 01:30:23PM +0100, Jozef Lawrynowicz wrote: > On Thu, Oct 01, 2020 at 09:09:07PM +0930, Alan Modra via Binutils wrote: > > On Thu, Oct 01, 2020 at 11:50:33AM +0100, Jozef Lawrynowicz wrote: > > > --- a/bfd/elflink.c > > > +++ b/bfd/elflink.c > > > @@ -14102,7 +14102,8 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info) > > > || (elf_section_data (o)->this_hdr.sh_type > > > == SHT_FINI_ARRAY))) > > > || (elf_section_data (o)->this_hdr.sh_type == SHT_NOTE > > > - && elf_next_in_group (o) == NULL ))) > > > + && elf_next_in_group (o) == NULL) > > > + || (elf_section_flags (o) & SHF_GNU_RETAIN))) > > > > Flag bits in SHF_MASKOS depend on OS, so this needs a test of OSABI. > > That can be done by checking elf_tdata (sub)->has_gnu_osabi for the > > appropriate bit. > > > > Fixed the two OSABI issues in the attached patch. I didn't mention it, but readelf has two occurrences of decoding SHF_GNU_UNIQUE. They both need fixing, not just the first one. > > > +* Add support for the SHF_GNU_RETAIN ELF section flag. > > > + This flag specifies that the section should not be garbage collected by the > > > + linker if it is unused. > > > > I would drop "if it is unused". The phrase doesn't really add > > anything to a user's understanding. > > > > I don't really have a strong opinion either way, but I thought "if it is > unused" might be helpful to add to the description since "garbage > collection" is not precisely defined in ELF. The reason I don't particularly like "if it is unused" is that it sounds like something said by someone who doesn't really understand linker garbage collection. "used" and "referenced by a relocation from a kept section" are only loosely related. And indeed the whole purpose of SHF_GNU_RETAIN is surely to keep needed sections, ones that are used for some purpose. -- Alan Modra Australia Development Lab, IBM