- }
- else
- {
- /* Run through the function symbols, looking for any that are
- PIC, and allocate space for the necessary .plt entries so
- that %r19 will be set up. */
- if (! info->shared)
- elf_link_hash_traverse (&hplink->root,
- hppa_handle_PIC_calls,
- info);
-
- /* We may have created entries in the .rela.got section.
- However, if we are not creating the dynamic sections, we will
- not actually use these entries. Reset the size of .rela.got,
- which will cause it to get stripped from the output file
- below. */
- hplink->srelgot->_raw_size = 0;
- }
-
-#if ((! LONG_BRANCH_PIC_IN_SHLIB && LONG_BRANCH_VIA_PLT) \
- || RELATIVE_DYNAMIC_RELOCS)
- /* If this is a -Bsymbolic shared link, then we need to discard all
- relocs against symbols defined in a regular object. We also need
- to lose relocs we've allocated for long branch stubs if we know
- we won't be generating a stub. */
- if (info->shared)
- elf_link_hash_traverse (&hplink->root,
- hppa_discard_copies,
- info);
-#endif
-
- /* The check_relocs and adjust_dynamic_symbol entry points have
- determined the sizes of the various dynamic sections. Allocate
- memory for them. */
- relocs = false;
- reltext = false;
- for (s = dynobj->sections; s != NULL; s = s->next)
- {
- const char *name;
-
- if ((s->flags & SEC_LINKER_CREATED) == 0)
- continue;
-
- /* It's OK to base decisions on the section name, because none
- of the dynobj section names depend upon the input files. */
- name = bfd_get_section_name (dynobj, s);
-
- if (strncmp (name, ".rela", 5) == 0)
- {
- if (s->_raw_size != 0)
- {
- asection *target;
- const char *outname;
-
- /* Remember whether there are any reloc sections other
- than .rela.plt. */
- if (strcmp (name+5, ".plt") != 0)
- relocs = true;
-
- /* If this relocation section applies to a read only
- section, then we probably need a DT_TEXTREL entry. */
- outname = bfd_get_section_name (output_bfd,
- s->output_section);
- target = bfd_get_section_by_name (output_bfd, outname + 5);
- if (target != NULL
- && (target->flags & SEC_READONLY) != 0
- && (target->flags & SEC_ALLOC) != 0)
- reltext = true;
-
- /* We use the reloc_count field as a counter if we need
- to copy relocs into the output file. */
- s->reloc_count = 0;
- }
- }
- else if (strcmp (name, ".plt") == 0)
+ }
+
+ /* Do all the .plt entries without relocs first. The dynamic linker
+ uses the last .plt reloc to find the end of the .plt (and hence
+ the start of the .got) for lazy linking. */
+ elf_link_hash_traverse (&htab->elf, allocate_plt_static, (PTR) info);
+
+ /* Allocate global sym .plt and .got entries, and space for global
+ sym dynamic relocs. */
+ elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info);
+
+ /* The check_relocs and adjust_dynamic_symbol entry points have
+ determined the sizes of the various dynamic sections. Allocate
+ memory for them. */
+ relocs = false;
+ for (s = dynobj->sections; s != NULL; s = s->next)
+ {
+ if ((s->flags & SEC_LINKER_CREATED) == 0)
+ continue;
+
+ if (s == htab->splt)