diff options
author | Alan Modra <amodra@gmail.com> | 2018-08-15 11:11:59 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2018-08-16 22:57:00 +0930 |
commit | 2cdcc33021214e77c2c185aa78ad4f9ae1b9e565 (patch) | |
tree | a49f184aed5a1f0d784e3fddba1b40296e934613 | |
parent | 3b7b80752fdb3544b5d822f477dc5a9863959393 (diff) | |
download | binutils-2cdcc33021214e77c2c185aa78ad4f9ae1b9e565.zip binutils-2cdcc33021214e77c2c185aa78ad4f9ae1b9e565.tar.gz binutils-2cdcc33021214e77c2c185aa78ad4f9ae1b9e565.tar.bz2 |
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.
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/elf64-ppc.c | 166 |
2 files changed, 94 insertions, 77 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 3169eb9..4c7468f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -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> PR binutils/23494 diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index c9ac8e9..be1113d 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -2302,7 +2302,8 @@ ppc64_elf_reloc_type_lookup (bfd *abfd, { default: /* 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); 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) return &ppc64_elf_howto_raw[i]; - return NULL; } @@ -2592,7 +2592,7 @@ ppc64_elf_info_to_howto (bfd *abfd, arelent *cache_ptr, bfd_set_error (bfd_error_bad_value); return FALSE; } - + return TRUE; } @@ -2913,11 +2913,11 @@ struct got_entry /* Reference count until size_dynamic_sections, GOT offset thereafter. */ union - { - bfd_signed_vma refcount; - bfd_vma offset; - struct got_entry *ent; - } got; + { + bfd_signed_vma refcount; + bfd_vma offset; + struct got_entry *ent; + } got; }; /* The same for PLT. */ @@ -2928,10 +2928,10 @@ struct plt_entry bfd_vma addend; union - { - bfd_signed_vma refcount; - bfd_vma offset; - } plt; + { + bfd_signed_vma refcount; + bfd_vma offset; + } plt; }; struct ppc64_elf_obj_tdata @@ -2950,7 +2950,8 @@ struct ppc64_elf_obj_tdata sections means we potentially need one of these for each input bfd. */ struct got_entry tlsld_got; - union { + union + { /* A copy of relocs before they are modified for --emit-relocs. */ Elf_Internal_Rela *relocs; @@ -3110,7 +3111,7 @@ ppc64_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type, /* Add extra PPC sections. */ -static const struct bfd_elf_special_section ppc64_elf_special_sections[]= +static const struct bfd_elf_special_section ppc64_elf_special_sections[] = { { STRING_COMMA_LEN (".plt"), 0, SHT_NOBITS, 0 }, { STRING_COMMA_LEN (".sbss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, @@ -3205,8 +3206,8 @@ static asection *synthetic_opd; static int compare_symbols (const void *ap, const void *bp) { - const asymbol *a = * (const asymbol **) ap; - const asymbol *b = * (const asymbol **) bp; + const asymbol *a = *(const asymbol **) ap; + const asymbol *b = *(const asymbol **) bp; /* Section symbols first. */ if ((a->flags & BSF_SECTION_SYM) && !(b->flags & BSF_SECTION_SYM)) @@ -3226,16 +3227,16 @@ compare_symbols (const void *ap, const void *bp) } /* then other code symbols. */ - if ((a->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) - == (SEC_CODE | SEC_ALLOC) - && (b->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) - != (SEC_CODE | SEC_ALLOC)) + if (((a->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) + == (SEC_CODE | SEC_ALLOC)) + && ((b->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) + != (SEC_CODE | SEC_ALLOC))) return -1; - if ((a->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) - != (SEC_CODE | SEC_ALLOC) - && (b->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) - == (SEC_CODE | SEC_ALLOC)) + if (((a->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) + != (SEC_CODE | SEC_ALLOC)) + && ((b->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) + == (SEC_CODE | SEC_ALLOC))) return 1; if (synthetic_relocatable) @@ -3451,7 +3452,8 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd, opdsymend = 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)) break; symcount = i; @@ -3650,7 +3652,8 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd, insn ^= B_DOT; if ((insn & ~0x3fffffc) == 0) { - resolv_vma = glink_vma + off + (insn ^ 0x2000000) - 0x2000000; + resolv_vma + = glink_vma + off + (insn ^ 0x2000000) - 0x2000000; break; } off += 4; @@ -3665,7 +3668,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd, if (relplt != NULL) { slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table; - if (! (*slurp_relocs) (abfd, relplt, dyn_syms, TRUE)) + if (!(*slurp_relocs) (abfd, relplt, dyn_syms, TRUE)) goto free_contents_and_exit_err; plt_count = relplt->size / sizeof (Elf64_External_Rela); @@ -3760,7 +3763,8 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd, s->section = glink; s->value = resolv_vma - glink->vma; s->name = names; - memcpy (names, "__glink_PLTresolve", sizeof ("__glink_PLTresolve")); + memcpy (names, "__glink_PLTresolve", + sizeof ("__glink_PLTresolve")); names += sizeof ("__glink_PLTresolve"); s++; count++; @@ -4021,12 +4025,8 @@ must_be_dyn_reloc (struct bfd_link_info *info, . 1: . mflr %r11 . mtlr %r12 - . lis %r12,xxx-1b@highest - . ori %r12,xxx-1b@higher - . sldi %r12,%r12,32 - . oris %r12,%r12,xxx-1b@hi - . ori %r12,%r12,xxx-1b@l - . add %r12,%r11,%r12 + . addis %r12,%r11,dest-1b@ha + . addi %r12,%r12,dest-1b@l . b dest 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 linkage. */ -enum ppc_stub_type { +enum ppc_stub_type +{ ppc_stub_none, ppc_stub_long_branch, ppc_stub_long_branch_r2off, @@ -4124,8 +4125,8 @@ struct map_stub unsigned int eh_base; }; -struct ppc_stub_hash_entry { - +struct ppc_stub_hash_entry +{ /* Base hash table entry structure. */ struct bfd_hash_entry root; @@ -4153,8 +4154,8 @@ struct ppc_stub_hash_entry { unsigned char other; }; -struct ppc_branch_hash_entry { - +struct ppc_branch_hash_entry +{ /* Base hash table entry structure. */ struct bfd_hash_entry root; @@ -4184,7 +4185,8 @@ struct ppc_link_hash_entry { struct elf_link_hash_entry elf; - union { + union + { /* A pointer to the most recently used stub hash entry against this symbol. */ struct ppc_stub_hash_entry *stub_cache; @@ -4509,7 +4511,8 @@ link_hash_newfunc (struct bfd_hash_entry *entry, return entry; } -struct tocsave_entry { +struct tocsave_entry +{ asection *sec; bfd_vma offset; }; @@ -4626,7 +4629,7 @@ create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) htab->sfpr = bfd_make_section_anyway_with_flags (dynobj, ".sfpr", flags); if (htab->sfpr == NULL - || ! bfd_set_section_alignment (dynobj, htab->sfpr, 2)) + || !bfd_set_section_alignment (dynobj, htab->sfpr, 2)) return FALSE; } @@ -4637,7 +4640,7 @@ create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) htab->glink = bfd_make_section_anyway_with_flags (dynobj, ".glink", flags); if (htab->glink == NULL - || ! bfd_set_section_alignment (dynobj, htab->glink, 3)) + || !bfd_set_section_alignment (dynobj, htab->glink, 3)) return FALSE; /* The part of .glink used by global entry stubs, separate so that @@ -4645,7 +4648,7 @@ create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) htab->global_entry = bfd_make_section_anyway_with_flags (dynobj, ".glink", flags); if (htab->global_entry == NULL - || ! bfd_set_section_alignment (dynobj, htab->global_entry, 2)) + || !bfd_set_section_alignment (dynobj, htab->global_entry, 2)) return FALSE; if (!info->no_ld_generated_unwind_info) @@ -4663,7 +4666,7 @@ create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) flags = SEC_ALLOC | SEC_LINKER_CREATED; htab->elf.iplt = bfd_make_section_anyway_with_flags (dynobj, ".iplt", flags); if (htab->elf.iplt == NULL - || ! bfd_set_section_alignment (dynobj, htab->elf.iplt, 3)) + || !bfd_set_section_alignment (dynobj, htab->elf.iplt, 3)) return FALSE; flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY @@ -4671,7 +4674,7 @@ create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) htab->elf.irelplt = bfd_make_section_anyway_with_flags (dynobj, ".rela.iplt", flags); if (htab->elf.irelplt == NULL - || ! bfd_set_section_alignment (dynobj, htab->elf.irelplt, 3)) + || !bfd_set_section_alignment (dynobj, htab->elf.irelplt, 3)) return FALSE; /* Create branch lookup table for plt_branch stubs. */ @@ -4680,7 +4683,7 @@ create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) htab->brlt = bfd_make_section_anyway_with_flags (dynobj, ".branch_lt", flags); if (htab->brlt == NULL - || ! bfd_set_section_alignment (dynobj, htab->brlt, 3)) + || !bfd_set_section_alignment (dynobj, htab->brlt, 3)) return FALSE; /* Local plt entries, put in .branch_lt but a separate section for @@ -4688,7 +4691,7 @@ create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) htab->pltlocal = bfd_make_section_anyway_with_flags (dynobj, ".branch_lt", flags); if (htab->pltlocal == NULL - || ! bfd_set_section_alignment (dynobj, htab->pltlocal, 3)) + || !bfd_set_section_alignment (dynobj, htab->pltlocal, 3)) return FALSE; if (!bfd_link_pic (info)) @@ -4699,13 +4702,13 @@ create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) htab->relbrlt = bfd_make_section_anyway_with_flags (dynobj, ".rela.branch_lt", flags); if (htab->relbrlt == NULL - || ! bfd_set_section_alignment (dynobj, htab->relbrlt, 3)) + || !bfd_set_section_alignment (dynobj, htab->relbrlt, 3)) return FALSE; htab->relpltlocal = bfd_make_section_anyway_with_flags (dynobj, ".rela.branch_lt", flags); if (htab->relpltlocal == NULL - || ! bfd_set_section_alignment (dynobj, htab->relpltlocal, 3)) + || !bfd_set_section_alignment (dynobj, htab->relpltlocal, 3)) return FALSE; return TRUE; @@ -4907,7 +4910,7 @@ create_got_section (bfd *abfd, struct bfd_link_info *info) relgot = bfd_make_section_anyway_with_flags (abfd, ".rela.got", flags | SEC_READONLY); if (!relgot - || ! bfd_set_section_alignment (abfd, relgot, 3)) + || !bfd_set_section_alignment (abfd, relgot, 3)) return FALSE; ppc64_elf_tdata (abfd)->got = got; @@ -5340,7 +5343,7 @@ add_symbol_adjust (struct ppc_link_hash_entry *eh, struct bfd_link_info *info) && (eh->elf.ref_regular || eh->elf.def_regular)) { - if (! bfd_elf_link_record_dynamic_symbol (info, &fdh->elf)) + if (!bfd_elf_link_record_dynamic_symbol (info, &fdh->elf)) return FALSE; } } @@ -6702,7 +6705,8 @@ ppc64_elf_gc_mark_dynamic_ref (struct elf_link_hash_entry *h, void *inf) || info->export_dynamic || (eh->elf.dynamic && 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 || !bfd_hide_sym_by_version (info->version_info, eh->elf.root.root.string))))) @@ -6830,8 +6834,8 @@ struct sfpr_def_parms { const char name[12]; unsigned char lo, hi; - bfd_byte * (*write_ent) (bfd *, bfd_byte *, int); - bfd_byte * (*write_tail) (bfd *, bfd_byte *, int); + bfd_byte *(*write_ent) (bfd *, bfd_byte *, int); + bfd_byte *(*write_tail) (bfd *, bfd_byte *, int); }; /* Auto-generate _save*, _rest* functions in .sfpr. @@ -6908,7 +6912,8 @@ sfpr_define (struct bfd_link_info *info, writing = TRUE; 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) 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->type = STT_OBJECT; - htab->elf.hgot->other = ((htab->elf.hgot->other & ~ELF_ST_VISIBILITY (-1)) - | STV_HIDDEN); + htab->elf.hgot->other + = (htab->elf.hgot->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN; } if (htab->need_func_desc_adj) @@ -7315,7 +7320,8 @@ alias_readonly_dynrelocs (struct elf_link_hash_entry *h) if (readonly_dynrelocs (&eh->elf)) return TRUE; eh = (struct ppc_link_hash_entry *) eh->elf.u.alias; - } while (eh != NULL && &eh->elf != h); + } + while (eh != NULL && &eh->elf != h); return FALSE; } @@ -8394,8 +8400,8 @@ ppc64_elf_edit_opd (struct bfd_link_info *info) if (p == NULL) return FALSE; - if (! bfd_get_section_contents (need_pad->owner, need_pad, - p, 0, need_pad->size)) + if (!bfd_get_section_contents (need_pad->owner, need_pad, + p, 0, need_pad->size)) return FALSE; need_pad->contents = p; @@ -8525,7 +8531,7 @@ ppc64_elf_inline_plt (struct bfd_link_info *info) if (elf_section_data (sec)->relocs != relstart) free (relstart); if (local_syms != NULL - && symtab_hdr->contents != (unsigned char *) local_syms) + && symtab_hdr->contents != (bfd_byte *) local_syms) free (local_syms); 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)) 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; if (opt != NULL && tga != NULL) { @@ -8920,11 +8927,12 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info) && is_plt_seq_reloc (ELF64_R_TYPE (rel[1].r_info))) { 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); if (!get_sym_h (&h, NULL, NULL, NULL, &locsyms, - r_symndx, ibfd)) + r_symndx, ibfd)) goto err_free_rel; if (h != NULL) { @@ -8957,7 +8965,8 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info) case of R_PPC64_TLS, and after checking for tls_get_addr for the TOC16 relocs. */ 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) goto err_free_rel; @@ -10374,9 +10383,9 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *inf) struct bfd_link_info *info = (struct bfd_link_info *) inf; info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); + info->callbacks->minfo (_("%pB: dynamic relocation against `%pT'" + " in read-only section `%pA'\n"), + sec->owner, h->root.root.string, sec); /* Not an error, just cut short the traversal. */ return FALSE; @@ -11414,8 +11423,9 @@ get_r2off (struct bfd_link_info *info, if (strcmp (opd->name, ".opd") != 0 || opd->reloc_count != 0) { - info->callbacks->einfo (_("%P: cannot find opd entry toc for `%pT'\n"), - stub_entry->h->elf.root.root.string); + info->callbacks->einfo + (_("%P: cannot find opd entry toc for `%pT'\n"), + stub_entry->h->elf.root.root.string); bfd_set_error (bfd_error_bad_value); return (bfd_vma) -1; } @@ -12988,7 +12998,8 @@ group_sections (struct bfd_link_info *info, && ((total += tail->output_offset - prev->output_offset) < (ppc64_elf_section_data (prev) != NULL && 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) { tail = prev; @@ -15848,9 +15859,9 @@ ppc64_elf_relocate_section (bfd *output_bfd, + plt->output_offset + ent->plt.offset); if (r_type == R_PPC64_PLT16_HA - || r_type ==R_PPC64_PLT16_HI - || r_type ==R_PPC64_PLT16_LO - || r_type ==R_PPC64_PLT16_LO_DS) + || r_type == R_PPC64_PLT16_HI + || r_type == R_PPC64_PLT16_LO + || r_type == R_PPC64_PLT16_LO_DS) { got = (elf_gp (output_bfd) + htab->sec_info[input_section->id].toc_off); @@ -16189,7 +16200,7 @@ ppc64_elf_relocate_section (bfd *output_bfd, be computed at runtime, so there's no need to do anything now. However, for the sake of prelink ensure that the section contents are a known value. */ - if (! relocate) + if (!relocate) { unresolved_reloc = FALSE; /* The value chosen here is quite arbitrary as ld.so @@ -16870,7 +16881,8 @@ ppc64_elf_finish_dynamic_sections (bfd *output_bfd, htab->elf.sgot->contents); /* 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 |