/* Support for HPPA 64-bit ELF
- Copyright (C) 1999-2020 Free Software Foundation, Inc.
+ Copyright (C) 1999-2021 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
/* Shortcuts to get to the various linker defined sections. */
asection *dlt_sec;
asection *dlt_rel_sec;
- asection *plt_sec;
- asection *plt_rel_sec;
asection *opd_sec;
asection *opd_rel_sec;
asection *other_rel_sec;
};
#define hppa_link_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == HPPA64_ELF_DATA ? ((struct elf64_hppa_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == HPPA64_ELF_DATA) \
+ ? (struct elf64_hppa_link_hash_table *) (p)->hash : NULL)
#define hppa_elf_hash_entry(ent) \
((struct elf64_hppa_link_hash_entry *)(ent))
return NULL;
}
+ htab->root.dt_pltgot_required = TRUE;
htab->text_segment_base = (bfd_vma) -1;
htab->data_segment_base = (bfd_vma) -1;
?!? Note we leak the last section_syms array. Presumably we
could free it in one of the later routines in this file. */
- if (hppa_info->section_syms)
- free (hppa_info->section_syms);
+ free (hppa_info->section_syms);
/* Read this BFD's local symbols. */
if (symtab_hdr->sh_info != 0)
if (need_entry & NEED_PLT)
{
- if (! hppa_info->plt_sec
+ if (! hppa_info->root.splt
&& ! get_plt (abfd, info, hppa_info))
goto err_out;
asection *plt;
bfd *dynobj;
- plt = hppa_info->plt_sec;
+ plt = hppa_info->root.splt;
if (!plt)
{
dynobj = hppa_info->root.dynobj;
return FALSE;
}
- hppa_info->plt_sec = plt;
+ hppa_info->root.splt = plt;
}
return TRUE;
if (s == NULL
|| !bfd_set_section_alignment (s, 3))
return FALSE;
- hppa_info->plt_rel_sec = s;
+ hppa_info->root.srelplt = s;
s = bfd_make_section_anyway_with_flags (abfd, ".rela.data",
(SEC_ALLOC | SEC_LOAD
else if (shared)
t = 2 * sizeof (Elf64_External_Rela);
- hppa_info->plt_rel_sec->size += t;
+ hppa_info->root.srelplt->size += t;
}
return TRUE;
bfd *dynobj;
bfd *ibfd;
asection *sec;
- bfd_boolean plt;
bfd_boolean relocs;
- bfd_boolean reltext;
hppa_info = hppa_link_hash_table (info);
if (hppa_info == NULL)
}
else
{
- sec = hppa_info->plt_sec;
- srel = hppa_info->plt_rel_sec;
+ sec = hppa_info->root.splt;
+ srel = hppa_info->root.srelplt;
for (; local_plt < end_local_plt; ++local_plt)
{
if (*local_plt > 0)
hppa_info->dlt_sec->size = data.ofs;
}
- if (hppa_info->plt_sec)
+ if (hppa_info->root.splt)
{
- data.ofs = hppa_info->plt_sec->size;
+ data.ofs = hppa_info->root.splt->size;
elf_link_hash_traverse (&hppa_info->root,
allocate_global_data_plt, &data);
- hppa_info->plt_sec->size = data.ofs;
+ hppa_info->root.splt->size = data.ofs;
}
if (hppa_info->stub_sec)
allocate_dynrel_entries, &data);
/* The sizes of all the sections are set. Allocate memory for them. */
- plt = FALSE;
relocs = FALSE;
- reltext = FALSE;
for (sec = dynobj->sections; sec != NULL; sec = sec->next)
{
const char *name;
if (strcmp (name, ".plt") == 0)
{
/* Remember whether there is a PLT. */
- plt = sec->size != 0;
+ ;
}
else if (strcmp (name, ".opd") == 0
- || CONST_STRNEQ (name, ".dlt")
+ || startswith (name, ".dlt")
|| strcmp (name, ".stub") == 0
|| strcmp (name, ".got") == 0)
{
/* Strip this section if we don't need it; see the comment below. */
}
- else if (CONST_STRNEQ (name, ".rela"))
+ else if (startswith (name, ".rela"))
{
if (sec->size != 0)
{
- asection *target;
-
/* Remember whether there are any reloc sections other
than .rela.plt. */
if (strcmp (name, ".rela.plt") != 0)
- {
- const char *outname;
-
- relocs = TRUE;
-
- /* If this relocation section applies to a read only
- section, then we probably need a DT_TEXTREL
- entry. The entries in the .rela.plt section
- really apply to the .got section, which we
- created ourselves and so know is not readonly. */
- outname = bfd_section_name (sec->output_section);
- target = bfd_get_section_by_name (output_bfd, outname + 4);
- if (target != NULL
- && (target->flags & SEC_READONLY) != 0
- && (target->flags & SEC_ALLOC) != 0)
- reltext = TRUE;
- }
+ relocs = TRUE;
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
#define add_dynamic_entry(TAG, VAL) \
_bfd_elf_add_dynamic_entry (info, TAG, VAL)
- if (!add_dynamic_entry (DT_HP_DLD_FLAGS, 0)
- || !add_dynamic_entry (DT_PLTGOT, 0))
+ if (!add_dynamic_entry (DT_HP_DLD_FLAGS, 0))
return FALSE;
/* Add some entries to the .dynamic section. We fill in the
dynamic linker and used by the debugger. */
if (! bfd_link_pic (info))
{
- if (!add_dynamic_entry (DT_DEBUG, 0)
- || !add_dynamic_entry (DT_HP_DLD_HOOK, 0)
+ if (!add_dynamic_entry (DT_HP_DLD_HOOK, 0)
|| !add_dynamic_entry (DT_HP_LOAD_MAP, 0))
return FALSE;
}
Required by HPUX 11.00 patch PHSS_26559. */
if (!add_dynamic_entry (DT_FLAGS, (info)->flags))
return FALSE;
-
- if (plt)
- {
- if (!add_dynamic_entry (DT_PLTRELSZ, 0)
- || !add_dynamic_entry (DT_PLTREL, DT_RELA)
- || !add_dynamic_entry (DT_JMPREL, 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 (reltext)
- {
- if (!add_dynamic_entry (DT_TEXTREL, 0))
- return FALSE;
- info->flags |= DF_TEXTREL;
- }
}
#undef add_dynamic_entry
- return TRUE;
+ return _bfd_elf_add_dynamic_tags (output_bfd, info, relocs);
}
/* Called after we have output the symbol into the dynamic symbol
return FALSE;
stub = hppa_info->stub_sec;
- splt = hppa_info->plt_sec;
+ splt = hppa_info->root.splt;
sopd = hppa_info->opd_sec;
- spltrel = hppa_info->plt_rel_sec;
+ spltrel = hppa_info->root.srelplt;
/* Incredible. It is actually necessary to NOT use the symbol's real
value when building the dynamic symbol table for a shared library.
break;
case DT_JMPREL:
- s = hppa_info->plt_rel_sec;
+ s = hppa_info->root.srelplt;
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTRELSZ:
- s = hppa_info->plt_rel_sec;
+ s = hppa_info->root.srelplt;
dyn.d_un.d_val = s->size;
bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
/* There is some question about whether or not the size of
the PLT relocs should be included here. HP's tools do
it, so we'll emulate them. */
- s = hppa_info->plt_rel_sec;
+ s = hppa_info->root.srelplt;
dyn.d_un.d_val += s->size;
bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
that order) and set __gp to the base address of whichever
section is found first. */
- sec = hppa_info->plt_sec;
+ sec = hppa_info->root.splt;
if (sec && ! (sec->flags & SEC_EXCLUDE))
gp_val = (sec->output_offset
+ sec->output_section->vma
to the start of the DLT, so we have to compute the absolute
address, then subtract out the value of __gp. */
value = (hh->plt_offset
- + hppa_info->plt_sec->output_offset
- + hppa_info->plt_sec->output_section->vma);
+ + hppa_info->root.splt->output_offset
+ + hppa_info->root.splt->output_section->vma);
value -= _bfd_get_gp_value (output_bfd);
/* All PLTOFF relocations are basically the same at this point,
}
case R_PARISC_SECREL32:
- if (sym_sec)
+ if (sym_sec && sym_sec->output_section)
value -= sym_sec->output_section->vma;
bfd_put_32 (input_bfd, value + addend, hit_data);
return bfd_reloc_ok;