From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id AB52A3857C62 for ; Tue, 18 Jan 2022 23:24:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AB52A3857C62 Received: by mail-pg1-x536.google.com with SMTP id h23so591716pgk.11 for ; Tue, 18 Jan 2022 15:24:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=h0fbAfhvIkV455QuVtkJKkzQAVYpGUDWf7aL3z2psLA=; b=npyRw/4p9iQ9iGyMHqTZot6h8GJepAXpEM9VgwWZ27iRIbMHlnlObO5r4eX/jN4g7c XV1oXksiapZFJrlCqq/om1lKuF9gKo58UwVMMn5L4vykGyf+/FW1uWg6dW0pIJUuT+1L mgoD8B0AkM29FEnICec99Yg+jogFFCg1IPRy0wjJOEbWmhaPPBJNC3ZoFMHqHmHstZ7S 7OJKaDWKtFKdgHDp4ReUkYS4UBmkcuZ9ln2rOnmY8iJs1JSz2QongtksnPRRfg7r04G1 8I7BnFJ4Am7aHxYuQf7EvdKKSoJp4wDJplZ5cHDOnBUOROcaQrcae3YmXGOYdIezO1r2 KPLA== X-Gm-Message-State: AOAM533F08s84C6Mh+7PQxHlPBQViXBgbMcJ8L65vk7tRnAypoHPe4Ir mJYz/IZgr66SJEWML6WfyosqVrSfS70= X-Google-Smtp-Source: ABdhPJzHcltTJMb2gEJmQ3/Mjt8XtgoA9eiIlWDmdKVr1I4cd69FL6Tr/rYTPQf0PTuCRTUzoC80kg== X-Received: by 2002:a63:2a51:: with SMTP id q78mr2061990pgq.25.1642548258821; Tue, 18 Jan 2022 15:24:18 -0800 (PST) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id m14sm12487081pfh.129.2022.01.18.15.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 15:24:18 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 567741140066; Wed, 19 Jan 2022 09:54:15 +1030 (ACDT) Date: Wed, 19 Jan 2022 09:54:15 +1030 From: Alan Modra To: "H.J. Lu" Cc: Binutils Subject: Re: PowerPC64 DT_RELR Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3037.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Tue, 18 Jan 2022 23:24:21 -0000 On Tue, Jan 18, 2022 at 05:32:37AM -0800, H.J. Lu wrote: > I tried binutils master branch on glibc master branch: > > $ readelf -r libc.so.6 > > Relocation section '.rela.dyn' at offset 0x21d38 contains 562 entries: > Offset Info Type Sym. Value Sym. Name + Addend > 000000000000 000000000000 R_PPC64_NONE 0 > 000000000000 000000000000 R_PPC64_NONE 0 > > There are 238 R_PPC64_NONEs in libc.so.6 alone. There is none > for i686, x32 and x86-64. Thanks for testing and finding the problem. I did warn that DT_RELR on ppc64 is experimental. :-) I had the SYMBOL_REFERENCES_LOCAL test in the wrong place. check_relocs is too early to know whether a symbol is dynamic in a shared library. Lots of glibc symbols are made local by version script, but that doesn't happen until size_dynamic_sections. * elf64-ppc.c (ppc64_elf_check_relocs): Don't count relative relocs here depending on SYMBOL_REFERENCES_LOCAL. (dec_dynrel_count): Likewise. (allocate_dynrelocs): Do so here instead. diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 923c7a3b407..aeae3b7e640 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -5390,8 +5390,7 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, if ((r_type == R_PPC64_ADDR64 || r_type == R_PPC64_TOC) && rel->r_offset % 2 == 0 && sec->alignment_power != 0 - && ((!NO_OPD_RELOCS && is_opd) - || (!ifunc && SYMBOL_REFERENCES_LOCAL (info, h)))) + && ((!NO_OPD_RELOCS && is_opd) || !ifunc)) p->rel_count += 1; } else @@ -7287,8 +7286,7 @@ dec_dynrel_count (const Elf_Internal_Rela *rel, && sec->alignment_power != 0 && ((!NO_OPD_RELOCS && ppc64_elf_section_data (sec)->sec_type == sec_opd) - || (h->type != STT_GNU_IFUNC - && SYMBOL_REFERENCES_LOCAL (info, h)))) + || h->type != STT_GNU_IFUNC)) p->rel_count -= 1; p->count -= 1; if (p->count == 0) @@ -10016,7 +10014,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) if (eh->elf.type == STT_GNU_IFUNC) sreloc = htab->elf.irelplt; count = p->count; - if (info->enable_dt_relr) + if (info->enable_dt_relr && SYMBOL_REFERENCES_LOCAL (info, h)) count -= p->rel_count; sreloc->size += count * sizeof (Elf64_External_Rela); } -- Alan Modra Australia Development Lab, IBM