aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-09-23 14:55:39 +0930
committerAndreas K. Hüttel <dilfridge@gentoo.org>2020-10-21 00:52:05 +0300
commit148e884b18fa9c11d5505cf6c6755688c9922cf8 (patch)
treec7731715ade34ec04ca3c9b9415ebb9055019022
parentCorrect vcmpsq, vcmpuq and xvtlsbb BF field (diff)
downloadbinutils-gdb-148e884b18fa9c11d5505cf6c6755688c9922cf8.tar.gz
binutils-gdb-148e884b18fa9c11d5505cf6c6755688c9922cf8.tar.bz2
binutils-gdb-148e884b18fa9c11d5505cf6c6755688c9922cf8.zip
PR26655, Power10 libstdc++.so R_PPC64_NONE dynamic relocs
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. (cherry picked from commit c94053440e29421dd8846530da73f09c9ede2e0f) (cherry picked from commit 97c22b122492ab3d2d1fd6237cadc56296ce76d2)
-rw-r--r--bfd/ChangeLog10
-rw-r--r--bfd/elf64-ppc.c27
-rw-r--r--bfd/elf64-ppc.h3
-rw-r--r--ld/ChangeLog7
-rw-r--r--ld/emultempl/ppc64elf.em18
5 files changed, 50 insertions, 15 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 825d5e6d4a..1dabc6ebd6 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,15 @@
2020-09-24 Alan Modra <amodra@gmail.com>
+ PR 26655
+ * 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.
+
+2020-09-24 Alan Modra <amodra@gmail.com>
+
Apply from master
2020-08-13 Alan Modra <amodra@gmail.com>
* elf64-ppc.h (struct ppc64_elf_params): Add no_pcrel_opt.
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index faf4989659..bc1302e6ef 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
@@ -6340,13 +6340,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;
@@ -6354,6 +6354,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)
{
@@ -7694,9 +7697,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;
@@ -7704,7 +7709,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;
@@ -7826,7 +7831,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)
{
@@ -7885,7 +7890,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/ChangeLog b/ld/ChangeLog
index 61067b9720..99fc3536d7 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,12 @@
2020-09-24 Alan Modra <amodra@gmail.com>
+ PR 26655
+ * emultempl/ppc64elf.em (params): Add ppc_edit.
+ (ppc_before_allocation): Split off some edit functions to..
+ (ppc_edit): ..this, new function.
+
+2020-09-24 Alan Modra <amodra@gmail.com>
+
Apply from master
2020-08-13 Alan Modra <amodra@gmail.com>
* emultempl/ppc64elf.em (params): Init new field.
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 <<EOF
static asection *ppc_add_stub_section (const char *, asection *);
static void ppc_layout_sections_again (void);
+static void ppc_edit (void);
static struct ppc64_elf_params params = { NULL,
&ppc_add_stub_section,
&ppc_layout_sections_again,
+ &ppc_edit,
1, -1, -1, 0,
${DEFAULT_PLT_STATIC_CHAIN-0}, -1, 5,
-1, -1, 0, 0, -1, -1, 0};
@@ -294,7 +296,19 @@ ppc_before_allocation (void)
einfo (_("%X%P: inline PLT: %E\n"));
}
- if (ppc64_elf_tls_setup (&link_info)
+ if (!ppc64_elf_tls_setup (&link_info))
+ einfo (_("%X%P: TLS problem %E\n"));
+ }
+
+ gld${EMULATION_NAME}_before_allocation ();
+}
+
+static void
+ppc_edit (void)
+{
+ if (stub_file != NULL)
+ {
+ if (elf_hash_table (&link_info)->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