From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by sourceware.org (Postfix) with ESMTPS id 6853F3842437 for ; Fri, 2 Oct 2020 15:45:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6853F3842437 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-x443.google.com with SMTP id w5so2318597wrp.8 for ; Fri, 02 Oct 2020 08:45:16 -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=fdx2WNiynLaEJpF+zCBbxQqL98nOyqAv/P671RG/Cjk=; b=RgowBd/cHcXORP4EXZdx6sTQpYpgrjRLc2p7JpFaFSsKD+hEBH4i8KZVD9jf1SzQYf xngGKOKrdM6aV6iIRqKB8fwBe8c1ZZ1yI989WQ8SaY1bc8XJeAK+Y49MZSkU6Rr3ODah Mwj5VYIJKuw9ftOK3sVTLQf2KI4+FzjzqKN4vHbXyXt1eDQ4uR3GjY1te2AVsC/FyZ3e iWb7aFWSMD3FRwI/8QMgMqiy1/C2GVLW4KgmSSbs4EfyBWee1xFQTXvZJqGr5Qygxldo 3T7cG5ZkzuInMfGl2/AEXnsHBaHigyD2iNeLZwSlglyD2R24A65G1R7dKceQtXlM2gLP foeA== 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=fdx2WNiynLaEJpF+zCBbxQqL98nOyqAv/P671RG/Cjk=; b=WZXB+ScMRRrszo86iKpd1IwEz36dVFlbIRtByoDqtIF3BLFy0aINSa9jtXM4lS80DQ B8/+wq6kN5Av1aDpJSpFOR+2oMT2eff2nyvu78GvmfLc2LOxgiWl+0OJqNE23x7Ob55j 6BWJ0w8eFOJ5RU2pM/C1wUdGb4MktZcHM0uFdjai/oZSZnFp7Lu2aL/oeve2atTi6TXZ lpaF0R46B7niR/4D7XhPB2XS1wsbBy6/31igK/p7aPH7GBhLP6JmX4ebL3wUTQ47LK7K QYh91EduMY5QUsWEdxIbleeJLVT9gEpr0EPUrhotI0jDYHLZvEimXPwDcp1+ShvgvDif c3Mw== X-Gm-Message-State: AOAM532tmNLV45R1bQmjncBg1rGUe8dWOneL9AeTncpi7qPsLIRzKOSM g+ipf8s2dnmPonaFxt7rs4H1Wg== X-Google-Smtp-Source: ABdhPJxldcB/i11+KrkqqcM5W+OCH6vNNP5Ri9Wwmiktp/E0f9xpfB74dgSeYEpqivQEX83bhMbD4w== X-Received: by 2002:adf:ffc7:: with SMTP id x7mr3748221wrs.405.1601653515448; Fri, 02 Oct 2020 08:45:15 -0700 (PDT) Received: from jozef-acer-manjaro ([2a01:4b00:87fd:900:5e1d:5c99:56da:76e8]) by smtp.gmail.com with ESMTPSA id y6sm2162291wrt.80.2020.10.02.08.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2020 08:45:14 -0700 (PDT) Date: Fri, 2 Oct 2020 16:45:13 +0100 From: Jozef Lawrynowicz To: Alan Modra Cc: "H.J. Lu" , Binutils Subject: Re: [PATCH v2] Support for SHF_GNU_RETAIN ELF Section Flag Message-ID: <20201002154513.jo6u6okjpxpvxvh3@jozef-acer-manjaro> Mail-Followup-To: Alan Modra , "H.J. Lu" , Binutils References: <20200928132613.btkqaoomv4fdnupn@jozef-acer-manjaro> <20201001105033.4eniyhry5o6epu4x@jozef-acer-manjaro> <20201001113907.GK15011@bubble.grove.modra.org> <20201002123023.xr7fnqmuuq6xd7xh@jozef-acer-manjaro> <20201002141110.GS15011@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201002141110.GS15011@bubble.grove.modra.org> X-Spam-Status: No, score=-4.8 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: Fri, 02 Oct 2020 15:45:18 -0000 On Fri, Oct 02, 2020 at 11:41:10PM +0930, Alan Modra via Binutils wrote: > 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. Well in fact, the part I added OSABI handling to already in readelf wasn't correct anyway, those nested switch/if-else/switch statements caught me out ;) Cleaning that up is a task for some other time, however. I started adding tests to validate the readelf output with/without "-N", when the numeric values for SHF_GNU_{RETAIN,MBIND} are set, for targets which neither error when these bits are set (ELFOSABI_STANDALONE) nor handle them as their GNU OSABI values (ELFOSABI_{NONE,GNU,FREEBSD}). However, hppa-unknown-elf is the only target I've been testing that satisfies these constraints (ELFOSABI_HPUX), so I'm going to find some others to validate the changes and finish this off next week. > > > > > +* 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. Sounds fair to me. The precise ELF definition is targeting technical users after all. Thanks, Jozef > > -- > Alan Modra > Australia Development Lab, IBM