aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-07-10 10:48:45 +0930
committerAlan Modra <amodra@gmail.com>2020-07-10 11:14:38 +0930
commitd3b10ee787216d304a858246656ed2fdaecdfd93 (patch)
tree8a07c8d1aae6020bbf39bbc27fe4f7d309e95433 /bfd
parentbf7682fdf7cf8e1efd361063e2a3a01eca953958 (diff)
downloadgdb-d3b10ee787216d304a858246656ed2fdaecdfd93.zip
gdb-d3b10ee787216d304a858246656ed2fdaecdfd93.tar.gz
gdb-d3b10ee787216d304a858246656ed2fdaecdfd93.tar.bz2
PowerPC64 ld --no-power10-stubs
Needed for libraries that use ifuncs or other means to support cpu-optimized versions of functions, some power10, some not, and those functions make calls using linkage stubs. bfd/ * elf64-ppc.h (struct ppc64_elf_params): Add power10_stubs. * elf64-ppc.c (struct ppc_link_hash_table): Delete power10_stubs. (ppc64_elf_check_relocs): Adjust setting of power10_stubs. (plt_stub_size, ppc_build_one_stub, ppc_size_one_stub): Adjust uses of power10_stubs. ld/ * emultempl/ppc64elf.em (params): Init new field. (enum ppc64_opt): Add OPTION_POWER10_STUBS and OPTION_NO_POWER10_STUBS. (PARSE_AND_LIST_LONGOPTS): Support --power10-stubs and --no-power10-stubs. (PARSE_AND_LIST_OPTIONS, PARSE_AND_LIST_ARGS_CASES): Likewise. * testsuite/ld-powerpc/callstub-3.d: New test. * testsuite/ld-powerpc/powerpc.exp: Run it.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/elf64-ppc.c26
-rw-r--r--bfd/elf64-ppc.h3
3 files changed, 24 insertions, 14 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index afbccc3..3cb4881 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2020-07-10 Alan Modra <amodra@gmail.com>
+
+ * elf64-ppc.h (struct ppc64_elf_params): Add power10_stubs.
+ * elf64-ppc.c (struct ppc_link_hash_table): Delete
+ power10_stubs.
+ (ppc64_elf_check_relocs): Adjust setting of power10_stubs.
+ (plt_stub_size, ppc_build_one_stub, ppc_size_one_stub): Adjust
+ uses of power10_stubs.
+
2020-07-09 Alan Modra <amodra@gmail.com>
* coff-ppc.c: Delete.
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 8d71084..e54f561 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -3245,9 +3245,6 @@ struct ppc_link_hash_table
/* Whether calls are made via the PLT from NOTOC functions. */
unsigned int notoc_plt:1;
- /* Whether to use power10 instructions in linkage stubs. */
- unsigned int power10_stubs:1;
-
/* Incremented every time we size stubs. */
unsigned int stub_iteration;
@@ -4602,7 +4599,8 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
case R_PPC64_PLT_PCREL34:
case R_PPC64_PLT_PCREL34_NOTOC:
case R_PPC64_PCREL28:
- htab->power10_stubs = 1;
+ if (htab->params->power10_stubs < 0)
+ htab->params->power10_stubs = 1;
break;
default:
break;
@@ -10763,7 +10761,7 @@ plt_stub_size (struct ppc_link_hash_table *htab,
if (stub_entry->stub_type >= ppc_stub_plt_call_notoc)
{
- if (htab->power10_stubs)
+ if (htab->params->power10_stubs > 0)
{
bfd_vma start = (stub_entry->stub_offset
+ stub_entry->group->stub_sec->output_offset
@@ -11604,7 +11602,7 @@ ppc_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
relp = p;
num_rel = 0;
- if (htab->power10_stubs)
+ if (htab->params->power10_stubs > 0)
{
bfd_boolean load = stub_entry->stub_type >= ppc_stub_plt_call_notoc;
p = build_power10_offset (htab->params->stub_bfd, p, off, odd, load);
@@ -11643,7 +11641,7 @@ ppc_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
if (info->emitrelocations)
{
bfd_vma roff = relp - stub_entry->group->stub_sec->contents;
- if (htab->power10_stubs)
+ if (htab->params->power10_stubs > 0)
num_rel += num_relocs_for_power10_offset (off, odd);
else
{
@@ -11653,7 +11651,7 @@ ppc_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
r = get_relocs (stub_entry->group->stub_sec, num_rel);
if (r == NULL)
return FALSE;
- if (htab->power10_stubs)
+ if (htab->params->power10_stubs > 0)
r = emit_relocs_for_power10_offset (info, r, roff, targ, off, odd);
else
r = emit_relocs_for_offset (info, r, roff, targ, off);
@@ -11671,7 +11669,7 @@ ppc_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
}
}
- if (!htab->power10_stubs
+ if (htab->params->power10_stubs <= 0
&& htab->glink_eh_frame != NULL
&& htab->glink_eh_frame->size != 0)
{
@@ -12019,7 +12017,7 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
if (info->emitrelocations)
{
unsigned int num_rel;
- if (htab->power10_stubs)
+ if (htab->params->power10_stubs > 0)
num_rel = num_relocs_for_power10_offset (off, odd);
else
num_rel = num_relocs_for_offset (off - 8);
@@ -12027,7 +12025,7 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
stub_entry->group->stub_sec->flags |= SEC_RELOC;
}
- if (htab->power10_stubs)
+ if (htab->params->power10_stubs > 0)
extra = size_power10_offset (off, odd);
else
extra = size_offset (off - 8);
@@ -12038,7 +12036,7 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
calculated. */
off -= extra;
- if (!htab->power10_stubs)
+ if (htab->params->power10_stubs <= 0)
{
/* After the bcl, lr has been modified so we need to emit
.eh_frame info saying the return address is in r12. */
@@ -12101,7 +12099,7 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
if (info->emitrelocations)
{
unsigned int num_rel;
- if (htab->power10_stubs)
+ if (htab->params->power10_stubs > 0)
num_rel = num_relocs_for_power10_offset (off, odd);
else
num_rel = num_relocs_for_offset (off - 8);
@@ -12111,7 +12109,7 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
size = plt_stub_size (htab, stub_entry, off);
- if (!htab->power10_stubs)
+ if (htab->params->power10_stubs <= 0)
{
/* After the bcl, lr has been modified so we need to emit
.eh_frame info saying the return address is in r12. */
diff --git a/bfd/elf64-ppc.h b/bfd/elf64-ppc.h
index a2ffd4e..547971f 100644
--- a/bfd/elf64-ppc.h
+++ b/bfd/elf64-ppc.h
@@ -54,6 +54,9 @@ struct ppc64_elf_params
/* Set if PLT call stubs for localentry:0 functions should omit r2 save. */
int plt_localentry0;
+ /* Whether to use power10 instructions in linkage stubs. */
+ int power10_stubs;
+
/* Whether to canonicalize .opd so that there are no overlapping
.opd entries. */
int non_overlapping_opd;