Correct elf64-ppc.c linkage stub comment and formatting fixes

ppc_stub_long_branch_notoc will never need more than a 32-bit offset
for the r12 offset since the stub target must be in range of a
branch instruction.

	* elf64-ppc.c: Correct ppc_stub_long_branch_notoc example.
	Formatting.
This commit is contained in:
Alan Modra
2018-08-15 11:11:59 +09:30
parent 3b7b80752f
commit 2cdcc33021
2 changed files with 94 additions and 77 deletions

View File

@ -1,3 +1,8 @@
2018-08-16 Alan Modra <amodra@gmail.com>
* elf64-ppc.c: Correct ppc_stub_long_branch_notoc example.
Formatting.
2018-08-12 H.J. Lu <hongjiu.lu@intel.com> 2018-08-12 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/23494 PR binutils/23494

View File

@ -2302,7 +2302,8 @@ ppc64_elf_reloc_type_lookup (bfd *abfd,
{ {
default: default:
/* xgettext:c-format */ /* xgettext:c-format */
_bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, (int) code); _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd,
(int) code);
bfd_set_error (bfd_error_bad_value); bfd_set_error (bfd_error_bad_value);
return NULL; return NULL;
@ -2558,7 +2559,6 @@ ppc64_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
&& strcasecmp (ppc64_elf_howto_raw[i].name, r_name) == 0) && strcasecmp (ppc64_elf_howto_raw[i].name, r_name) == 0)
return &ppc64_elf_howto_raw[i]; return &ppc64_elf_howto_raw[i];
return NULL; return NULL;
} }
@ -2950,7 +2950,8 @@ struct ppc64_elf_obj_tdata
sections means we potentially need one of these for each input bfd. */ sections means we potentially need one of these for each input bfd. */
struct got_entry tlsld_got; struct got_entry tlsld_got;
union { union
{
/* A copy of relocs before they are modified for --emit-relocs. */ /* A copy of relocs before they are modified for --emit-relocs. */
Elf_Internal_Rela *relocs; Elf_Internal_Rela *relocs;
@ -3226,16 +3227,16 @@ compare_symbols (const void *ap, const void *bp)
} }
/* then other code symbols. */ /* then other code symbols. */
if ((a->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) if (((a->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL))
== (SEC_CODE | SEC_ALLOC) == (SEC_CODE | SEC_ALLOC))
&& (b->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) && ((b->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL))
!= (SEC_CODE | SEC_ALLOC)) != (SEC_CODE | SEC_ALLOC)))
return -1; return -1;
if ((a->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) if (((a->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL))
!= (SEC_CODE | SEC_ALLOC) != (SEC_CODE | SEC_ALLOC))
&& (b->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) && ((b->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL))
== (SEC_CODE | SEC_ALLOC)) == (SEC_CODE | SEC_ALLOC)))
return 1; return 1;
if (synthetic_relocatable) if (synthetic_relocatable)
@ -3451,7 +3452,8 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
opdsymend = i; opdsymend = i;
for (; i < symcount; ++i) for (; i < symcount; ++i)
if ((syms[i]->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) if (((syms[i]->section->flags
& (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)))
!= (SEC_CODE | SEC_ALLOC)) != (SEC_CODE | SEC_ALLOC))
break; break;
symcount = i; symcount = i;
@ -3650,7 +3652,8 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
insn ^= B_DOT; insn ^= B_DOT;
if ((insn & ~0x3fffffc) == 0) if ((insn & ~0x3fffffc) == 0)
{ {
resolv_vma = glink_vma + off + (insn ^ 0x2000000) - 0x2000000; resolv_vma
= glink_vma + off + (insn ^ 0x2000000) - 0x2000000;
break; break;
} }
off += 4; off += 4;
@ -3760,7 +3763,8 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
s->section = glink; s->section = glink;
s->value = resolv_vma - glink->vma; s->value = resolv_vma - glink->vma;
s->name = names; s->name = names;
memcpy (names, "__glink_PLTresolve", sizeof ("__glink_PLTresolve")); memcpy (names, "__glink_PLTresolve",
sizeof ("__glink_PLTresolve"));
names += sizeof ("__glink_PLTresolve"); names += sizeof ("__glink_PLTresolve");
s++; s++;
count++; count++;
@ -4021,12 +4025,8 @@ must_be_dyn_reloc (struct bfd_link_info *info,
. 1: . 1:
. mflr %r11 . mflr %r11
. mtlr %r12 . mtlr %r12
. lis %r12,xxx-1b@highest . addis %r12,%r11,dest-1b@ha
. ori %r12,xxx-1b@higher . addi %r12,%r12,dest-1b@l
. sldi %r12,%r12,32
. oris %r12,%r12,xxx-1b@hi
. ori %r12,%r12,xxx-1b@l
. add %r12,%r11,%r12
. b dest . b dest
ppc_stub_plt_branch_notoc: ppc_stub_plt_branch_notoc:
@ -4083,7 +4083,8 @@ must_be_dyn_reloc (struct bfd_link_info *info,
hierarchy of long branch and plt branch stubs for local call hierarchy of long branch and plt branch stubs for local call
linkage. */ linkage. */
enum ppc_stub_type { enum ppc_stub_type
{
ppc_stub_none, ppc_stub_none,
ppc_stub_long_branch, ppc_stub_long_branch,
ppc_stub_long_branch_r2off, ppc_stub_long_branch_r2off,
@ -4124,8 +4125,8 @@ struct map_stub
unsigned int eh_base; unsigned int eh_base;
}; };
struct ppc_stub_hash_entry { struct ppc_stub_hash_entry
{
/* Base hash table entry structure. */ /* Base hash table entry structure. */
struct bfd_hash_entry root; struct bfd_hash_entry root;
@ -4153,8 +4154,8 @@ struct ppc_stub_hash_entry {
unsigned char other; unsigned char other;
}; };
struct ppc_branch_hash_entry { struct ppc_branch_hash_entry
{
/* Base hash table entry structure. */ /* Base hash table entry structure. */
struct bfd_hash_entry root; struct bfd_hash_entry root;
@ -4184,7 +4185,8 @@ struct ppc_link_hash_entry
{ {
struct elf_link_hash_entry elf; struct elf_link_hash_entry elf;
union { union
{
/* A pointer to the most recently used stub hash entry against this /* A pointer to the most recently used stub hash entry against this
symbol. */ symbol. */
struct ppc_stub_hash_entry *stub_cache; struct ppc_stub_hash_entry *stub_cache;
@ -4509,7 +4511,8 @@ link_hash_newfunc (struct bfd_hash_entry *entry,
return entry; return entry;
} }
struct tocsave_entry { struct tocsave_entry
{
asection *sec; asection *sec;
bfd_vma offset; bfd_vma offset;
}; };
@ -6702,7 +6705,8 @@ ppc64_elf_gc_mark_dynamic_ref (struct elf_link_hash_entry *h, void *inf)
|| info->export_dynamic || info->export_dynamic
|| (eh->elf.dynamic || (eh->elf.dynamic
&& d != NULL && d != NULL
&& (*d->match) (&d->head, NULL, eh->elf.root.root.string))) && (*d->match) (&d->head, NULL,
eh->elf.root.root.string)))
&& (eh->elf.versioned >= versioned && (eh->elf.versioned >= versioned
|| !bfd_hide_sym_by_version (info->version_info, || !bfd_hide_sym_by_version (info->version_info,
eh->elf.root.root.string))))) eh->elf.root.root.string)))))
@ -6908,7 +6912,8 @@ sfpr_define (struct bfd_link_info *info,
writing = TRUE; writing = TRUE;
if (htab->sfpr->contents == NULL) if (htab->sfpr->contents == NULL)
{ {
htab->sfpr->contents = bfd_alloc (htab->elf.dynobj, SFPR_MAX); htab->sfpr->contents
= bfd_alloc (htab->elf.dynobj, SFPR_MAX);
if (htab->sfpr->contents == NULL) if (htab->sfpr->contents == NULL)
return FALSE; return FALSE;
} }
@ -7268,8 +7273,8 @@ ppc64_elf_func_desc_adjust (bfd *obfd ATTRIBUTE_UNUSED,
htab->elf.hgot->root.linker_def = 1; htab->elf.hgot->root.linker_def = 1;
} }
htab->elf.hgot->type = STT_OBJECT; htab->elf.hgot->type = STT_OBJECT;
htab->elf.hgot->other = ((htab->elf.hgot->other & ~ELF_ST_VISIBILITY (-1)) htab->elf.hgot->other
| STV_HIDDEN); = (htab->elf.hgot->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
} }
if (htab->need_func_desc_adj) if (htab->need_func_desc_adj)
@ -7315,7 +7320,8 @@ alias_readonly_dynrelocs (struct elf_link_hash_entry *h)
if (readonly_dynrelocs (&eh->elf)) if (readonly_dynrelocs (&eh->elf))
return TRUE; return TRUE;
eh = (struct ppc_link_hash_entry *) eh->elf.u.alias; eh = (struct ppc_link_hash_entry *) eh->elf.u.alias;
} while (eh != NULL && &eh->elf != h); }
while (eh != NULL && &eh->elf != h);
return FALSE; return FALSE;
} }
@ -8525,7 +8531,7 @@ ppc64_elf_inline_plt (struct bfd_link_info *info)
if (elf_section_data (sec)->relocs != relstart) if (elf_section_data (sec)->relocs != relstart)
free (relstart); free (relstart);
if (local_syms != NULL if (local_syms != NULL
&& symtab_hdr->contents != (unsigned char *) local_syms) && symtab_hdr->contents != (bfd_byte *) local_syms)
free (local_syms); free (local_syms);
return FALSE; return FALSE;
} }
@ -8661,7 +8667,8 @@ ppc64_elf_tls_setup (struct bfd_link_info *info)
if (!bfd_elf_link_record_dynamic_symbol (info, opt_fd)) if (!bfd_elf_link_record_dynamic_symbol (info, opt_fd))
return NULL; return NULL;
} }
htab->tls_get_addr_fd = (struct ppc_link_hash_entry *) opt_fd; htab->tls_get_addr_fd
= (struct ppc_link_hash_entry *) opt_fd;
tga = &htab->tls_get_addr->elf; tga = &htab->tls_get_addr->elf;
if (opt != NULL && tga != NULL) if (opt != NULL && tga != NULL)
{ {
@ -8920,7 +8927,8 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info)
&& is_plt_seq_reloc (ELF64_R_TYPE (rel[1].r_info))) && is_plt_seq_reloc (ELF64_R_TYPE (rel[1].r_info)))
{ {
if (pass != 0 if (pass != 0
&& ELF64_R_TYPE (rel[1].r_info) != R_PPC64_PLTSEQ) && (ELF64_R_TYPE (rel[1].r_info)
!= R_PPC64_PLTSEQ))
{ {
r_symndx = ELF64_R_SYM (rel[1].r_info); r_symndx = ELF64_R_SYM (rel[1].r_info);
if (!get_sym_h (&h, NULL, NULL, NULL, &locsyms, if (!get_sym_h (&h, NULL, NULL, NULL, &locsyms,
@ -8957,7 +8965,8 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info)
case of R_PPC64_TLS, and after checking for case of R_PPC64_TLS, and after checking for
tls_get_addr for the TOC16 relocs. */ tls_get_addr for the TOC16 relocs. */
if (toc_ref == NULL) if (toc_ref == NULL)
toc_ref = bfd_zmalloc (toc->output_section->rawsize / 8); toc_ref
= bfd_zmalloc (toc->output_section->rawsize / 8);
if (toc_ref == NULL) if (toc_ref == NULL)
goto err_free_rel; goto err_free_rel;
@ -10374,8 +10383,8 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *inf)
struct bfd_link_info *info = (struct bfd_link_info *) inf; struct bfd_link_info *info = (struct bfd_link_info *) inf;
info->flags |= DF_TEXTREL; info->flags |= DF_TEXTREL;
info->callbacks->minfo info->callbacks->minfo (_("%pB: dynamic relocation against `%pT'"
(_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), " in read-only section `%pA'\n"),
sec->owner, h->root.root.string, sec); sec->owner, h->root.root.string, sec);
/* Not an error, just cut short the traversal. */ /* Not an error, just cut short the traversal. */
@ -11414,7 +11423,8 @@ get_r2off (struct bfd_link_info *info,
if (strcmp (opd->name, ".opd") != 0 if (strcmp (opd->name, ".opd") != 0
|| opd->reloc_count != 0) || opd->reloc_count != 0)
{ {
info->callbacks->einfo (_("%P: cannot find opd entry toc for `%pT'\n"), info->callbacks->einfo
(_("%P: cannot find opd entry toc for `%pT'\n"),
stub_entry->h->elf.root.root.string); stub_entry->h->elf.root.root.string);
bfd_set_error (bfd_error_bad_value); bfd_set_error (bfd_error_bad_value);
return (bfd_vma) -1; return (bfd_vma) -1;
@ -12988,7 +12998,8 @@ group_sections (struct bfd_link_info *info,
&& ((total += tail->output_offset - prev->output_offset) && ((total += tail->output_offset - prev->output_offset)
< (ppc64_elf_section_data (prev) != NULL < (ppc64_elf_section_data (prev) != NULL
&& ppc64_elf_section_data (prev)->has_14bit_branch && ppc64_elf_section_data (prev)->has_14bit_branch
? (group_size = stub_group_size >> 10) : group_size)) ? (group_size = stub_group_size >> 10)
: group_size))
&& htab->sec_info[prev->id].toc_off == curr_toc) && htab->sec_info[prev->id].toc_off == curr_toc)
{ {
tail = prev; tail = prev;
@ -16870,7 +16881,8 @@ ppc64_elf_finish_dynamic_sections (bfd *output_bfd,
htab->elf.sgot->contents); htab->elf.sgot->contents);
/* Set .got entry size. */ /* Set .got entry size. */
elf_section_data (htab->elf.sgot->output_section)->this_hdr.sh_entsize = 8; elf_section_data (htab->elf.sgot->output_section)->this_hdr.sh_entsize
= 8;
} }
if (htab->elf.splt != NULL && htab->elf.splt->size != 0 if (htab->elf.splt != NULL && htab->elf.splt->size != 0