: be,n 0(%sr0,%rp) ; inter-space return */
#define PLT_ENTRY_SIZE 8
-#define PLABEL_PLT_ENTRY_SIZE PLT_ENTRY_SIZE
#define GOT_ENTRY_SIZE 4
#define ELF_DYNAMIC_INTERPRETER "/lib/ld.so.1"
static boolean mark_PIC_calls
PARAMS ((struct elf_link_hash_entry *, PTR));
-static boolean allocate_PIC_calls
+static boolean allocate_plt_static
PARAMS ((struct elf_link_hash_entry *, PTR));
static boolean allocate_dynrelocs
return true;
}
-/* Allocate space in the .plt for pic_call entries. */
+/* Allocate space in the .plt for entries that won't have relocations.
+ ie. pic_call and plabel entries. */
static boolean
-allocate_PIC_calls (h, inf)
+allocate_plt_static (h, inf)
struct elf_link_hash_entry *h;
PTR inf;
{
htab = hppa_link_hash_table (info);
if (((struct elf32_hppa_link_hash_entry *) h)->pic_call)
{
- /* Make an entry in the .plt section. */
+ /* Make an entry in the .plt section for non-pic code that is
+ calling pic code. */
s = htab->splt;
h->plt.offset = s->_raw_size;
- if (PLABEL_PLT_ENTRY_SIZE != PLT_ENTRY_SIZE
- && ((struct elf32_hppa_link_hash_entry *) h)->plabel
- && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+ s->_raw_size += PLT_ENTRY_SIZE;
+ }
+ else if (htab->elf.dynamic_sections_created
+ && h->plt.refcount > 0)
+ {
+ /* Make sure this symbol is output as a dynamic symbol.
+ Undefined weak syms won't yet be marked as dynamic. */
+ if (h->dynindx == -1
+ && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0
+ && h->type != STT_PARISC_MILLI)
{
- /* Add some extra space for the dynamic linker to use. */
- s->_raw_size += PLABEL_PLT_ENTRY_SIZE;
+ if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+ return false;
+ }
+
+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
+ {
+ /* Allocate these later. */
+ }
+ else if (((struct elf32_hppa_link_hash_entry *) h)->plabel)
+ {
+ /* Make an entry in the .plt section for plabel references
+ that won't have a .plt entry for other reasons. */
+ s = htab->splt;
+ h->plt.offset = s->_raw_size;
+ s->_raw_size += PLT_ENTRY_SIZE;
}
else
- s->_raw_size += PLT_ENTRY_SIZE;
+ {
+ /* No .plt entry needed. */
+ h->plt.offset = (bfd_vma) -1;
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ }
+ }
+ else
+ {
+ h->plt.offset = (bfd_vma) -1;
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
}
return true;
info = (struct bfd_link_info *) inf;
htab = hppa_link_hash_table (info);
- if ((htab->elf.dynamic_sections_created
- && h->plt.refcount > 0)
- || ((struct elf32_hppa_link_hash_entry *) h)->pic_call)
+ if (htab->elf.dynamic_sections_created
+ && h->plt.offset != (bfd_vma) -1
+ && !((struct elf32_hppa_link_hash_entry *) h)->pic_call
+ && WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
{
- /* Make sure this symbol is output as a dynamic symbol.
- Undefined weak syms won't yet be marked as dynamic. */
- if (h->dynindx == -1
- && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0
- && h->type != STT_PARISC_MILLI
- && !((struct elf32_hppa_link_hash_entry *) h)->pic_call)
- {
- if (! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- if (((struct elf32_hppa_link_hash_entry *) h)->pic_call)
- {
- /* Already handled by allocate_PIC_calls. */
- }
- else if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
- {
- /* Make an entry in the .plt section. */
- s = htab->splt;
- h->plt.offset = s->_raw_size;
- if (PLABEL_PLT_ENTRY_SIZE != PLT_ENTRY_SIZE
- && ((struct elf32_hppa_link_hash_entry *) h)->plabel
- && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
- {
- /* Add some extra space for the dynamic linker to use. */
- s->_raw_size += PLABEL_PLT_ENTRY_SIZE;
- }
- else
- s->_raw_size += PLT_ENTRY_SIZE;
+ /* Make an entry in the .plt section. */
+ s = htab->splt;
+ h->plt.offset = s->_raw_size;
+ s->_raw_size += PLT_ENTRY_SIZE;
- /* We also need to make an entry in the .rela.plt section. */
- htab->srelplt->_raw_size += sizeof (Elf32_External_Rela);
- htab->need_plt_stub = 1;
- }
- else
- {
- h->plt.offset = (bfd_vma) -1;
- h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
- }
- }
- else
- {
- h->plt.offset = (bfd_vma) -1;
- h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ /* We also need to make an entry in the .rela.plt section. */
+ htab->srelplt->_raw_size += sizeof (Elf32_External_Rela);
+ htab->need_plt_stub = 1;
}
if (h->got.refcount > 0)
}
}
- if (! info->shared)
- elf_link_hash_traverse (&htab->elf, allocate_PIC_calls, (PTR) info);
+ /* 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. */