+ if (!info->shared)
+ {
+ if (!add_dynamic_entry (DT_DEBUG, 0))
+ return false;
+ }
+
+ if (htab->splt != NULL && htab->splt->_raw_size != 0)
+ {
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0)
+ || !add_dynamic_entry (DT_PPC64_GLINK, 0))
+ return false;
+ }
+
+ if (NO_OPD_RELOCS)
+ {
+ if (!add_dynamic_entry (DT_PPC64_OPD, 0)
+ || !add_dynamic_entry (DT_PPC64_OPDSZ, 0))
+ return false;
+ }
+
+ if (relocs)
+ {
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
+ return false;
+
+ /* If any dynamic relocs apply to a read-only section,
+ then we need a DT_TEXTREL entry. */
+ if ((info->flags & DF_TEXTREL) == 0)
+ elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
+ (PTR) info);
+
+ if ((info->flags & DF_TEXTREL) != 0)
+ {
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
+ return false;
+ }
+ }
+ }
+#undef add_dynamic_entry
+
+ return true;
+}
+
+/* Determine the type of stub needed, if any, for a call. */
+
+static INLINE enum ppc_stub_type
+ppc_type_of_stub (input_sec, rel, hash, destination)
+ asection *input_sec;
+ const Elf_Internal_Rela *rel;
+ struct ppc_link_hash_entry **hash;
+ bfd_vma destination;
+{
+ struct ppc_link_hash_entry *h = *hash;
+ bfd_vma location;
+ bfd_vma branch_offset;
+ bfd_vma max_branch_offset;
+ unsigned int r_type;
+
+ if (h != NULL)
+ {
+ if (h->oh != NULL
+ && h->oh->plt.offset != (bfd_vma) -1
+ && h->oh->dynindx != -1)
+ {
+ *hash = (struct ppc_link_hash_entry *) h->oh;
+ return ppc_stub_plt_call;
+ }
+
+ if (h->elf.root.type == bfd_link_hash_undefweak
+ || h->elf.root.type == bfd_link_hash_undefined)
+ return ppc_stub_none;
+ }
+
+ /* Determine where the call point is. */
+ location = (input_sec->output_offset
+ + input_sec->output_section->vma
+ + rel->r_offset);
+
+ branch_offset = destination - location;
+ r_type = ELF64_R_TYPE (rel->r_info);
+
+ /* Determine if a long branch stub is needed. */
+ max_branch_offset = 1 << 25;
+ if (r_type != (unsigned int) R_PPC64_REL24)
+ max_branch_offset = 1 << 15;
+
+ if (branch_offset + max_branch_offset >= 2 * max_branch_offset)
+ /* We need a stub. Figure out whether a long_branch or plt_branch
+ is needed later. */
+ return ppc_stub_long_branch;
+
+ return ppc_stub_none;
+}
+
+/* Build a .plt call stub. */
+
+static bfd_byte *
+build_plt_stub (obfd, p, offset, glink)
+ bfd *obfd;
+ bfd_byte *p;
+ int offset;
+ int glink;
+{
+#define PPC_LO(v) ((v) & 0xffff)
+#define PPC_HI(v) (((v) >> 16) & 0xffff)
+#define PPC_HA(v) PPC_HI ((v) + 0x8000)
+
+ if (glink)
+ bfd_put_32 (obfd, LD_R2_40R1, p), p += 4;
+ bfd_put_32 (obfd, ADDIS_R12_R2 | PPC_HA (offset), p), p += 4;
+ if (!glink)
+ bfd_put_32 (obfd, STD_R2_40R1, p), p += 4;
+ bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset), p), p += 4;
+ if (PPC_HA (offset + 8) != PPC_HA (offset))
+ bfd_put_32 (obfd, ADDIS_R12_R12_1, p), p += 4;
+ offset += 8;
+ bfd_put_32 (obfd, LD_R2_0R12 | PPC_LO (offset), p), p += 4;
+ if (PPC_HA (offset + 8) != PPC_HA (offset))
+ bfd_put_32 (obfd, ADDIS_R12_R12_1, p), p += 4;
+ offset += 8;
+ bfd_put_32 (obfd, MTCTR_R11, p), p += 4;
+ bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset), p), p += 4;
+ bfd_put_32 (obfd, BCTR, p), p += 4;
+ return p;
+}
+
+static boolean
+ppc_build_one_stub (gen_entry, in_arg)
+ struct bfd_hash_entry *gen_entry;
+ PTR in_arg;
+{
+ struct ppc_stub_hash_entry *stub_entry;
+ struct ppc_branch_hash_entry *br_entry;
+ struct bfd_link_info *info;
+ struct ppc_link_hash_table *htab;
+ asection *stub_sec;
+ bfd *stub_bfd;
+ bfd_byte *loc;
+ bfd_byte *p;
+ unsigned int indx;
+ bfd_vma off;
+ int size;
+
+ /* Massage our args to the form they really have. */
+ stub_entry = (struct ppc_stub_hash_entry *) gen_entry;
+ info = (struct bfd_link_info *) in_arg;
+
+ htab = ppc_hash_table (info);
+ stub_sec = stub_entry->stub_sec;
+
+ /* Make a note of the offset within the stubs for this entry. */
+ stub_entry->stub_offset = stub_sec->_cooked_size;
+ loc = stub_sec->contents + stub_entry->stub_offset;
+
+ stub_bfd = stub_sec->owner;
+
+ switch (stub_entry->stub_type)
+ {
+ case ppc_stub_long_branch:
+ /* Branches are relative. This is where we are going to. */
+ off = (stub_entry->target_value
+ + stub_entry->target_section->output_offset
+ + stub_entry->target_section->output_section->vma);
+
+ /* And this is where we are coming from. */
+ off -= (stub_entry->stub_offset
+ + stub_sec->output_offset
+ + stub_sec->output_section->vma);
+
+ BFD_ASSERT (off + (1 << 25) < (bfd_vma) (1 << 26));
+
+ bfd_put_32 (stub_bfd, (bfd_vma) B_DOT | (off & 0x3fffffc), loc);
+ size = 4;
+ break;
+
+ case ppc_stub_plt_branch:
+ br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table,
+ stub_entry->root.string + 9,
+ false, false);
+ if (br_entry == NULL)
+ {
+ (*_bfd_error_handler) (_("can't find branch stub `%s'"),
+ stub_entry->root.string + 9);
+ htab->stub_error = true;
+ return false;
+ }
+
+ off = (stub_entry->target_value
+ + stub_entry->target_section->output_offset
+ + stub_entry->target_section->output_section->vma);
+
+ bfd_put_64 (htab->sbrlt->owner, off,
+ htab->sbrlt->contents + br_entry->offset);
+
+ if (info->shared)
+ {
+ /* Create a reloc for the branch lookup table entry. */
+ Elf_Internal_Rela rela;
+ Elf64_External_Rela *r;
+
+ rela.r_offset = (br_entry->offset
+ + htab->sbrlt->output_offset
+ + htab->sbrlt->output_section->vma);
+ rela.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE);
+ rela.r_addend = off;
+
+ r = (Elf64_External_Rela *) htab->srelbrlt->contents;
+ r += htab->srelbrlt->reloc_count++;
+ bfd_elf64_swap_reloca_out (htab->srelbrlt->owner, &rela, r);
+ }
+
+ off = (br_entry->offset
+ + htab->sbrlt->output_offset
+ + htab->sbrlt->output_section->vma
+ - elf_gp (htab->sbrlt->output_section->owner)
+ - TOC_BASE_OFF);
+
+ if (off + 0x80000000 > 0xffffffff || (off & 7) != 0)
+ {
+ (*_bfd_error_handler)
+ (_("linkage table error against `%s'"),
+ stub_entry->root.string);
+ bfd_set_error (bfd_error_bad_value);
+ htab->stub_error = true;
+ return false;
+ }
+
+ indx = off;
+ bfd_put_32 (stub_bfd, (bfd_vma) ADDIS_R12_R2 | PPC_HA (indx), loc);
+ bfd_put_32 (stub_bfd, (bfd_vma) LD_R11_0R12 | PPC_LO (indx), loc + 4);
+ bfd_put_32 (stub_bfd, (bfd_vma) MTCTR_R11, loc + 8);
+ bfd_put_32 (stub_bfd, (bfd_vma) BCTR, loc + 12);
+ size = 16;
+ break;
+
+ case ppc_stub_plt_call:
+ /* Do the best we can for shared libraries built without
+ exporting ".foo" for each "foo". This can happen when symbol
+ versioning scripts strip all bar a subset of symbols. */
+ if (stub_entry->h->oh->root.type != bfd_link_hash_defined
+ && stub_entry->h->oh->root.type != bfd_link_hash_defweak)
+ {
+ /* Point the symbol at the stub. There may be multiple stubs,
+ we don't really care; The main thing is to make this sym
+ defined somewhere. */
+ stub_entry->h->oh->root.type = bfd_link_hash_defined;
+ stub_entry->h->oh->root.u.def.section = stub_entry->stub_sec;
+ stub_entry->h->oh->root.u.def.value = stub_entry->stub_offset;
+ }
+
+ /* Now build the stub. */
+ off = stub_entry->h->elf.plt.offset;
+ if (off >= (bfd_vma) -2)
+ abort ();
+
+ off &= ~ (bfd_vma) 1;
+ off += (htab->splt->output_offset
+ + htab->splt->output_section->vma
+ - elf_gp (htab->splt->output_section->owner)
+ - TOC_BASE_OFF);
+
+ if (off + 0x80000000 > 0xffffffff || (off & 7) != 0)
+ {
+ (*_bfd_error_handler)
+ (_("linkage table error against `%s'"),
+ stub_entry->h->elf.root.root.string);
+ bfd_set_error (bfd_error_bad_value);
+ htab->stub_error = true;
+ return false;
+ }
+
+ p = build_plt_stub (stub_bfd, loc, (int) off, 0);
+ size = p - loc;
+ break;
+
+ default:
+ BFD_FAIL ();
+ return false;
+ }
+
+ stub_sec->_cooked_size += size;
+ return true;
+}
+
+/* As above, but don't actually build the stub. Just bump offset so
+ we know stub section sizes, and select plt_branch stubs where
+ long_branch stubs won't do. */
+
+static boolean
+ppc_size_one_stub (gen_entry, in_arg)
+ struct bfd_hash_entry *gen_entry;
+ PTR in_arg;
+{
+ struct ppc_stub_hash_entry *stub_entry;
+ struct ppc_link_hash_table *htab;
+ bfd_vma off;
+ int size;
+
+ /* Massage our args to the form they really have. */
+ stub_entry = (struct ppc_stub_hash_entry *) gen_entry;
+ htab = (struct ppc_link_hash_table *) in_arg;
+
+ if (stub_entry->stub_type == ppc_stub_plt_call)
+ {
+ off = stub_entry->h->elf.plt.offset & ~(bfd_vma) 1;
+ off += (htab->splt->output_offset
+ + htab->splt->output_section->vma
+ - elf_gp (htab->splt->output_section->owner)
+ - TOC_BASE_OFF);
+
+ size = 28;
+ if (PPC_HA ((int) off + 16) != PPC_HA ((int) off))
+ size += 4;
+ }
+ else
+ {
+ /* ppc_stub_long_branch or ppc_stub_plt_branch. */
+ stub_entry->stub_type = ppc_stub_long_branch;
+ size = 4;
+
+ off = (stub_entry->target_value
+ + stub_entry->target_section->output_offset
+ + stub_entry->target_section->output_section->vma);
+ off -= (stub_entry->stub_sec->_raw_size
+ + stub_entry->stub_sec->output_offset
+ + stub_entry->stub_sec->output_section->vma);
+
+ if (off + (1 << 25) >= (bfd_vma) (1 << 26))
+ {
+ struct ppc_branch_hash_entry *br_entry;
+
+ br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table,
+ stub_entry->root.string + 9,
+ true, false);
+ if (br_entry == NULL)
+ {
+ (*_bfd_error_handler) (_("can't build branch stub `%s'"),
+ stub_entry->root.string + 9);
+ htab->stub_error = true;
+ return false;
+ }
+
+ if (br_entry->iter != htab->stub_iteration)
+ {
+ br_entry->iter = htab->stub_iteration;
+ br_entry->offset = htab->sbrlt->_raw_size;
+ htab->sbrlt->_raw_size += 8;
+ }
+ stub_entry->stub_type = ppc_stub_plt_branch;
+ size = 16;
+ }
+ }
+
+ stub_entry->stub_sec->_raw_size += size;
+ return true;
+}
+
+/* Set up various things so that we can make a list of input sections
+ for each output section included in the link. Returns -1 on error,
+ 0 when no stubs will be needed, and 1 on success. */
+
+int
+ppc64_elf_setup_section_lists (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ bfd *input_bfd;
+ int top_id, top_index;
+ asection *section;
+ asection **input_list, **list;
+ bfd_size_type amt;
+ struct ppc_link_hash_table *htab = ppc_hash_table (info);
+
+ if (htab->elf.root.creator->flavour != bfd_target_elf_flavour
+ || htab->sbrlt == NULL)
+ return 0;
+
+ /* Find the top input section id. */
+ for (input_bfd = info->input_bfds, top_id = 0;
+ input_bfd != NULL;
+ input_bfd = input_bfd->link_next)
+ {
+ for (section = input_bfd->sections;
+ section != NULL;
+ section = section->next)
+ {
+ if (top_id < section->id)
+ top_id = section->id;
+ }
+ }
+
+ amt = sizeof (struct map_stub) * (top_id + 1);
+ htab->stub_group = (struct map_stub *) bfd_zmalloc (amt);
+ if (htab->stub_group == NULL)
+ return -1;
+
+ /* We can't use output_bfd->section_count here to find the top output
+ section index as some sections may have been removed, and
+ _bfd_strip_section_from_output doesn't renumber the indices. */
+ for (section = output_bfd->sections, top_index = 0;
+ section != NULL;
+ section = section->next)
+ {
+ if (top_index < section->index)
+ top_index = section->index;
+ }
+
+ htab->top_index = top_index;
+ amt = sizeof (asection *) * (top_index + 1);
+ input_list = (asection **) bfd_malloc (amt);
+ htab->input_list = input_list;
+ if (input_list == NULL)
+ return -1;
+
+ /* For sections we aren't interested in, mark their entries with a
+ value we can check later. */
+ list = input_list + top_index;
+ do
+ *list = bfd_abs_section_ptr;
+ while (list-- != input_list);
+
+ for (section = output_bfd->sections;
+ section != NULL;
+ section = section->next)
+ {
+ if ((section->flags & SEC_CODE) != 0)
+ input_list[section->index] = NULL;
+ }
+
+ return 1;
+}
+
+/* The linker repeatedly calls this function for each input section,
+ in the order that input sections are linked into output sections.
+ Build lists of input sections to determine groupings between which
+ we may insert linker stubs. */
+
+void
+ppc64_elf_next_input_section (info, isec)
+ struct bfd_link_info *info;
+ asection *isec;
+{
+ struct ppc_link_hash_table *htab = ppc_hash_table (info);
+
+ if (isec->output_section->index <= htab->top_index)
+ {
+ asection **list = htab->input_list + isec->output_section->index;
+ if (*list != bfd_abs_section_ptr)
+ {
+ /* Steal the link_sec pointer for our list. */
+#define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec)
+ /* This happens to make the list in reverse order,
+ which is what we want. */
+ PREV_SEC (isec) = *list;
+ *list = isec;
+ }
+ }
+}
+
+/* See whether we can group stub sections together. Grouping stub
+ sections may result in fewer stubs. More importantly, we need to
+ put all .init* and .fini* stubs at the beginning of the .init or
+ .fini output sections respectively, because glibc splits the
+ _init and _fini functions into multiple parts. Putting a stub in
+ the middle of a function is not a good idea. */
+
+static void
+group_sections (htab, stub_group_size, stubs_always_before_branch)
+ struct ppc_link_hash_table *htab;
+ bfd_size_type stub_group_size;
+ boolean stubs_always_before_branch;
+{
+ asection **list = htab->input_list + htab->top_index;
+ do
+ {
+ asection *tail = *list;
+ if (tail == bfd_abs_section_ptr)
+ continue;
+ while (tail != NULL)
+ {
+ asection *curr;
+ asection *prev;
+ bfd_size_type total;
+
+ curr = tail;
+ if (tail->_cooked_size)
+ total = tail->_cooked_size;
+ else
+ total = tail->_raw_size;
+ while ((prev = PREV_SEC (curr)) != NULL
+ && ((total += curr->output_offset - prev->output_offset)
+ < stub_group_size))
+ curr = prev;
+
+ /* OK, the size from the start of CURR to the end is less
+ than stub_group_size and thus can be handled by one stub
+ section. (or the tail section is itself larger than
+ stub_group_size, in which case we may be toast.) We
+ should really be keeping track of the total size of stubs
+ added here, as stubs contribute to the final output
+ section size. That's a little tricky, and this way will
+ only break if stubs added make the total size more than
+ 2^25, ie. for the default stub_group_size, if stubs total
+ more than 2834432 bytes, or over 100000 plt call stubs. */
+ do
+ {
+ prev = PREV_SEC (tail);
+ /* Set up this stub group. */
+ htab->stub_group[tail->id].link_sec = curr;
+ }
+ while (tail != curr && (tail = prev) != NULL);
+
+ /* But wait, there's more! Input sections up to stub_group_size
+ bytes before the stub section can be handled by it too. */
+ if (!stubs_always_before_branch)
+ {
+ total = 0;
+ while (prev != NULL
+ && ((total += tail->output_offset - prev->output_offset)
+ < stub_group_size))
+ {
+ tail = prev;
+ prev = PREV_SEC (tail);
+ htab->stub_group[tail->id].link_sec = curr;
+ }
+ }
+ tail = prev;
+ }
+ }
+ while (list-- != htab->input_list);
+ free (htab->input_list);
+#undef PREV_SEC
+}
+
+/* Determine and set the size of the stub section for a final link.
+
+ The basic idea here is to examine all the relocations looking for
+ PC-relative calls to a target that is unreachable with a "bl"
+ instruction. */
+
+boolean
+ppc64_elf_size_stubs (output_bfd, stub_bfd, info, group_size,
+ add_stub_section, layout_sections_again)
+ bfd *output_bfd;
+ bfd *stub_bfd;
+ struct bfd_link_info *info;
+ bfd_signed_vma group_size;
+ asection * (*add_stub_section) PARAMS ((const char *, asection *));
+ void (*layout_sections_again) PARAMS ((void));
+{
+ bfd_size_type stub_group_size;
+ boolean stubs_always_before_branch;
+ struct ppc_link_hash_table *htab = ppc_hash_table (info);
+
+ /* Stash our params away. */
+ htab->stub_bfd = stub_bfd;
+ htab->add_stub_section = add_stub_section;
+ htab->layout_sections_again = layout_sections_again;
+ stubs_always_before_branch = group_size < 0;
+ if (group_size < 0)
+ stub_group_size = -group_size;
+ else
+ stub_group_size = group_size;
+ if (stub_group_size == 1)
+ {
+ /* Default values. */
+ stub_group_size = 30720000;
+ if (htab->has_14bit_branch)
+ stub_group_size = 30000;
+ }
+
+ group_sections (htab, stub_group_size, stubs_always_before_branch);
+
+ while (1)
+ {
+ bfd *input_bfd;
+ unsigned int bfd_indx;
+ asection *stub_sec;
+ boolean stub_changed;
+
+ htab->stub_iteration += 1;
+ stub_changed = false;
+
+ for (input_bfd = info->input_bfds, bfd_indx = 0;
+ input_bfd != NULL;
+ input_bfd = input_bfd->link_next, bfd_indx++)
+ {
+ Elf_Internal_Shdr *symtab_hdr;
+ asection *section;
+ Elf_Internal_Sym *local_syms = NULL;
+
+ /* We'll need the symbol table in a second. */
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ if (symtab_hdr->sh_info == 0)
+ continue;
+
+ /* Walk over each section attached to the input bfd. */
+ for (section = input_bfd->sections;
+ section != NULL;
+ section = section->next)
+ {
+ Elf_Internal_Rela *internal_relocs, *irelaend, *irela;
+
+ /* If there aren't any relocs, then there's nothing more
+ to do. */
+ if ((section->flags & SEC_RELOC) == 0
+ || section->reloc_count == 0)
+ continue;
+
+ /* If this section is a link-once section that will be
+ discarded, then don't create any stubs. */
+ if (section->output_section == NULL
+ || section->output_section->owner != output_bfd)
+ continue;
+
+ /* Get the relocs. */
+ internal_relocs
+ = _bfd_elf64_link_read_relocs (input_bfd, section, NULL,
+ (Elf_Internal_Rela *) NULL,
+ info->keep_memory);
+ if (internal_relocs == NULL)
+ goto error_ret_free_local;
+
+ /* Now examine each relocation. */
+ irela = internal_relocs;
+ irelaend = irela + section->reloc_count;
+ for (; irela < irelaend; irela++)
+ {
+ unsigned int r_type, r_indx;
+ enum ppc_stub_type stub_type;
+ struct ppc_stub_hash_entry *stub_entry;
+ asection *sym_sec;
+ bfd_vma sym_value;
+ bfd_vma destination;
+ struct ppc_link_hash_entry *hash;
+ char *stub_name;
+ const asection *id_sec;
+
+ r_type = ELF64_R_TYPE (irela->r_info);
+ r_indx = ELF64_R_SYM (irela->r_info);
+
+ if (r_type >= (unsigned int) R_PPC_max)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ goto error_ret_free_internal;
+ }
+
+ /* Only look for stubs on branch instructions. */
+ if (r_type != (unsigned int) R_PPC64_REL24
+ && r_type != (unsigned int) R_PPC64_REL14
+ && r_type != (unsigned int) R_PPC64_REL14_BRTAKEN
+ && r_type != (unsigned int) R_PPC64_REL14_BRNTAKEN)
+ continue;
+
+ /* Now determine the call target, its name, value,
+ section. */
+ sym_sec = NULL;
+ sym_value = 0;
+ destination = 0;
+ hash = NULL;
+ if (r_indx < symtab_hdr->sh_info)
+ {
+ /* It's a local symbol. */
+ Elf_Internal_Sym *sym;
+ Elf_Internal_Shdr *hdr;
+
+ if (local_syms == NULL)
+ {
+ local_syms
+ = (Elf_Internal_Sym *) symtab_hdr->contents;
+ if (local_syms == NULL)
+ local_syms
+ = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
+ symtab_hdr->sh_info, 0,
+ NULL, NULL, NULL);
+ if (local_syms == NULL)
+ goto error_ret_free_internal;
+ }
+ sym = local_syms + r_indx;
+ hdr = elf_elfsections (input_bfd)[sym->st_shndx];
+ sym_sec = hdr->bfd_section;
+ if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
+ sym_value = sym->st_value;
+ destination = (sym_value + irela->r_addend
+ + sym_sec->output_offset
+ + sym_sec->output_section->vma);
+ }
+ else
+ {
+ /* It's an external symbol. */
+ int e_indx;
+
+ e_indx = r_indx - symtab_hdr->sh_info;
+ hash = ((struct ppc_link_hash_entry *)
+ elf_sym_hashes (input_bfd)[e_indx]);
+
+ while (hash->elf.root.type == bfd_link_hash_indirect
+ || hash->elf.root.type == bfd_link_hash_warning)
+ hash = ((struct ppc_link_hash_entry *)
+ hash->elf.root.u.i.link);
+
+ if (hash->elf.root.type == bfd_link_hash_defined
+ || hash->elf.root.type == bfd_link_hash_defweak)
+ {
+ sym_sec = hash->elf.root.u.def.section;
+ sym_value = hash->elf.root.u.def.value;
+ if (sym_sec->output_section != NULL)
+ destination = (sym_value + irela->r_addend
+ + sym_sec->output_offset
+ + sym_sec->output_section->vma);
+ }
+ else if (hash->elf.root.type == bfd_link_hash_undefweak)
+ ;
+ else if (hash->elf.root.type == bfd_link_hash_undefined)
+ ;
+ else
+ {
+ bfd_set_error (bfd_error_bad_value);
+ goto error_ret_free_internal;
+ }
+ }
+
+ /* Determine what (if any) linker stub is needed. */
+ stub_type = ppc_type_of_stub (section, irela, &hash,
+ destination);
+ if (stub_type == ppc_stub_none)
+ continue;
+
+ /* Support for grouping stub sections. */
+ id_sec = htab->stub_group[section->id].link_sec;