From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101557 invoked by alias); 8 Feb 2020 20:23:27 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 101549 invoked by uid 89); 8 Feb 2020 20:23:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=D*me, U*i, i@maskray.me, imaskrayme X-HELO: mail-ot1-f65.google.com Received: from mail-ot1-f65.google.com (HELO mail-ot1-f65.google.com) (209.85.210.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 08 Feb 2020 20:23:25 +0000 Received: by mail-ot1-f65.google.com with SMTP id a15so2666987otf.1 for ; Sat, 08 Feb 2020 12:23:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aB5T5kKXlChTev7eSAKmwTRjtgDLHCdL7B53A0EG7xg=; b=SVbxrD/qtQs/sAU/NwodDRDZE7WJAtrkvQ9021x/SjDw65+5JHG8lDqDQh+aoq6aww n87LRZSochgG9sz3+8mF2cmGnAFg32xovEAmZQODJIGFbTv2lRoX/nnrLMkC2k6ieoaP 07iKFmkDSreoSBQXuHCNCCJmzottdRgVOrgQg8Bnea6rLwIwLBlNwwHfIzUXOpVmoEOt yA/GbFaJfCjv0NTFsdFgVRjJE3ve/Kf4yXqi1ncUA3z9Pqy1wPIdQ2DfR7dU8o1PITnh qb420ODQYhupESyzhyrrZM85OSerqEAPDuYDqHijWwybQl7A6PZvzW6NZaAcd1OTokwE tExw== MIME-Version: 1.0 References: <20200207021431.387289-1-hjl.tools@gmail.com> <20200208181425.eob7jcssy2gery6o@google.com> In-Reply-To: <20200208181425.eob7jcssy2gery6o@google.com> From: "H.J. Lu" Date: Sat, 08 Feb 2020 20:23:00 -0000 Message-ID: Subject: Re: [PATCH] ELF: Discard a section if any of its linked-to section has been discarded To: Fangrui Song Cc: Binutils Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00124.txt.bz2 On Sat, Feb 8, 2020 at 10:14 AM Fangrui Song wrote: > > On 2020-02-06, H.J. Lu wrote: > >Add ldelf_before_place_orphans to call before lang_place_orphans to > >discard a section if any of its linked-to sections has been discarded. > > > > PR ld/25022 > > * emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Add > > before_place_orphans_default. > > * emultempl/armcoff.em (ld_${EMULATION_NAME}_emulation): Likewise. > > * emultempl/beos.em (ld_${EMULATION_NAME}_emulation): Likewise. > > * emultempl/generic.em (ld_${EMULATION_NAME}_emulation): Likewise. > > * emultempl/linux.em (ld_${EMULATION_NAME}_emulation): Likewise. > > * emultempl/msp430.em (ld_${EMULATION_NAME}_emulation): Likewise. > > * emultempl/pe.em (ld_${EMULATION_NAME}_emulation): Likewise. > > * emultempl/pep.em (ld_${EMULATION_NAME}_emulation): Likewise. > > * emultempl/ticoff.em (ld_${EMULATION_NAME}_emulation): Likewise. > > * emultempl/vanilla.em (ld_${EMULATION_NAME}_emulation): Likewise. > > * emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Use > > ldelf_before_place_orphans. > > * ldelf.c (ldelf_before_place_orphans): New. > > * ldelf.h (ldelf_before_place_orphans): Likewise. > > * ldemul.c (ldemul_before_place_orphans): Likewise. > > (before_place_orphans_default): Likewise. > > * ldemul.h (ldemul_before_place_orphans): Likewise. > > (before_place_orphans_default): Likewise. > > (ld_emulation_xfer_struct): Add before_place_orphans. > > * ldlang.c (lang_process): Call ldemul_before_place_orphans > > before lang_place_orphans. > > * testsuite/ld-elf/pr25022.d: New file. > > * testsuite/ld-elf/pr25022.s: Likewise. > > * testsuite/ld-elf/pr25022.t: Likewise. > > Is the second rule listed on > https://sourceware.org/ml/binutils/2020-02/msg00035.html respected? > > > For a non-SHF_ALLOC section, it is a GC root only if all the following > > conditions are satisfied: > > ... > > * it is not in a section group with at least one SHF_ALLOC section. > > If it belongs to such a section group, we expect a > > SHF_ALLOC section in the section group responsible for making the > > whole group alive. This semantic is at least expected by > > If A (with SHF_LINK_ORDER) is in a section group with no SHF_ALLOC > section, we should not garbage collect A. Testcase please. -- H.J.