From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id C0AB23857C4C for ; Wed, 23 Sep 2020 22:41:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C0AB23857C4C Received: by mail-pf1-x431.google.com with SMTP id n14so566167pff.6 for ; Wed, 23 Sep 2020 15:41:06 -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:mime-version :content-disposition:user-agent; bh=9IizqrAC82KE+qWNAI2tJUwpyJpSWZ2A0rvfm1b2aNg=; b=B3efASOXeAttz/LofmLpOkrx8eUioz247FHMTCepyJzqnEhkjBixyFiJxw91h0cvjf ttM+GIxA0gGKLhxpZitGDAyFCHPG61FEJBzZ4TSqHEYddGyLO7nEnqG8ayKLzBn8kTd/ /KwGoQeYt2WiPtUzqGyOEq3EC743T3xU9e9rG2Q24rgADltcq1mRUDucSMfWYBQ8ZfGE deJ0KFVgevcENxMzy7lGxYzfqfq24kZTEU8MRrf9JEEMk2dfE2o7n/RRWjUSjzSIwhQJ DbdKftL/xVoHWC54EcPeXJc1pgBh/oueldIsVplP7oVe6YsMJvRlYrhcDGZ3KlPz5JZ9 PwXA== X-Gm-Message-State: AOAM533lW6+cHd20mKrUtTHDgO8lAZnWKgpt7G6i2YfoQr/SMjXoZ04z OzRyI62l01aEaMsut7fOvp4Fo74bFUI= X-Google-Smtp-Source: ABdhPJzVPGeitk+xB9Qg96mf4HcHcMdxA4WYUTpHWmZ+xNzSWzqMzoWzrvCoiF0hFpT/PPT6QVlGJg== X-Received: by 2002:a63:5452:: with SMTP id e18mr1544074pgm.330.1600900865351; Wed, 23 Sep 2020 15:41:05 -0700 (PDT) Received: from bubble.grove.modra.org ([2406:3400:51d:8cc0:9583:52e2:19a0:946d]) by smtp.gmail.com with ESMTPSA id j20sm612607pfh.146.2020.09.23.15.41.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 15:41:04 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id C197885B1A; Thu, 24 Sep 2020 08:11:00 +0930 (ACST) Date: Thu, 24 Sep 2020 08:11:00 +0930 From: Alan Modra To: binutils@sourceware.org Subject: PR26655, Power10 libstdc++.so R_PPC64_NONE dynamic relocs Message-ID: <20200923224100.GG5452@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-9.0 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.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: Wed, 23 Sep 2020 22:41:09 -0000 Some of the powerpc64 code editing functions are better run after dynamic symbols have stabilised in order to make proper decisions based on SYMBOL_REFERENCES_LOCAL. The dynamic symbols are processed early in bfd_elf_size_dynamic_sections, before the backend always_size_sections function is called. One function, ppc64_elf_tls_setup must run before bfd_elf_size_dynamic_sections because it changes dynamic symbols. ppc64_elf_edit_opd and ppc64_elf_inline_plt can run early or late, I think. ppc64_elf_tls_optimize and ppc64_elf_edit_toc are better run later. So this patch arranges to call some edit functions later via always_size_sections. PR 26655 bfd/ * elf64-ppc.c (ppc64_elf_func_desc_adjust): Rename to.. (ppc64_elf_edit): Call params->edit. (ppc64_elf_tls_setup): Don't call _bfd_elf_tls_setup. Return a bfd_boolean. * elf64-ppc.h (struct ppc64_elf_params): Add "edit". (ppc64_elf_tls_setup): Update declaration. ld/ * emultempl/ppc64elf.em (params): Add ppc_edit. (ppc_before_allocation): Split off some edit functions to.. (ppc_edit): ..this, new function. diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 06202c94a3..4d16dc3cd4 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -114,7 +114,7 @@ static bfd_vma opd_entry_value #define elf_backend_adjust_dynamic_symbol ppc64_elf_adjust_dynamic_symbol #define elf_backend_hide_symbol ppc64_elf_hide_symbol #define elf_backend_maybe_function_sym ppc64_elf_maybe_function_sym -#define elf_backend_always_size_sections ppc64_elf_func_desc_adjust +#define elf_backend_always_size_sections ppc64_elf_edit #define elf_backend_size_dynamic_sections ppc64_elf_size_dynamic_sections #define elf_backend_hash_symbol ppc64_elf_hash_symbol #define elf_backend_init_index_section _bfd_elf_init_2_index_sections @@ -6341,13 +6341,13 @@ static const struct sfpr_def_parms save_res_funcs[] = }; /* Called near the start of bfd_elf_size_dynamic_sections. We use - this hook to a) provide some gcc support functions, and b) transfer - dynamic linking information gathered so far on function code symbol - entries, to their corresponding function descriptor symbol entries. */ + this hook to a) run the edit functions in this file, b) provide + some gcc support functions, and c) transfer dynamic linking + information gathered so far on function code symbol entries, to + their corresponding function descriptor symbol entries. */ static bfd_boolean -ppc64_elf_func_desc_adjust (bfd *obfd ATTRIBUTE_UNUSED, - struct bfd_link_info *info) +ppc64_elf_edit (bfd *obfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) { struct ppc_link_hash_table *htab; @@ -6355,6 +6355,9 @@ ppc64_elf_func_desc_adjust (bfd *obfd ATTRIBUTE_UNUSED, if (htab == NULL) return FALSE; + /* Call back into the linker, which then runs the edit functions. */ + htab->params->edit (); + /* Provide any missing _save* and _rest* functions. */ if (htab->sfpr != NULL) { @@ -7695,9 +7698,11 @@ ppc64_elf_inline_plt (struct bfd_link_info *info) return TRUE; } -/* Set htab->tls_get_addr and call the generic ELF tls_setup function. */ +/* Set htab->tls_get_addr and various other info specific to TLS. + This needs to run before dynamic symbols are processed in + bfd_elf_size_dynamic_sections. */ -asection * +bfd_boolean ppc64_elf_tls_setup (struct bfd_link_info *info) { struct ppc_link_hash_table *htab; @@ -7705,7 +7710,7 @@ ppc64_elf_tls_setup (struct bfd_link_info *info) htab = ppc_hash_table (info); if (htab == NULL) - return NULL; + return FALSE; if (abiversion (info->output_bfd) == 1) htab->opd_abi = 1; @@ -7827,7 +7832,7 @@ ppc64_elf_tls_setup (struct bfd_link_info *info) _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr, opt_fd->dynstr_index); if (!bfd_elf_link_record_dynamic_symbol (info, opt_fd)) - return NULL; + return FALSE; } if (tga_fd != NULL) { @@ -7886,7 +7891,7 @@ ppc64_elf_tls_setup (struct bfd_link_info *info) && htab->params->no_tls_get_addr_regsave == -1) htab->params->no_tls_get_addr_regsave = 0; - return _bfd_elf_tls_setup (info->output_bfd, info); + return TRUE; } /* Return TRUE iff REL is a branch reloc with a global symbol matching diff --git a/bfd/elf64-ppc.h b/bfd/elf64-ppc.h index a7230de81c..0492fd7fad 100644 --- a/bfd/elf64-ppc.h +++ b/bfd/elf64-ppc.h @@ -27,6 +27,7 @@ struct ppc64_elf_params /* Linker call-backs. */ asection * (*add_stub_section) (const char *, asection *); void (*layout_sections_again) (void); + void (*edit) (void); /* Maximum size of a group of input sections that can be handled by one stub section. A value of +/-1 indicates the bfd back-end @@ -80,7 +81,7 @@ bfd_boolean ppc64_elf_edit_opd (struct bfd_link_info *); bfd_boolean ppc64_elf_inline_plt (struct bfd_link_info *); -asection *ppc64_elf_tls_setup +bfd_boolean ppc64_elf_tls_setup (struct bfd_link_info *); bfd_boolean ppc64_elf_tls_optimize (struct bfd_link_info *); diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em index 42b9bd48fc..2df5a218e6 100644 --- a/ld/emultempl/ppc64elf.em +++ b/ld/emultempl/ppc64elf.em @@ -32,10 +32,12 @@ fragment <tls_sec != NULL && !no_tls_opt) { /* Size the sections. This is premature, but we want to know the @@ -323,8 +337,6 @@ ppc_before_allocation (void) sort_toc_sections (&toc_os->children, NULL, NULL); } } - - gld${EMULATION_NAME}_before_allocation (); } struct hook_stub_info -- Alan Modra Australia Development Lab, IBM