Home | History | Annotate | Download | only in bfd

Lines Matching refs:htab

126 #define PLT_ENTRY_SIZE(htab) (htab->opd_abi ? 24 : 8)
129 #define PLT_INITIAL_ENTRY_SIZE(htab) (htab->opd_abi ? 24 : 16)
133 #define STK_TOC(htab) (htab->opd_abi ? 40 : 24)
137 #define STK_LINKER(htab) (htab->opd_abi ? 32 : 8)
4141 struct ppc_link_hash_table *htab;
4143 htab = (struct ppc_link_hash_table *) table;
4144 eh->u.next_dot_sym = htab->dot_syms;
4145 htab->dot_syms = eh;
4177 struct ppc_link_hash_table *htab;
4179 htab = (struct ppc_link_hash_table *) obfd->link.hash;
4180 if (htab->tocsave_htab)
4181 htab_delete (htab->tocsave_htab);
4182 bfd_hash_table_free (&htab->branch_hash_table);
4183 bfd_hash_table_free (&htab->stub_hash_table);
4192 struct ppc_link_hash_table *htab;
4195 htab = bfd_zmalloc (amt);
4196 if (htab == NULL)
4199 if (!_bfd_elf_link_hash_table_init (&htab->elf, abfd, link_hash_newfunc,
4203 free (htab);
4208 if (!bfd_hash_table_init (&htab->stub_hash_table, stub_hash_newfunc,
4216 if (!bfd_hash_table_init (&htab->branch_hash_table, branch_hash_newfunc,
4219 bfd_hash_table_free (&htab->stub_hash_table);
4224 htab->tocsave_htab = htab_try_create (1024,
4228 if (htab->tocsave_htab == NULL)
4233 htab->elf.root.hash_table_free = ppc64_elf_link_hash_table_free;
4239 htab->elf.init_got_refcount.refcount = 0;
4240 htab->elf.init_got_refcount.glist = NULL;
4241 htab->elf.init_plt_refcount.refcount = 0;
4242 htab->elf.init_plt_refcount.glist = NULL;
4243 htab->elf.init_got_offset.offset = 0;
4244 htab->elf.init_got_offset.glist = NULL;
4245 htab->elf.init_plt_offset.offset = 0;
4246 htab->elf.init_plt_offset.glist = NULL;
4248 return &htab->elf.root;
4256 struct ppc_link_hash_table *htab;
4259 htab = ppc_hash_table (info);
4264 htab->sfpr = bfd_make_section_anyway_with_flags (dynobj, ".sfpr",
4266 if (htab->sfpr == NULL
4267 || ! bfd_set_section_alignment (dynobj, htab->sfpr, 2))
4271 htab->glink = bfd_make_section_anyway_with_flags (dynobj, ".glink",
4273 if (htab->glink == NULL
4274 || ! bfd_set_section_alignment (dynobj, htab->glink, 3))
4281 htab->glink_eh_frame = bfd_make_section_anyway_with_flags (dynobj,
4284 if (htab->glink_eh_frame == NULL
4285 || !bfd_set_section_alignment (dynobj, htab->glink_eh_frame, 2))
4290 htab->elf.iplt = bfd_make_section_anyway_with_flags (dynobj, ".iplt", flags);
4291 if (htab->elf.iplt == NULL
4292 || ! bfd_set_section_alignment (dynobj, htab->elf.iplt, 3))
4297 htab->elf.irelplt
4299 if (htab->elf.irelplt == NULL
4300 || ! bfd_set_section_alignment (dynobj, htab->elf.irelplt, 3))
4306 htab->brlt = bfd_make_section_anyway_with_flags (dynobj, ".branch_lt",
4308 if (htab->brlt == NULL
4309 || ! bfd_set_section_alignment (dynobj, htab->brlt, 3))
4317 htab->relbrlt = bfd_make_section_anyway_with_flags (dynobj,
4320 if (htab->relbrlt == NULL
4321 || ! bfd_set_section_alignment (dynobj, htab->relbrlt, 3))
4333 struct ppc_link_hash_table *htab;
4340 htab = ppc_hash_table (info);
4341 if (htab == NULL)
4343 htab->elf.dynobj = params->stub_bfd;
4344 htab->params = params;
4349 return create_linkage_sections (htab->elf.dynobj, info);
4406 struct ppc_link_hash_table *htab)
4416 id_sec = htab->stub_group[input_section->id].link_sec;
4432 stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table,
4451 struct ppc_link_hash_table *htab = ppc_hash_table (info);
4456 link_sec = htab->stub_group[section->id].link_sec;
4457 stub_sec = htab->stub_group[section->id].stub_sec;
4460 stub_sec = htab->stub_group[link_sec->id].stub_sec;
4469 s_name = bfd_alloc (htab->params->stub_bfd, len);
4475 stub_sec = (*htab->params->add_stub_section) (s_name, link_sec);
4478 htab->stub_group[link_sec->id].stub_sec = stub_sec;
4480 htab->stub_group[section->id].stub_sec = stub_sec;
4484 stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, stub_name,
4507 struct ppc_link_hash_table *htab = ppc_hash_table (info);
4511 if (htab == NULL)
4514 if (!htab->elf.sgot
4515 && !_bfd_elf_create_got_section (htab->elf.dynobj, info))
4542 struct ppc_link_hash_table *htab;
4547 htab = ppc_hash_table (info);
4548 if (htab == NULL)
4551 htab->dynbss = bfd_get_linker_section (dynobj, ".dynbss");
4553 htab->relbss = bfd_get_linker_section (dynobj, ".rela.bss");
4555 if (!htab->elf.sgot || !htab->elf.splt || !htab->elf.srelplt || !htab->dynbss
4556 || (!info->shared && !htab->relbss))
4745 lookup_fdh (struct ppc_link_hash_entry *fh, struct ppc_link_hash_table *htab)
4754 elf_link_hash_lookup (&htab->elf, fd_name, FALSE, FALSE, FALSE);
4919 struct ppc_link_hash_table *htab;
4931 htab = ppc_hash_table (info);
4932 if (htab == NULL)
4935 fdh = lookup_fdh (eh, htab);
4967 htab->twiddled_syms = 1;
4980 struct ppc_link_hash_table *htab;
5024 htab = ppc_hash_table (info);
5025 if (htab == NULL)
5039 p = &htab->dot_syms;
5043 if (&eh->elf == htab->elf.hgot)
5045 else if (htab->elf.hgot == NULL
5047 htab->elf.hgot = &eh->elf;
5054 p = &htab->dot_syms;
5063 if (htab->twiddled_syms)
5065 bfd_link_repair_undef_list (&htab->elf.root);
5066 htab->twiddled_syms = 0;
5081 struct ppc_link_hash_table *htab = ppc_hash_table (info);
5083 if (htab == NULL)
5086 htab->dot_syms = NULL;
5206 struct ppc_link_hash_table *htab;
5229 htab = ppc_hash_table (info);
5230 if (htab == NULL)
5233 tga = elf_link_hash_lookup (&htab->elf, "__tls_get_addr",
5235 dottga = elf_link_hash_lookup (&htab->elf, ".__tls_get_addr",
5267 if (h == htab->elf.hgot)
5283 Elf_Internal_Sym *isym = bfd_sym_from_r_symndx (&htab->sym_cache,
5373 htab->do_multi_toc = 1;
5499 htab->do_multi_toc = 1;
5543 isym = bfd_sym_from_r_symndx (&htab->sym_cache,
5666 && lookup_fdh ((struct ppc_link_hash_entry *) h, htab))
5676 isym = bfd_sym_from_r_symndx (&htab->sym_cache,
5773 (sec, htab->elf.dynobj, 3, abfd, /*rela?*/ TRUE);
5790 p = bfd_alloc (htab->elf.dynobj, sizeof *p);
5815 isym = bfd_sym_from_r_symndx (&htab->sym_cache,
5832 p = bfd_alloc (htab->elf.dynobj, sizeof *p);
6181 struct ppc_link_hash_table *htab = ppc_hash_table (info);
6184 if (htab == NULL)
6193 elf_link_hash_lookup (&htab->elf, sym->name, FALSE, FALSE, TRUE);
6364 struct ppc_link_hash_table *htab;
6378 htab = ppc_hash_table (info);
6379 if (htab == NULL)
6548 struct ppc_link_hash_table *htab = ppc_hash_table (info);
6554 if (htab == NULL)
6566 h = elf_link_hash_lookup (&htab->elf, sym, FALSE, FALSE, TRUE);
6571 h->root.u.def.section = htab->sfpr;
6572 h->root.u.def.value = htab->sfpr->size;
6577 if (htab->sfpr->contents == NULL)
6579 htab->sfpr->contents = bfd_alloc (htab->elf.dynobj, SFPR_MAX);
6580 if (htab->sfpr->contents == NULL)
6586 bfd_byte *p = htab->sfpr->contents + htab->sfpr->size;
6588 p = (*parm->write_ent) (htab->elf.dynobj, p, i);
6590 p = (*parm->write_tail) (htab->elf.dynobj, p, i);
6591 htab->sfpr->size = p - htab->sfpr->contents;
6768 struct ppc_link_hash_table *htab;
6779 htab = ppc_hash_table (info);
6780 if (htab == NULL)
6818 fdh = lookup_fdh (fh, htab);
6842 bfd_link_add_undef (&htab->elf.root, &fdh->elf.root);
6901 struct ppc_link_hash_table *htab;
6919 htab = ppc_hash_table (info);
6920 if (htab == NULL)
6924 && htab->elf.hgot != NULL)
6926 _bfd_elf_link_hash_hide_symbol (info, htab->elf.hgot, TRUE);
6929 htab->elf.hgot->type = STT_OBJECT;
6930 htab->elf.hgot->root.type = bfd_link_hash_defined;
6931 htab->elf.hgot->root.u.def.value = 0;
6932 htab->elf.hgot->root.u.def.section = bfd_abs_section_ptr;
6933 htab->elf.hgot->def_regular = 1;
6934 htab->elf.hgot->other = ((htab->elf.hgot->other & ~ELF_ST_VISIBILITY (-1))
6938 if (htab->sfpr == NULL)
6943 htab->sfpr->size = 0;
6944 if (htab->params->save_restore_funcs)
6949 elf_link_hash_traverse (&htab->elf, func_desc_adjust, info);
6951 if (htab->sfpr->size == 0)
6952 htab->sfpr->flags |= SEC_EXCLUDE;
6986 struct ppc_link_hash_table *htab;
6989 htab = ppc_hash_table (info);
6990 if (htab == NULL)
7120 htab->relbss->size += sizeof (Elf64_External_Rela);
7124 s = htab->dynbss;
7147 struct ppc_link_hash_table *htab;
7162 htab = ppc_hash_table (info);
7163 if (htab == NULL)
7167 elf_link_hash_lookup (&htab->elf, p, FALSE, FALSE, FALSE);
7181 elf_link_hash_lookup (&htab->elf, p, FALSE, FALSE, FALSE);
7340 tocsave_find (struct ppc_link_hash_table *htab,
7371 htab_find_slot_with_hash (htab->tocsave_htab, &ent, hash, insert));
7606 struct ppc_link_hash_table *htab;
7608 htab = ppc_hash_table (info);
7609 if (htab == NULL)
7763 add_aux_fields = htab->params->non_overlapping_opd && cnt_16b > 0;
7854 fdh = lookup_fdh ((struct ppc_link_hash_entry *) h, htab);
8000 /* Set htab->tls_get_addr and call the generic ELF tls_setup function. */
8005 struct ppc_link_hash_table *htab;
8007 htab = ppc_hash_table (info);
8008 if (htab == NULL)
8012 htab->opd_abi = 1;
8014 if (htab->params->no_multi_toc)
8015 htab->do_multi_toc = 0;
8016 else if (!htab->do_multi_toc)
8017 htab->params->no_multi_toc = 1;
8019 htab->tls_get_addr = ((struct ppc_link_hash_entry *)
8020 elf_link_hash_lookup (&htab->elf, ".__tls_get_addr",
8023 if (htab->tls_get_addr != NULL)
8024 func_desc_adjust (&htab->tls_get_addr->elf, info);
8025 htab->tls_get_addr_fd = ((struct ppc_link_hash_entry *)
8026 elf_link_hash_lookup (&htab->elf, "__tls_get_addr",
8028 if (!htab->params->no_tls_get_addr_opt)
8032 opt = elf_link_hash_lookup (&htab->elf, ".__tls_get_addr_opt",
8036 opt_fd = elf_link_hash_lookup (&htab->elf, "__tls_get_addr_opt",
8046 tga_fd = &htab->tls_get_addr_fd->elf;
8047 if (htab->elf.dynamic_sections_created
8074 htab->tls_get_addr_fd = (struct ppc_link_hash_entry *) opt_fd;
8075 tga = &htab->tls_get_addr->elf;
8083 htab->tls_get_addr = (struct ppc_link_hash_entry *) opt;
8085 htab->tls_get_addr_fd->oh = htab->tls_get_addr;
8086 htab->tls_get_addr_fd->is_func_descriptor = 1;
8087 if (htab->tls_get_addr != NULL)
8089 htab->tls_get_addr->oh = htab->tls_get_addr_fd;
8090 htab->tls_get_addr->is_func = 1;
8096 htab->params->no_tls_get_addr_opt = TRUE;
8139 struct ppc_link_hash_table *htab;
8146 htab = ppc_hash_table (info);
8147 if (htab == NULL)
8242 value -= htab->elf.tls_sec->vma;
8258 && (h == &htab->tls_get_addr->elf
8259 || h == &htab->tls_get_addr_fd->elf)
8428 htab->tls_get_addr,
8429 htab->tls_get_addr_fd))
8467 if (expecting_tls_get_addr && htab->tls_get_addr != NULL)
8470 for (ent = htab->tls_get_addr->elf.plt.plist;
8484 if (expecting_tls_get_addr && htab->tls_get_addr_fd != NULL)
8487 for (ent = htab->tls_get_addr_fd->elf.plt.plist;
8655 struct ppc_link_hash_table *htab = ppc_hash_table (info);
8657 htab->do_toc_opt = 1;
9319 struct ppc_link_hash_table *htab = ppc_hash_table (info);
9331 dyn = htab->elf.dynamic_sections_created;
9334 htab->elf.irelplt->size += rentsize;
9335 htab->got_reli_size += rentsize;
9374 struct ppc_link_hash_table *htab;
9384 htab = ppc_hash_table (info);
9385 if (htab == NULL)
9388 if ((htab->elf.dynamic_sections_created
9398 if (!htab
9401 s = htab->elf.iplt;
9403 s->size += PLT_ENTRY_SIZE (htab);
9404 s = htab->elf.irelplt;
9410 s = htab->elf.splt;
9412 s->size += PLT_INITIAL_ENTRY_SIZE (htab);
9417 s->size += PLT_ENTRY_SIZE (htab);
9420 s = htab->glink;
9423 if (htab->opd_abi)
9434 s = htab->elf.srelplt;
9498 if (!htab->do_multi_toc)
9510 && htab->elf.dynamic_sections_created)
9523 || (!htab->elf.dynamic_sections_created
9613 sreloc = htab->elf.irelplt;
9628 struct ppc_link_hash_table *htab;
9642 htab = ppc_hash_table (info);
9643 if (htab == NULL)
9646 s = htab->glink;
9689 struct ppc_link_hash_table *htab;
9696 htab = ppc_hash_table (info);
9697 if (htab == NULL)
9700 dynobj = htab->elf.dynobj;
9704 if (htab->elf.dynamic_sections_created)
9750 srel = htab->elf.irelplt;
9796 htab->elf.irelplt->size += rel_size;
9797 htab->got_reli_size += rel_size;
9819 s = htab->elf.iplt;
9821 s->size += PLT_ENTRY_SIZE (htab);
9823 htab->elf.irelplt->size += sizeof (Elf64_External_Rela);
9832 elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, info);
9834 if (htab->glink != NULL)
9835 htab->glink->rawsize = htab->glink->size;
9837 if (!htab->opd_abi && !info->shared)
9838 elf_link_hash_traverse (&htab->elf, size_global_entry_stubs, info);
9851 if (!htab->do_multi_toc && first_tlsld != NULL)
9883 if (s == htab->brlt || s == htab->relbrlt)
9886 else if (s == htab->elf.sgot
9887 || s == htab->elf.splt
9888 || s == htab->elf.iplt
9889 || s == htab->glink
9890 || s == htab->dynbss)
9895 else if (s == htab->glink_eh_frame)
9905 if (s != htab->elf.srelplt)
9955 if (s != NULL && s != htab->elf.sgot)
9982 if (htab->elf.dynamic_sections_created)
10000 if (htab->elf.splt != NULL && htab->elf.splt->size != 0)
10017 tls_opt = (!htab->params->no_tls_get_addr_opt
10018 && htab->tls_get_addr_fd != NULL
10019 && htab
10020 if (tls_opt || !htab->opd_abi)
10036 elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info);
10175 plt_stub_size (struct ppc_link_hash_table *htab,
10186 if (htab->opd_abi)
10189 if (htab->params->plt_static_chain)
10191 if (htab->params->plt_thread_safe)
10193 if (PPC_HA (off + 8 + 8 * htab->params->plt_static_chain) != PPC_HA (off))
10197 && (stub_entry->h == htab->tls_get_addr_fd
10198 || stub_entry->h == htab->tls_get_addr)
10199 && !htab->params->no_tls_get_addr_opt)
10207 plt_stub_pad (struct ppc_link_hash_table *htab,
10211 int stub_align = 1 << htab->params->plt_stub_align;
10212 unsigned stub_size = plt_stub_size (htab, stub_entry, plt_off);
10224 build_plt_stub (struct ppc_link_hash_table *htab,
10228 bfd *obfd = htab->params->stub_bfd;
10229 bfd_boolean plt_load_toc = htab->opd_abi;
10230 bfd_boolean plt_static_chain = htab->params->plt_static_chain;
10231 bfd_boolean plt_thread_safe = htab->params->plt_thread_safe;
10239 && (stub_entry->h == htab->tls_get_addr_fd
10240 || stub_entry->h == htab->tls_get_addr)
10241 && !htab->params->no_tls_get_addr_opt))
10244 bfd_vma pltindex = ((pltoff - PLT_INITIAL_ENTRY_SIZE (htab))
10245 / PLT_ENTRY_SIZE (htab));
10252 + htab->glink->output_offset
10253 + htab->glink->output_section->vma);
10303 bfd_put_32 (obfd, STD_R2_0R1 + STK_TOC (htab), p), p += 4;
10365 bfd_put_32 (obfd, STD_R2_0R1 + STK_TOC (htab), p), p += 4;
10412 build_tls_get_addr_stub (struct ppc_link_hash_table *htab,
10416 bfd *obfd = htab->params->stub_bfd;
10426 bfd_put_32 (obfd, STD_R11_0R1 + STK_LINKER (htab), p), p += 4;
10430 p = build_plt_stub (htab, stub_entry, p, offset, r);
10433 bfd_put_32 (obfd, LD_R11_0R1 + STK_LINKER (htab), p), p += 4;
10434 bfd_put_32 (obfd, LD_R2_0R1 + STK_TOC (htab), p), p += 4;
10475 struct ppc_link_hash_table *htab = ppc_hash_table (info);
10476 bfd_vma r2off = htab->stub_group[stub_entry->target_section->id].toc_off;
10483 if (!htab->opd_abi)
10501 r2off -= htab->stub_group[stub_entry->id_sec->id].toc_off;
10511 struct ppc_link_hash_table *htab;
10523 htab = ppc_hash_table (info);
10524 if (htab == NULL)
10531 htab->stub_count[stub_entry->stub_type - 1] += 1;
10555 htab->stub_error = TRUE;
10558 bfd_put_32 (htab->params->stub_bfd, STD_R2_0R1 + STK_TOC (htab), loc);
10564 bfd_put_32 (htab->params->stub_bfd,
10568 bfd_put_32 (htab->params->stub_bfd, ADDI_R2_R2 | PPC_LO (r2off), loc);
10572 bfd_put_32 (htab->params->stub_bfd, B_DOT | (off & 0x3fffffc), loc);
10579 htab->stub_error = TRUE;
10597 hashes = elf_sym_hashes (htab->params->stub_bfd);
10602 hsize = (htab->stub_globals + 1) * sizeof (*hashes);
10603 hashes = bfd_zalloc (htab->params->stub_bfd, hsize);
10606 elf_sym_hashes (htab->params->stub_bfd) = hashes;
10607 htab->stub_globals = 1;
10609 symndx = htab->stub_globals++;
10631 br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table,
10638 htab->stub_error = TRUE;
10648 bfd_put_64 (htab->brlt->owner, dest,
10649 htab->brlt->contents + br_entry->offset);
10651 if (br_entry->iter == htab->stub_iteration)
10655 if (htab->relbrlt != NULL)
10662 + htab->brlt->output_offset
10663 + htab->brlt->output_section->vma);
10667 rl = htab->relbrlt->contents;
10668 rl += (htab->relbrlt->reloc_count++
10670 bfd_elf64_swap_reloca_out (htab->relbrlt->owner, &rela, rl);
10674 r = get_relocs (htab->brlt, 1);
10682 + htab->brlt->output_offset
10683 + htab->brlt->output_section->vma);
10690 + htab->brlt->output_offset
10691 + htab->brlt->output_section->vma);
10694 - elf_gp (htab->brlt->output_section->owner)
10695 - htab->stub_group[stub_entry->id_sec->id].toc_off);
10703 htab->stub_error = TRUE;
10733 bfd_put_32 (htab->params->stub_bfd,
10736 bfd_put_32 (htab->params->stub_bfd,
10742 bfd_put_32 (htab->params->stub_bfd,
10750 if (r2off == 0 && htab->opd_abi)
10752 htab->stub_error = TRUE;
10756 bfd_put_32 (htab->params->stub_bfd, STD_R2_0R1 + STK_TOC (htab), loc);
10762 bfd_put_32 (htab->params->stub_bfd,
10765 bfd_put_32 (htab->params->stub_bfd,
10769 bfd_put_32 (htab->params->stub_bfd, LD_R12_0R2 | PPC_LO (off), loc);
10775 bfd_put_32 (htab->params->stub_bfd,
10782 bfd_put_32 (htab->params->stub_bfd,
10787 bfd_put_32 (htab->params->stub_bfd, MTCTR_R12, loc);
10789 bfd_put_32 (htab->params->stub_bfd, BCTR, loc);
10804 against htab->top_id in various places. Likely all
10817 plt = htab->elf.splt;
10818 if (!htab->elf.dynamic_sections_created
10821 plt = htab->elf.iplt;
10832 if (htab->opd_abi)
10840 rl = (htab->elf.irelplt->contents
10841 + (htab->elf.irelplt->reloc_count++
10849 - htab->stub_group[stub_entry->id_sec->id].toc_off);
10859 htab->stub_error = TRUE;
10863 if (htab->params->plt_stub_align != 0)
10865 unsigned pad = plt_stub_pad (htab, stub_entry, off);
10877 + (htab->opd_abi
10878 ? 2 + (htab->params->plt_static_chain
10889 && (stub_entry->h == htab->tls_get_addr_fd
10890 || stub_entry->h == htab->tls_get_addr)
10891 && !htab->params->no_tls_get_addr_opt)
10892 p = build_tls_get_addr_stub (htab, stub_entry, loc, off, r);
10894 p = build_plt_stub (htab, stub_entry, loc, off, r);
10905 if (htab->params->emit_stub_syms)
10925 h = elf_link_hash_lookup (&htab->elf, name, TRUE, FALSE, FALSE);
10953 struct ppc_link_hash_table *htab;
10961 htab = ppc_hash_table (info);
10962 if (htab == NULL)
10972 plt = htab->elf.splt;
10973 if (!htab->elf.dynamic_sections_created
10976 plt = htab->elf.iplt;
10980 - htab->stub_group[stub_entry->id_sec->id].toc_off);
10982 size = plt_stub_size (htab, stub_entry, off);
10983 if (htab->params->plt_stub_align)
10984 size += plt_stub_pad (htab, stub_entry, off);
10989 + (htab->opd_abi
10990 ? 2 + (htab->params->plt_static_chain
11019 if (r2off == 0 && htab->opd_abi)
11021 htab->stub_error = TRUE;
11040 br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table,
11047 htab->stub_error = TRUE;
11051 if (br_entry->iter != htab->stub_iteration)
11053 br_entry->iter = htab->stub_iteration;
11054 br_entry->offset = htab->brlt->size;
11055 htab->brlt->size += 8;
11057 if (htab->relbrlt != NULL)
11058 htab->relbrlt->size += sizeof (Elf64_External_Rela);
11061 htab->brlt->reloc_count += 1;
11062 htab->brlt->flags |= SEC_RELOC;
11068 + htab->brlt->output_offset
11069 + htab->brlt->output_section->vma
11070 - elf_gp (htab->brlt->output_section->owner)
11071 - htab->stub_group[stub_entry->id_sec->id].toc_off);
11120 struct ppc_link_hash_table *htab = ppc_hash_table (info);
11122 if (htab == NULL)
11139 htab->top_id = top_id;
11141 htab->stub_group = bfd_zmalloc (amt);
11142 if (htab->stub_group == NULL)
11147 htab->stub_group[id].toc_off = TOC_BASE_OFF;
11160 htab->top_index = top_index;
11163 htab->input_list = input_list;
11175 struct ppc_link_hash_table *htab = ppc_hash_table (info);
11177 htab->toc_curr = ppc64_elf_set_toc (info, info->output_bfd);
11178 htab->toc_bfd = NULL;
11179 htab->toc_first_sec = NULL;
11189 struct ppc_link_hash_table *htab = ppc_hash_table (info);
11192 if (htab == NULL)
11195 if (!htab->second_toc_pass)
11198 bfd_boolean new_bfd = htab->toc_bfd != isec->owner;
11202 htab->toc_bfd = isec->owner;
11203 htab->toc_first_sec = isec;
11207 off = addr - htab->toc_curr;
11213 addr = (htab->toc_first_sec->output_offset
11214 + htab->toc_first_sec->output_section->vma);
11215 htab->toc_curr = addr;
11223 off = htab->toc_curr - elf_gp (isec->output_section->owner);
11240 if (htab->toc_bfd == isec->owner)
11242 htab->toc_bfd = isec->owner;
11244 if (htab->toc_first_sec == NULL
11245 || htab->toc_curr != elf_gp (isec->owner))
11247 htab->toc_curr = elf_gp (isec->owner);
11248 htab->toc_first_sec = isec;
11250 addr = (htab->toc_first_sec->output_offset
11251 + htab->toc_first_sec->output_section->vma);
11296 struct ppc_link_hash_table *htab = ppc_hash_table (info);
11300 htab->multi_toc_needed = htab->toc_curr != elf_gp (info->output_bfd);
11302 if (!htab->do_multi_toc)
11306 elf_link_hash_traverse (&htab->elf, merge_global_got, info);
11338 htab->elf.irelplt->rawsize = htab->elf.irelplt->size;
11339 htab->elf.irelplt->size -= htab->got_reli_size;
11340 htab->got_reli_size = 0;
11405 htab->elf.irelplt->size += rel_size;
11406 htab->got_reli_size += rel_size;
11417 elf_link_hash_traverse (&htab->elf, reallocate_got, info);
11441 done_something = htab->elf.irelplt->rawsize != htab->elf.irelplt->size;
11460 (*htab->params->layout_sections_again) ();
11464 htab->toc_bfd = NULL;
11465 htab->toc_first_sec = NULL;
11466 htab->second_toc_pass = TRUE;
11475 struct ppc_link_hash_table *htab = ppc_hash_table (info);
11479 htab->toc_curr = TOC_BASE_OFF;
11513 struct ppc_link_hash_table *htab;
11522 htab = ppc_hash_table (info);
11523 if (htab == NULL)
11707 struct ppc_link_hash_table *htab = ppc_hash_table (info);
11709 if (htab == NULL)
11713 && isec->output_section->index <= htab->top_index)
11715 asection **list = htab->input_list + isec->output_section->index;
11717 #define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec)
11724 if (htab->multi_toc_needed)
11742 htab->toc_curr = elf_gp (isec->owner);
11745 htab->stub_group[isec->id].toc_off = htab->toc_curr;
11759 struct ppc_link_hash_table *htab = ppc_hash_table (info);
11767 toc_off = htab->stub_group[i->id].toc_off;
11768 else if (toc_off != htab->stub_group[i->id].toc_off)
11776 toc_off = htab->stub_group[i->id].toc_off;
11783 htab->stub_group[i->id].toc_off = toc_off;
11803 group_sections (struct ppc_link_hash_table *htab,
11829 list = htab->input_list + htab->top_index;
11849 curr_toc = htab->stub_group[tail->id].toc_off;
11856 && htab->stub_group[prev->id].toc_off == curr_toc)
11873 htab->stub_group[tail->id].link_sec = curr;
11890 && htab->stub_group[prev->id].toc_off == curr_toc)
11894 htab->stub_group[tail->id].link_sec = curr;
11900 while (list-- != htab->input_list);
11901 free (htab->input_list);
11922 handles cases like htab->brlt which is mapped to its own output
11952 struct ppc_link_hash_table *htab = ppc_hash_table (info);
11954 if (htab == NULL)
11957 if (htab->params->plt_thread_safe == -1 && !info->executable)
11958 htab->params->plt_thread_safe = 1;
11959 if (!htab->opd_abi)
11960 htab->params->plt_thread_safe = 0;
11961 else if (htab->params->plt_thread_safe == -1)
11994 h = elf_link_hash_lookup (&htab->elf, thread_starter[i],
11996 htab->params->plt_thread_safe = h != NULL && h->ref_regular;
11997 if (htab->params->plt_thread_safe)
12001 stubs_always_before_branch = htab->params->group_size < 0;
12002 if (htab->params->group_size < 0)
12003 stub_group_size = -htab->params->group_size;
12005 stub_group_size = htab->params->group_size;
12007 group_sections (htab, stub_group_size, stubs_always_before_branch);
12015 htab->stub_iteration += 1;
12130 && (fdh = lookup_fdh (hash, htab)) != NULL)
12210 && (htab->stub_group[code_sec->id].toc_off
12211 != htab->stub_group[section->id].toc_off)
12223 && (hash == htab->tls_get_addr
12224 || hash == htab->tls_get_addr_fd)
12243 if (!tocsave_find (htab, INSERT,
12251 id_sec = htab->stub_group[section->id].link_sec;
12258 stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table,
12301 htab->stub_globals += 1;
12321 for (stub_sec = htab->params->stub_bfd->sections;
12332 htab->brlt->size = 0;
12333 htab->brlt->reloc_count = 0;
12334 htab->brlt->flags &= ~SEC_RELOC;
12335 if (htab->relbrlt != NULL)
12336 htab->relbrlt->size = 0;
12338 bfd_hash_traverse (&htab->stub_hash_table, ppc_size_one_stub, info);
12341 && htab->glink != NULL && htab->glink->size != 0)
12343 htab->glink->reloc_count = 1;
12344 htab->glink->flags |= SEC_RELOC;
12347 if (htab->glink_eh_frame != NULL
12348 && !bfd_is_abs_section (htab->glink_eh_frame->output_section)
12349 && htab->glink_eh_frame->output_section->size != 0)
12353 for (stub_sec = htab->params->stub_bfd->sections;
12358 if (htab->glink != NULL && htab->glink->size != 0)
12363 align <<= htab->glink_eh_frame->output_section->alignment_power;
12366 htab->glink_eh_frame->rawsize = htab->glink_eh_frame->size;
12367 htab->glink_eh_frame->size = size;
12370 if (htab->params->plt_stub_align != 0)
12371 for (stub_sec = htab->params->stub_bfd->sections;
12376 + (1 << htab->params->plt_stub_align) - 1)
12377 & (-1 << htab->params->plt_stub_align));
12379 for (stub_sec = htab->params->stub_bfd->sections;
12389 && (htab->glink_eh_frame == NULL
12390 || htab->glink_eh_frame->rawsize == htab->glink_eh_frame->size))
12394 (*htab->params->layout_sections_again) ();
12397 if (htab->glink_eh_frame != NULL
12398 && htab->glink_eh_frame->size != 0)
12405 p = bfd_zalloc (htab->glink_eh_frame->owner, htab->glink_eh_frame->size);
12408 htab->glink_eh_frame->contents = p;
12414 bfd_put_32 (htab->elf.dynobj, last_fde_len, p);
12417 for (stub_sec = htab->params->stub_bfd->sections;
12425 bfd_put_32 (htab->elf.dynobj, 20, p);
12428 val = p - htab->glink_eh_frame->contents;
12429 bfd_put_32 (htab->elf.dynobj, val, p);
12434 bfd_put_32 (htab->elf.dynobj, stub_sec->size, p);
12441 if (htab->glink != NULL && htab->glink->size != 0)
12446 bfd_put_32 (htab->elf.dynobj, 20, p);
12449 val = p - htab->glink_eh_frame->contents;
12450 bfd_put_32 (htab->elf.dynobj, val, p);
12455 bfd_put_32 (htab->elf.dynobj, htab->glink->size - 8, p);
12471 size = p - htab->glink_eh_frame->contents;
12473 align <<= htab->glink_eh_frame->output_section->alignment_power;
12476 htab->glink_eh_frame->size = size + pad;
12477 bfd_put_32 (htab->elf.dynobj, last_fde_len + pad, last_fde);
12480 maybe_strip_output (info, htab->brlt);
12481 if (htab->glink_eh_frame != NULL)
12482 maybe_strip_output (info, htab->glink_eh_frame);
12546 struct ppc_link_hash_table *htab = ppc_hash_table (info);
12548 if (htab != NULL)
12550 if (htab->elf.hgot != NULL)
12552 htab->elf.hgot->root.u.def.value = TOC_BASE_OFF;
12553 htab->elf.hgot->root.u.def.section = s;
12574 struct ppc_link_hash_table *htab;
12588 htab = ppc_hash_table (info);
12589 if (htab == NULL)
12592 s = htab->glink;
12602 plt = htab->elf.splt;
12603 if (!htab->elf.dynamic_sections_created
12605 plt = htab->elf.iplt;
12615 htab->stub_error = TRUE;
12618 htab->stub_count[ppc_stub_global_entry - 1] += 1;
12619 if (htab->params->emit_stub_syms)
12628 h = elf_link_hash_lookup (&htab->elf, name, TRUE, FALSE, FALSE);
12667 struct ppc_link_hash_table *htab = ppc_hash_table (info);
12672 if (htab == NULL)
12676 for (stub_sec = htab->params->stub_bfd->sections;
12682 stub_sec->contents = bfd_zalloc (htab->params->stub_bfd, stub_sec->size);
12691 if (htab->glink != NULL && htab->glink->size != 0)
12697 if (htab->params->emit_stub_syms)
12700 h = elf_link_hash_lookup (&htab->elf, "__glink_PLTresolve",
12707 h->root.u.def.section = htab->glink;
12716 plt0 = (htab->elf.splt->output_section->vma
12717 + htab->elf.splt->output_offset
12721 Elf_Internal_Rela *r = get_relocs (htab->glink, 1);
12724 r->r_offset = (htab->glink->output_offset
12725 + htab->glink->output_section->vma);
12729 p = htab->glink->contents;
12730 plt0 -= htab->glink->output_section->vma + htab->glink->output_offset;
12731 bfd_put_64 (htab->glink->owner, plt0, p);
12733 if (htab->opd_abi)
12735 bfd_put_32 (htab->glink->owner, MFLR_R12, p);
12737 bfd_put_32 (htab->glink->owner, BCL_20_31, p);
12739 bfd_put_32 (htab->glink->owner, MFLR_R11, p);
12741 bfd_put_32 (htab->glink->owner, LD_R2_0R11 | (-16 & 0xfffc), p);
12743 bfd_put_32 (htab->glink->owner, MTLR_R12, p);
12745 bfd_put_32 (htab->glink->owner, ADD_R11_R2_R11, p);
12747 bfd_put_32 (htab->glink->owner, LD_R12_0R11, p);
12749 bfd_put_32 (htab->glink->owner, LD_R2_0R11 | 8, p);
12751 bfd_put_32 (htab->glink->owner, MTCTR_R12, p);
12753 bfd_put_32 (htab->glink->owner, LD_R11_0R11 | 16, p);
12758 bfd_put_32 (htab->glink->owner, MFLR_R0, p);
12760 bfd_put_32 (htab->glink->owner, BCL_20_31, p);
12762 bfd_put_32 (htab->glink->owner, MFLR_R11, p);
12764 bfd_put_32 (htab->glink->owner, LD_R2_0R11 | (-16 & 0xfffc), p);
12766 bfd_put_32 (htab->glink->owner, MTLR_R0, p);
12768 bfd_put_32 (htab->glink->owner, SUB_R12_R12_R11, p);
12770 bfd_put_32 (htab->glink->owner, ADD_R11_R2_R11, p);
12772 bfd_put_32 (htab->glink->owner, ADDI_R0_R12 | (-48 & 0xffff), p);
12774 bfd_put_32 (htab->glink->owner, LD_R12_0R11, p);
12776 bfd_put_32 (htab->glink->owner, SRDI_R0_R0_2, p);
12778 bfd_put_32 (htab->glink->owner, MTCTR_R12, p);
12780 bfd_put_32 (htab->glink->owner, LD_R11_0R11 | 8, p);
12783 bfd_put_32 (htab->glink->owner, BCTR, p);
12785 while (p - htab->glink->contents < GLINK_CALL_STUB_SIZE)
12787 bfd_put_32 (htab->glink->owner, NOP, p);
12793 while (p < htab->glink->contents + htab->glink->rawsize)
12795 if (htab->opd_abi)
12799 bfd_put_32 (htab->glink->owner, LI_R0_0 | indx, p);
12804 bfd_put_32 (htab->glink->owner, LIS_R0_0 | PPC_HI (indx), p);
12806 bfd_put_32 (htab->glink->owner, ORI_R0_R0_0 | PPC_LO (indx),
12811 bfd_put_32 (htab->glink->owner,
12812 B_DOT | ((htab->glink->contents - p + 8) & 0x3fffffc), p);
12818 if (htab->glink->size > htab->glink->rawsize)
12819 elf_link_hash_traverse (&htab->elf, build_global_entry_stubs, info);
12822 if (htab->brlt != NULL && htab->brlt->size != 0)
12824 htab->brlt->contents = bfd_zalloc (htab->brlt->owner,
12825 htab->brlt->size);
12826 if (htab->brlt->contents == NULL)
12829 if (htab->relbrlt != NULL && htab->relbrlt->size != 0)
12831 htab->relbrlt->contents = bfd_zalloc (htab->relbrlt->owner,
12832 htab->relbrlt->size);
12833 if (htab->relbrlt->contents == NULL)
12838 bfd_hash_traverse (&htab->stub_hash_table, ppc_build_one_stub, info);
12840 if (htab->relbrlt != NULL)
12841 htab->relbrlt->reloc_count = 0;
12843 if (htab->params->plt_stub_align != 0)
12844 for (stub_sec = htab->params->stub_bfd->sections;
12849 + (1 << htab->params->plt_stub_align) - 1)
12850 & (-1 << htab->params->plt_stub_align));
12852 for (stub_sec = htab->params->stub_bfd->sections;
12866 || (htab->glink_eh_frame != NULL
12867 && htab->glink_eh_frame->rawsize != htab->glink_eh_frame->size))
12869 htab->stub_error = TRUE;
12873 if (htab->stub_error)
12892 htab->stub_count[ppc_stub_long_branch - 1],
12893 htab->stub_count[ppc_stub_long_branch_r2off - 1],
12894 htab->stub_count[ppc_stub_plt_branch - 1],
12895 htab->stub_count[ppc_stub_plt_branch_r2off - 1],
12896 htab->stub_count[ppc_stub_plt_call - 1],
12897 htab->stub_count[ppc_stub_plt_call_r2save - 1],
12898 htab->stub_count[ppc_stub_global_entry - 1]);
12924 struct ppc_link_hash_table *htab = ppc_hash_table (info);
12926 if (htab != NULL)
12927 elf_link_hash_traverse (&htab->elf, undo_symbol_twiddle, info);
12987 struct ppc_link_hash_table *htab;
13006 htab = ppc_hash_table (info);
13007 if (htab == NULL)
13011 if (input_section->owner == htab->params->stub_bfd)
13150 if (h != NULL && &h->elf == htab->elf.hgot)
13153 + htab->stub_group[input_section->id].toc_off);
13404 htab->tls_get_addr,
13405 htab->tls_get_addr_fd))
13441 rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
13549 rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
13624 && h != NULL && &h->elf == htab->elf.hgot
13663 && tocsave_find (htab, NO_INSERT,
13670 STD_R2_0R1 + STK_TOC (htab),
13705 htab);
13733 && (h == htab->tls_get_addr_fd
13734 || h == htab->tls_get_addr)
13735 && !htab->params->no_tls_get_addr_opt)
13741 LD_R2_0R1 + STK_TOC (htab),
13990 bfd_boolean dyn = htab->elf.dynamic_sections_created;
14051 relgot = htab->elf.irelplt;
14106 outrel.r_addend -= htab->elf.tls_sec->vma;
14123 relocation -= htab->elf.tls_sec->vma + DTP_OFFSET;
14144 addend = -(TOCstart + htab->stub_group[input_section->id].toc_off);
14165 if (htab->elf.splt != NULL)
14172 relocation = (htab->elf.splt->output_section->vma
14173 + htab->elf.splt->output_offset
14185 relocation += htab->stub_group[input_section->id].toc_off;
14188 else if (sec != NULL && sec->id <= htab->top_id)
14189 relocation += htab->stub_group[sec->id].toc_off;
14204 addend -= TOCstart + htab->stub_group[input_section->id].toc_off;
14258 addend -= htab->elf.tls_sec->vma + TP_OFFSET;
14278 addend -= htab->elf.tls_sec->vma + DTP_OFFSET;
14293 addend -= htab->elf.tls_sec->vma + TP_OFFSET;
14297 addend -= htab->elf.tls_sec->vma + DTP_OFFSET;
14464 && htab->elf.data_index_section != NULL)
14465 osec = htab->elf.data_index_section;
14467 osec = htab->elf.text_index_section;
14488 sreloc = htab->elf.irelplt;
14585 if (htab->do_toc_opt && relocation + addend + 0x8000 < 0x10000
14601 if (htab->do_toc_opt && relocation + addend + 0x8000 < 0x10000
14868 struct ppc_link_hash_table *htab;
14873 htab = ppc_hash_table (info);
14874 if (htab == NULL)
14882 if (!htab->elf.dynamic_sections_created
14889 rela.r_offset = (htab->elf.iplt->output_section->vma
14890 + htab->elf.iplt->output_offset
14892 if (htab->opd_abi)
14900 loc = (htab->elf.irelplt->contents
14901 + (htab->elf.irelplt->reloc_count++
14906 rela.r_offset = (htab->elf.splt->output_section->vma
14907 + htab->elf.splt->output_offset
14911 loc = (htab->elf.srelplt->contents
14912 + ((ent->plt.offset - PLT_INITIAL_ENTRY_SIZE (htab))
14913 / PLT_ENTRY_SIZE (htab) * sizeof (Elf64_External_Rela)));
14917 if (!htab->opd_abi)
14949 || htab->relbss == NULL)
14957 loc = htab->relbss->contents;
14958 loc += htab->relbss->reloc_count++ * sizeof (Elf64_External_Rela);
14974 struct ppc_link_hash_table *htab = ppc_hash_table (info);
14976 if (rel_sec == htab->elf.irelplt)
14999 struct ppc_link_hash_table *htab;
15003 htab = ppc_hash_table (info);
15004 if (htab == NULL)
15007 dynobj = htab->elf.dynobj;
15010 if (htab->elf.dynamic_sections_created)
15014 if (sdyn == NULL || htab->elf.sgot == NULL)
15032 s = htab->glink;
15049 if (htab->do_multi_toc && htab->multi_toc_needed)
15061 s = htab->elf.splt;
15066 s = htab->elf.srelplt;
15071 dyn.d_un.d_val = htab->elf.srelplt->size;
15077 s = htab->elf.srelplt;
15087 s = htab->elf.srelplt;
15100 if (htab->elf.sgot != NULL && htab->elf.sgot->size != 0)
15106 htab->elf.sgot->contents);
15109 elf_section_data (htab->elf.sgot->output_section)->this_hdr.sh_entsize = 8;
15112 if (htab->elf.splt != NULL && htab->elf.splt->size != 0)
15115 elf_section_data (htab->elf.splt->output_section)->this_hdr.sh_entsize
15116 = PLT_ENTRY_SIZE (htab);
15121 if (htab->brlt != NULL
15122 && htab->brlt->reloc_count != 0
15124 htab->brlt,
15125 elf_section_data (htab->brlt)->rela.hdr,
15126 elf_section_data (htab->brlt)->relocs,
15130 if (htab->glink != NULL
15131 && htab->glink->reloc_count != 0
15133 htab->glink,
15134 elf_section_data (htab->glink)->rela.hdr,
15135 elf_section_data (htab->glink)->relocs,
15139 if (htab->glink_eh_frame != NULL
15140 && htab->glink_eh_frame->size != 0)
15146 p = htab->glink_eh_frame->contents + sizeof (glink_eh_frame_cie);
15147 for (stub_sec = htab->params->stub_bfd->sections;
15159 val -= (htab->glink_eh_frame->output_section->vma
15160 + htab->glink_eh_frame->output_offset
15161 + (p - htab->glink_eh_frame->contents));
15178 if (htab->glink != NULL && htab->glink->size != 0)
15185 val = (htab->glink->output_section->vma
15186 + htab->glink->output_offset
15188 val -= (htab->glink_eh_frame->output_section->vma
15189 + htab->glink_eh_frame->output_offset
15190 + (p - htab->glink_eh_frame->contents));
15195 htab->glink->name);
15208 if (htab->glink_eh_frame->sec_info_type == SEC_INFO_TYPE_EH_FRAME
15210 htab->glink_eh_frame,
15211 htab->glink_eh_frame->contents))