/* Support for HPPA 64-bit ELF
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
- 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1999-2023 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
-#include "alloca-conf.h"
#include "sysdep.h"
#include "bfd.h"
#include "libbfd.h"
#include "elf/hppa.h"
#include "libhppa.h"
#include "elf64-hppa.h"
-
+#include "libiberty.h"
#define ARCH_SIZE 64
/* 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))
hash tables and shared functions. */
#include "elf-hppa.h"
-static bfd_boolean elf64_hppa_object_p
+static bool elf64_hppa_object_p
(bfd *);
-static void elf64_hppa_post_process_headers
- (bfd *, struct bfd_link_info *);
-
-static bfd_boolean elf64_hppa_create_dynamic_sections
+static bool elf64_hppa_create_dynamic_sections
(bfd *, struct bfd_link_info *);
-static bfd_boolean elf64_hppa_adjust_dynamic_symbol
+static bool elf64_hppa_adjust_dynamic_symbol
(struct bfd_link_info *, struct elf_link_hash_entry *);
-static bfd_boolean elf64_hppa_mark_milli_and_exported_functions
+static bool elf64_hppa_mark_milli_and_exported_functions
(struct elf_link_hash_entry *, void *);
-static bfd_boolean elf64_hppa_size_dynamic_sections
+static bool elf64_hppa_size_dynamic_sections
(bfd *, struct bfd_link_info *);
static int elf64_hppa_link_output_symbol_hook
(struct bfd_link_info *, const char *, Elf_Internal_Sym *,
asection *, struct elf_link_hash_entry *);
-static bfd_boolean elf64_hppa_finish_dynamic_symbol
+static bool elf64_hppa_finish_dynamic_symbol
(bfd *, struct bfd_link_info *,
struct elf_link_hash_entry *, Elf_Internal_Sym *);
-static enum elf_reloc_type_class elf64_hppa_reloc_type_class
- (const Elf_Internal_Rela *);
-
-static bfd_boolean elf64_hppa_finish_dynamic_sections
+static bool elf64_hppa_finish_dynamic_sections
(bfd *, struct bfd_link_info *);
-static bfd_boolean elf64_hppa_check_relocs
+static bool elf64_hppa_check_relocs
(bfd *, struct bfd_link_info *,
asection *, const Elf_Internal_Rela *);
-static bfd_boolean elf64_hppa_dynamic_symbol_p
+static bool elf64_hppa_dynamic_symbol_p
(struct elf_link_hash_entry *, struct bfd_link_info *);
-static bfd_boolean elf64_hppa_mark_exported_functions
+static bool elf64_hppa_mark_exported_functions
(struct elf_link_hash_entry *, void *);
-static bfd_boolean elf64_hppa_finalize_opd
+static bool elf64_hppa_finalize_opd
(struct elf_link_hash_entry *, void *);
-static bfd_boolean elf64_hppa_finalize_dlt
+static bool elf64_hppa_finalize_dlt
(struct elf_link_hash_entry *, void *);
-static bfd_boolean allocate_global_data_dlt
+static bool allocate_global_data_dlt
(struct elf_link_hash_entry *, void *);
-static bfd_boolean allocate_global_data_plt
+static bool allocate_global_data_plt
(struct elf_link_hash_entry *, void *);
-static bfd_boolean allocate_global_data_stub
+static bool allocate_global_data_stub
(struct elf_link_hash_entry *, void *);
-static bfd_boolean allocate_global_data_opd
+static bool allocate_global_data_opd
(struct elf_link_hash_entry *, void *);
-static bfd_boolean get_reloc_section
+static bool get_reloc_section
(bfd *, struct elf64_hppa_link_hash_table *, asection *);
-static bfd_boolean count_dyn_reloc
+static bool count_dyn_reloc
(bfd *, struct elf64_hppa_link_hash_entry *,
int, asection *, int, bfd_vma, bfd_vma);
-static bfd_boolean allocate_dynrel_entries
+static bool allocate_dynrel_entries
(struct elf_link_hash_entry *, void *);
-static bfd_boolean elf64_hppa_finalize_dynreloc
+static bool elf64_hppa_finalize_dynreloc
(struct elf_link_hash_entry *, void *);
-static bfd_boolean get_opd
+static bool get_opd
(bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *);
-static bfd_boolean get_plt
+static bool get_plt
(bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *);
-static bfd_boolean get_dlt
+static bool get_dlt
(bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *);
-static bfd_boolean get_stub
+static bool get_stub
(bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *);
static int elf64_hppa_elf_get_symbol_type
entry = bfd_hash_allocate (table,
sizeof (struct elf64_hppa_link_hash_entry));
if (entry == NULL)
- return entry;
+ return entry;
}
/* Call the allocation method of the superclass. */
elf64_hppa_hash_table_create (bfd *abfd)
{
struct elf64_hppa_link_hash_table *htab;
- bfd_size_type amt = sizeof (*htab);
+ size_t amt = sizeof (*htab);
- htab = bfd_zalloc (abfd, amt);
+ htab = bfd_zmalloc (amt);
if (htab == NULL)
return NULL;
sizeof (struct elf64_hppa_link_hash_entry),
HPPA64_ELF_DATA))
{
- bfd_release (abfd, htab);
+ free (htab);
return NULL;
}
+ htab->root.dt_pltgot_required = true;
htab->text_segment_base = (bfd_vma) -1;
htab->data_segment_base = (bfd_vma) -1;
/* Return nonzero if ABFD represents a PA2.0 ELF64 file.
Additionally we set the default architecture and machine. */
-static bfd_boolean
+static bool
elf64_hppa_object_p (bfd *abfd)
{
Elf_Internal_Ehdr * i_ehdrp;
but the kernel produces corefiles with OSABI=SysV. */
if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_GNU
&& i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_NONE) /* aka SYSV */
- return FALSE;
+ return false;
}
else
{
but the kernel produces corefiles with OSABI=SysV. */
if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_HPUX
&& i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_NONE) /* aka SYSV */
- return FALSE;
+ return false;
}
flags = i_ehdrp->e_flags;
return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 11);
case EFA_PARISC_2_0:
if (i_ehdrp->e_ident[EI_CLASS] == ELFCLASS64)
- return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 25);
+ return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 25);
else
- return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 20);
+ return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 20);
case EFA_PARISC_2_0 | EF_PARISC_WIDE:
return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 25);
}
/* Don't be fussy. */
- return TRUE;
+ return true;
}
/* Given section type (hdr->sh_type), return a boolean indicating
whether or not the section is an elf64-hppa specific section. */
-static bfd_boolean
+static bool
elf64_hppa_section_from_shdr (bfd *abfd,
Elf_Internal_Shdr *hdr,
const char *name,
{
case SHT_PARISC_EXT:
if (strcmp (name, ".PARISC.archext") != 0)
- return FALSE;
+ return false;
break;
case SHT_PARISC_UNWIND:
if (strcmp (name, ".PARISC.unwind") != 0)
- return FALSE;
+ return false;
break;
case SHT_PARISC_DOC:
case SHT_PARISC_ANNOT:
default:
- return FALSE;
+ return false;
}
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
- return FALSE;
+ return false;
- return TRUE;
+ return ((hdr->sh_flags & SHF_PARISC_SHORT) == 0
+ || bfd_set_section_flags (hdr->bfd_section,
+ hdr->bfd_section->flags | SEC_SMALL_DATA));
}
/* SEC is a section containing relocs for an input BFD when linking; return
a suitable section for holding relocs in the output BFD for a link. */
-static bfd_boolean
+static bool
get_reloc_section (bfd *abfd,
struct elf64_hppa_link_hash_table *hppa_info,
asection *sec)
(abfd, elf_elfheader(abfd)->e_shstrndx,
_bfd_elf_single_rel_hdr(sec)->sh_name));
if (srel_name == NULL)
- return FALSE;
+ return false;
dynobj = hppa_info->root.dynobj;
if (!dynobj)
hppa_info->root.dynobj = dynobj = abfd;
- srel = bfd_get_section_by_name (dynobj, srel_name);
+ srel = bfd_get_linker_section (dynobj, srel_name);
if (srel == NULL)
{
- srel = bfd_make_section_with_flags (dynobj, srel_name,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_LINKER_CREATED
- | SEC_READONLY));
+ srel = bfd_make_section_anyway_with_flags (dynobj, srel_name,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY));
if (srel == NULL
- || !bfd_set_section_alignment (dynobj, srel, 3))
- return FALSE;
+ || !bfd_set_section_alignment (srel, 3))
+ return false;
}
hppa_info->other_rel_sec = srel;
- return TRUE;
+ return true;
}
/* Add a new entry to the list of dynamic relocations against DYN_H.
particular symbol so that we can create FPTR relocations in the
output file. */
-static bfd_boolean
+static bool
count_dyn_reloc (bfd *abfd,
struct elf64_hppa_link_hash_entry *hh,
int type,
asection *sec,
- int sec_symndx,
- bfd_vma offset,
+ int sec_symndx,
+ bfd_vma offset,
bfd_vma addend)
{
struct elf64_hppa_dyn_reloc_entry *rent;
rent = (struct elf64_hppa_dyn_reloc_entry *)
bfd_alloc (abfd, (bfd_size_type) sizeof (*rent));
if (!rent)
- return FALSE;
+ return false;
rent->next = hh->reloc_entries;
rent->type = type;
rent->addend = addend;
hh->reloc_entries = rent;
- return TRUE;
+ return true;
}
/* Return a pointer to the local DLT, PLT and OPD reference counts
{
Elf_Internal_Shdr *symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
bfd_signed_vma *local_refcounts;
-
+
local_refcounts = elf_local_got_refcounts (abfd);
if (local_refcounts == NULL)
{
/* Scan the RELOCS and record the type of dynamic entries that each
referenced symbol needs. */
-static bfd_boolean
+static bool
elf64_hppa_check_relocs (bfd *abfd,
struct bfd_link_info *info,
asection *sec,
const Elf_Internal_Rela *rel;
unsigned int sec_symndx;
- if (info->relocatable)
- return TRUE;
+ if (bfd_link_relocatable (info))
+ return true;
/* If this is the first dynamic object found in the link, create
the special sections required for dynamic linking. */
if (! elf_hash_table (info)->dynamic_sections_created)
{
if (! _bfd_elf_link_create_dynamic_sections (abfd, info))
- return FALSE;
+ return false;
}
hppa_info = hppa_link_hash_table (info);
if (hppa_info == NULL)
- return FALSE;
+ return false;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
/* If necessary, build a new table holding section symbols indices
for this BFD. */
- if (info->shared && hppa_info->section_syms_bfd != abfd)
+ if (bfd_link_pic (info) && hppa_info->section_syms_bfd != abfd)
{
unsigned long i;
unsigned int highest_shndx;
?!? 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)
symtab_hdr->sh_info, 0,
NULL, NULL, NULL);
if (local_syms == NULL)
- return FALSE;
+ return false;
}
/* Record the highest section index referenced by the local symbols. */
relocations when building shared libraries. When not building shared
libraries this value is never really used, but assign it to zero to
prevent out of bounds memory accesses in other routines. */
- if (info->shared)
+ if (bfd_link_pic (info))
{
sec_symndx = _bfd_elf_section_from_bfd_section (abfd, sec);
/* If we did not find a section symbol for this section, then
something went terribly wrong above. */
if (sec_symndx == SHN_BAD)
- return FALSE;
+ return false;
if (sec_symndx < SHN_LORESERVE)
sec_symndx = hppa_info->section_syms[sec_symndx];
unsigned long r_symndx = ELF64_R_SYM (rel->r_info);
struct elf64_hppa_link_hash_entry *hh;
int need_entry;
- bfd_boolean maybe_dynamic;
+ bool maybe_dynamic;
int dynrel_type = R_PARISC_NONE;
static reloc_howto_type *howto;
|| hh->eh.root.type == bfd_link_hash_warning)
hh = hppa_elf_hash_entry (hh->eh.root.u.i.link);
+ /* PR15323, ref flags aren't set for references in the same
+ object. */
hh->eh.ref_regular = 1;
}
else
locally or externally defined, as not all of the input files
have yet been processed. Do something with what we know, as
this may help reduce memory usage and processing time later. */
- maybe_dynamic = FALSE;
- if (hh && ((info->shared
+ maybe_dynamic = false;
+ if (hh && ((bfd_link_pic (info)
&& (!info->symbolic
|| info->unresolved_syms_in_shared_libs == RM_IGNORE))
|| !hh->eh.def_regular
|| hh->eh.root.type == bfd_link_hash_defweak))
- maybe_dynamic = TRUE;
+ maybe_dynamic = true;
howto = elf_hppa_howto_table + ELF64_R_TYPE (rel->r_info);
need_entry = 0;
break;
case R_PARISC_DIR64:
- if (info->shared || maybe_dynamic)
+ if (bfd_link_pic (info) || maybe_dynamic)
need_entry = (NEED_DYNREL);
dynrel_type = R_PARISC_DIR64;
break;
case R_PARISC_LTOFF_FPTR16F:
case R_PARISC_LTOFF_FPTR16WF:
case R_PARISC_LTOFF_FPTR16DF:
- if (info->shared || maybe_dynamic)
+ if (bfd_link_pic (info) || maybe_dynamic)
need_entry = (NEED_DLT | NEED_OPD | NEED_PLT);
else
need_entry = (NEED_DLT | NEED_OPD | NEED_PLT);
/* This is a simple OPD entry. */
case R_PARISC_FPTR64:
- if (info->shared || maybe_dynamic)
+ if (bfd_link_pic (info) || maybe_dynamic)
need_entry = (NEED_OPD | NEED_PLT | NEED_DYNREL);
else
need_entry = (NEED_OPD | NEED_PLT);
else
{
bfd_signed_vma *local_dlt_refcounts;
-
+
/* This is a DLT entry for a local symbol. */
local_dlt_refcounts = hppa64_elf_local_refcounts (abfd);
if (local_dlt_refcounts == NULL)
- return FALSE;
+ return false;
local_dlt_refcounts[r_symndx] += 1;
}
}
if (need_entry & NEED_PLT)
{
- if (! hppa_info->plt_sec
+ if (! hppa_info->root.splt
&& ! get_plt (abfd, info, hppa_info))
goto err_out;
{
bfd_signed_vma *local_dlt_refcounts;
bfd_signed_vma *local_plt_refcounts;
-
+
/* This is a PLT entry for a local symbol. */
local_dlt_refcounts = hppa64_elf_local_refcounts (abfd);
if (local_dlt_refcounts == NULL)
- return FALSE;
+ return false;
local_plt_refcounts = local_dlt_refcounts + symtab_hdr->sh_info;
local_plt_refcounts[r_symndx] += 1;
}
{
bfd_signed_vma *local_dlt_refcounts;
bfd_signed_vma *local_opd_refcounts;
-
+
/* This is a OPD for a local symbol. */
local_dlt_refcounts = hppa64_elf_local_refcounts (abfd);
if (local_dlt_refcounts == NULL)
- return FALSE;
+ return false;
local_opd_refcounts = (local_dlt_refcounts
+ 2 * symtab_hdr->sh_info);
local_opd_refcounts[r_symndx] += 1;
a dynamic R_PARISC_FPTR64 relocation, then make sure the
section symbol for this section ends up in the dynamic
symbol table. */
- if (info->shared && dynrel_type == R_PARISC_FPTR64
+ if (bfd_link_pic (info) && dynrel_type == R_PARISC_FPTR64
&& ! (bfd_elf_link_record_local_dynamic_symbol
(info, abfd, sec_symndx)))
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
err_out:
- return FALSE;
+ return false;
}
struct elf64_hppa_allocate_data
/* Should we do dynamic things to this symbol? */
-static bfd_boolean
+static bool
elf64_hppa_dynamic_symbol_p (struct elf_link_hash_entry *eh,
struct bfd_link_info *info)
{
{
/* ??? Why is this here and not elsewhere is_local_label_name. */
if (eh->root.root.string[0] == '$' && eh->root.root.string[1] == '$')
- return FALSE;
+ return false;
- return TRUE;
+ return true;
}
else
- return FALSE;
+ return false;
}
/* Mark all functions exported by this file so that we can later allocate
entries in .opd for them. */
-static bfd_boolean
+static bool
elf64_hppa_mark_exported_functions (struct elf_link_hash_entry *eh, void *data)
{
struct elf64_hppa_link_hash_entry *hh = hppa_elf_hash_entry (eh);
hppa_info = hppa_link_hash_table (info);
if (hppa_info == NULL)
- return FALSE;
+ return false;
if (eh
&& (eh->root.type == bfd_link_hash_defined
{
if (! hppa_info->opd_sec
&& ! get_opd (hppa_info->root.dynobj, info, hppa_info))
- return FALSE;
+ return false;
hh->want_opd = 1;
eh->needs_plt = 1;
}
- return TRUE;
+ return true;
}
/* Allocate space for a DLT entry. */
-static bfd_boolean
+static bool
allocate_global_data_dlt (struct elf_link_hash_entry *eh, void *data)
{
struct elf64_hppa_link_hash_entry *hh = hppa_elf_hash_entry (eh);
if (hh->want_dlt)
{
- if (x->info->shared)
+ if (bfd_link_pic (x->info))
{
/* Possibly add the symbol to the local dynamic symbol
table since we might need to create a dynamic relocation
if (! (bfd_elf_link_record_local_dynamic_symbol
(x->info, owner, hh->sym_indx)))
- return FALSE;
+ return false;
}
}
hh->dlt_offset = x->ofs;
x->ofs += DLT_ENTRY_SIZE;
}
- return TRUE;
+ return true;
}
/* Allocate space for a DLT.PLT entry. */
-static bfd_boolean
+static bool
allocate_global_data_plt (struct elf_link_hash_entry *eh, void *data)
{
struct elf64_hppa_link_hash_entry *hh = hppa_elf_hash_entry (eh);
hppa_info = hppa_link_hash_table (x->info);
if (hppa_info == NULL)
- return FALSE;
+ return false;
hppa_info->gp_offset = hh->plt_offset;
}
else
hh->want_plt = 0;
- return TRUE;
+ return true;
}
/* Allocate space for a STUB entry. */
-static bfd_boolean
+static bool
allocate_global_data_stub (struct elf_link_hash_entry *eh, void *data)
{
struct elf64_hppa_link_hash_entry *hh = hppa_elf_hash_entry (eh);
}
else
hh->want_stub = 0;
- return TRUE;
+ return true;
}
/* Allocate space for a FPTR entry. */
-static bfd_boolean
+static bool
allocate_global_data_opd (struct elf_link_hash_entry *eh, void *data)
{
struct elf64_hppa_link_hash_entry *hh = hppa_elf_hash_entry (eh);
/* If we are creating a shared library, took the address of a local
function or might export this function from this object file, then
we have to create an opd descriptor. */
- else if (x->info->shared
+ else if (bfd_link_pic (x->info)
|| hh == NULL
|| (hh->eh.dynindx == -1 && hh->eh.type != STT_PARISC_MILLI)
|| (hh->eh.root.type == bfd_link_hash_defined
create a runtime relocation for the symbol to properly
initialize the .opd entry. Make sure the symbol gets
added to the dynamic symbol table. */
- if (x->info->shared
+ if (bfd_link_pic (x->info)
&& (hh == NULL || (hh->eh.dynindx == -1)))
{
bfd *owner;
if (!bfd_elf_link_record_local_dynamic_symbol
(x->info, owner, hh->sym_indx))
- return FALSE;
+ return false;
}
/* This may not be necessary or desirable anymore now that
in dynamic relocs. But name munging does make the result
much easier to debug. ie, the EPLT reloc will reference
a symbol like .foobar, instead of .text + offset. */
- if (x->info->shared && eh)
+ if (bfd_link_pic (x->info) && eh)
{
char *new_name;
struct elf_link_hash_entry *nh;
- new_name = alloca (strlen (eh->root.root.string) + 2);
- new_name[0] = '.';
- strcpy (new_name + 1, eh->root.root.string);
+ new_name = concat (".", eh->root.root.string, NULL);
nh = elf_link_hash_lookup (elf_hash_table (x->info),
- new_name, TRUE, TRUE, TRUE);
+ new_name, true, true, true);
+ free (new_name);
nh->root.type = eh->root.type;
nh->root.u.def.value = eh->root.u.def.value;
nh->root.u.def.section = eh->root.u.def.section;
if (! bfd_elf_link_record_dynamic_symbol (x->info, nh))
- return FALSE;
-
+ return false;
}
hh->opd_offset = x->ofs;
x->ofs += OPD_ENTRY_SIZE;
else
hh->want_opd = 0;
}
- return TRUE;
+ return true;
}
/* HP requires the EI_OSABI field to be filled in. The assignment to
EI_ABIVERSION may not be strictly necessary. */
-static void
-elf64_hppa_post_process_headers (bfd *abfd,
- struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
+static bool
+elf64_hppa_init_file_header (bfd *abfd, struct bfd_link_info *info)
{
- Elf_Internal_Ehdr * i_ehdrp;
+ Elf_Internal_Ehdr *i_ehdrp;
+
+ if (!_bfd_elf_init_file_header (abfd, info))
+ return false;
i_ehdrp = elf_elfheader (abfd);
-
i_ehdrp->e_ident[EI_OSABI] = get_elf_backend_data (abfd)->elf_osabi;
i_ehdrp->e_ident[EI_ABIVERSION] = 1;
+ return true;
}
/* Create function descriptor section (.opd). This section is called .opd
refers to the fact that these descriptors are used when taking the address
of a procedure, thus ensuring a unique address for each procedure. */
-static bfd_boolean
+static bool
get_opd (bfd *abfd,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
struct elf64_hppa_link_hash_table *hppa_info)
if (!dynobj)
hppa_info->root.dynobj = dynobj = abfd;
- opd = bfd_make_section_with_flags (dynobj, ".opd",
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_LINKER_CREATED));
+ opd = bfd_make_section_anyway_with_flags (dynobj, ".opd",
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED));
if (!opd
- || !bfd_set_section_alignment (abfd, opd, 3))
+ || !bfd_set_section_alignment (opd, 3))
{
BFD_ASSERT (0);
- return FALSE;
+ return false;
}
hppa_info->opd_sec = opd;
}
- return TRUE;
+ return true;
}
/* Create the PLT section. */
-static bfd_boolean
+static bool
get_plt (bfd *abfd,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
struct elf64_hppa_link_hash_table *hppa_info)
asection *plt;
bfd *dynobj;
- plt = hppa_info->plt_sec;
+ plt = hppa_info->root.splt;
if (!plt)
{
dynobj = hppa_info->root.dynobj;
if (!dynobj)
hppa_info->root.dynobj = dynobj = abfd;
- plt = bfd_make_section_with_flags (dynobj, ".plt",
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_LINKER_CREATED));
+ plt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED));
if (!plt
- || !bfd_set_section_alignment (abfd, plt, 3))
+ || !bfd_set_section_alignment (plt, 3))
{
BFD_ASSERT (0);
- return FALSE;
+ return false;
}
- hppa_info->plt_sec = plt;
+ hppa_info->root.splt = plt;
}
- return TRUE;
+ return true;
}
/* Create the DLT section. */
-static bfd_boolean
+static bool
get_dlt (bfd *abfd,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
struct elf64_hppa_link_hash_table *hppa_info)
if (!dynobj)
hppa_info->root.dynobj = dynobj = abfd;
- dlt = bfd_make_section_with_flags (dynobj, ".dlt",
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_LINKER_CREATED));
+ dlt = bfd_make_section_anyway_with_flags (dynobj, ".dlt",
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED));
if (!dlt
- || !bfd_set_section_alignment (abfd, dlt, 3))
+ || !bfd_set_section_alignment (dlt, 3))
{
BFD_ASSERT (0);
- return FALSE;
+ return false;
}
hppa_info->dlt_sec = dlt;
}
- return TRUE;
+ return true;
}
/* Create the stubs section. */
-static bfd_boolean
+static bool
get_stub (bfd *abfd,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
struct elf64_hppa_link_hash_table *hppa_info)
if (!dynobj)
hppa_info->root.dynobj = dynobj = abfd;
- stub = bfd_make_section_with_flags (dynobj, ".stub",
- (SEC_ALLOC | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY
- | SEC_LINKER_CREATED));
+ stub = bfd_make_section_anyway_with_flags (dynobj, ".stub",
+ (SEC_ALLOC | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_READONLY
+ | SEC_LINKER_CREATED));
if (!stub
- || !bfd_set_section_alignment (abfd, stub, 3))
+ || !bfd_set_section_alignment (stub, 3))
{
BFD_ASSERT (0);
- return FALSE;
+ return false;
}
hppa_info->stub_sec = stub;
}
- return TRUE;
+ return true;
}
/* Create sections necessary for dynamic linking. This is only a rough
.rela.opd:
EPLT relocations for symbols exported from shared libraries. */
-static bfd_boolean
+static bool
elf64_hppa_create_dynamic_sections (bfd *abfd,
struct bfd_link_info *info)
{
hppa_info = hppa_link_hash_table (info);
if (hppa_info == NULL)
- return FALSE;
+ return false;
if (! get_stub (abfd, info, hppa_info))
- return FALSE;
+ return false;
if (! get_dlt (abfd, info, hppa_info))
- return FALSE;
+ return false;
if (! get_plt (abfd, info, hppa_info))
- return FALSE;
+ return false;
if (! get_opd (abfd, info, hppa_info))
- return FALSE;
-
- s = bfd_make_section_with_flags (abfd, ".rela.dlt",
- (SEC_ALLOC | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY
- | SEC_LINKER_CREATED));
+ return false;
+
+ s = bfd_make_section_anyway_with_flags (abfd, ".rela.dlt",
+ (SEC_ALLOC | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_READONLY
+ | SEC_LINKER_CREATED));
if (s == NULL
- || !bfd_set_section_alignment (abfd, s, 3))
- return FALSE;
+ || !bfd_set_section_alignment (s, 3))
+ return false;
hppa_info->dlt_rel_sec = s;
- s = bfd_make_section_with_flags (abfd, ".rela.plt",
- (SEC_ALLOC | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY
- | SEC_LINKER_CREATED));
+ s = bfd_make_section_anyway_with_flags (abfd, ".rela.plt",
+ (SEC_ALLOC | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_READONLY
+ | SEC_LINKER_CREATED));
if (s == NULL
- || !bfd_set_section_alignment (abfd, s, 3))
- return FALSE;
- hppa_info->plt_rel_sec = s;
-
- s = bfd_make_section_with_flags (abfd, ".rela.data",
- (SEC_ALLOC | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY
- | SEC_LINKER_CREATED));
+ || !bfd_set_section_alignment (s, 3))
+ return false;
+ hppa_info->root.srelplt = s;
+
+ s = bfd_make_section_anyway_with_flags (abfd, ".rela.data",
+ (SEC_ALLOC | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_READONLY
+ | SEC_LINKER_CREATED));
if (s == NULL
- || !bfd_set_section_alignment (abfd, s, 3))
- return FALSE;
+ || !bfd_set_section_alignment (s, 3))
+ return false;
hppa_info->other_rel_sec = s;
- s = bfd_make_section_with_flags (abfd, ".rela.opd",
- (SEC_ALLOC | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY
- | SEC_LINKER_CREATED));
+ s = bfd_make_section_anyway_with_flags (abfd, ".rela.opd",
+ (SEC_ALLOC | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_READONLY
+ | SEC_LINKER_CREATED));
if (s == NULL
- || !bfd_set_section_alignment (abfd, s, 3))
- return FALSE;
+ || !bfd_set_section_alignment (s, 3))
+ return false;
hppa_info->opd_rel_sec = s;
- return TRUE;
+ return true;
}
/* Allocate dynamic relocations for those symbols that turned out
to be dynamic. */
-static bfd_boolean
+static bool
allocate_dynrel_entries (struct elf_link_hash_entry *eh, void *data)
{
struct elf64_hppa_link_hash_entry *hh = hppa_elf_hash_entry (eh);
struct elf64_hppa_allocate_data *x = (struct elf64_hppa_allocate_data *)data;
struct elf64_hppa_link_hash_table *hppa_info;
struct elf64_hppa_dyn_reloc_entry *rent;
- bfd_boolean dynamic_symbol, shared;
+ bool dynamic_symbol, shared;
hppa_info = hppa_link_hash_table (x->info);
if (hppa_info == NULL)
- return FALSE;
+ return false;
dynamic_symbol = elf64_hppa_dynamic_symbol_p (eh, x->info);
- shared = x->info->shared;
+ shared = bfd_link_pic (x->info);
/* We may need to allocate relocations for a non-dynamic symbol
when creating a shared library. */
if (!dynamic_symbol && !shared)
- return TRUE;
+ return true;
/* Take care of the normal data relocations. */
if (eh->dynindx == -1 && eh->type != STT_PARISC_MILLI)
if (!bfd_elf_link_record_local_dynamic_symbol
(x->info, rent->sec->owner, hh->sym_indx))
- return FALSE;
+ return false;
}
/* Take care of the GOT and PLT relocations. */
else if (shared)
t = 2 * sizeof (Elf64_External_Rela);
- hppa_info->plt_rel_sec->size += t;
+ hppa_info->root.srelplt->size += t;
}
- return TRUE;
+ return true;
}
/* Adjust a symbol defined by a dynamic object and referenced by a
regular object. */
-static bfd_boolean
+static bool
elf64_hppa_adjust_dynamic_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED,
struct elf_link_hash_entry *eh)
{
/* If this is a weak symbol, and there is a real definition, the
processor independent code will have arranged for us to see the
real definition first, and we can just use the same value. */
- if (eh->u.weakdef != NULL)
+ if (eh->is_weakalias)
{
- BFD_ASSERT (eh->u.weakdef->root.type == bfd_link_hash_defined
- || eh->u.weakdef->root.type == bfd_link_hash_defweak);
- eh->root.u.def.section = eh->u.weakdef->root.u.def.section;
- eh->root.u.def.value = eh->u.weakdef->root.u.def.value;
- return TRUE;
+ struct elf_link_hash_entry *def = weakdef (eh);
+ BFD_ASSERT (def->root.type == bfd_link_hash_defined);
+ eh->root.u.def.section = def->root.u.def.section;
+ eh->root.u.def.value = def->root.u.def.value;
+ return true;
}
/* If this is a reference to a symbol defined by a dynamic object which
But PA64 code is canonically PIC, so as a rule we can avoid this sort
of hackery. */
- return TRUE;
+ return true;
}
/* This function is called via elf_link_hash_traverse to mark millicode
from the dynamic symbol table. If the symbol is not a millicode symbol,
elf64_hppa_mark_exported_functions is called. */
-static bfd_boolean
+static bool
elf64_hppa_mark_milli_and_exported_functions (struct elf_link_hash_entry *eh,
void *data)
{
_bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
eh->dynstr_index);
}
- return TRUE;
+ return true;
}
return elf64_hppa_mark_exported_functions (eh, data);
/* Set the final sizes of the dynamic sections and allocate memory for
the contents of our special sections. */
-static bfd_boolean
+static bool
elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
{
struct elf64_hppa_link_hash_table *hppa_info;
bfd *dynobj;
bfd *ibfd;
asection *sec;
- bfd_boolean plt;
- bfd_boolean relocs;
- bfd_boolean reltext;
+ bool relocs;
hppa_info = hppa_link_hash_table (info);
if (hppa_info == NULL)
- return FALSE;
+ return false;
- dynobj = elf_hash_table (info)->dynobj;
+ dynobj = hppa_info->root.dynobj;
BFD_ASSERT (dynobj != NULL);
/* Mark each function this program exports so that we will allocate
We have to traverse the main linker hash table since we have to
find functions which may not have been mentioned in any relocs. */
- elf_link_hash_traverse (elf_hash_table (info),
- (elf_hash_table (info)->dynamic_sections_created
+ elf_link_hash_traverse (&hppa_info->root,
+ (hppa_info->root.dynamic_sections_created
? elf64_hppa_mark_milli_and_exported_functions
: elf64_hppa_mark_exported_functions),
info);
- if (elf_hash_table (info)->dynamic_sections_created)
+ if (hppa_info->root.dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (info->executable)
+ if (bfd_link_executable (info) && !info->nointerp)
{
- sec = bfd_get_section_by_name (dynobj, ".interp");
+ sec = bfd_get_linker_section (dynobj, ".interp");
BFD_ASSERT (sec != NULL);
sec->size = sizeof ELF_DYNAMIC_INTERPRETER;
sec->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
not actually use these entries. Reset the size of .rela.dlt,
which will cause it to get stripped from the output file
below. */
- sec = bfd_get_section_by_name (dynobj, ".rela.dlt");
+ sec = hppa_info->dlt_rel_sec;
if (sec != NULL)
sec->size = 0;
}
/* Set up DLT, PLT and OPD offsets for local syms, and space for local
dynamic relocs. */
- for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
{
bfd_signed_vma *local_dlt;
bfd_signed_vma *end_local_dlt;
{
*local_dlt = sec->size;
sec->size += DLT_ENTRY_SIZE;
- if (info->shared)
- {
+ if (bfd_link_pic (info))
+ {
srel->size += sizeof (Elf64_External_Rela);
- }
+ }
}
else
*local_dlt = (bfd_vma) -1;
}
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)
{
*local_plt = sec->size;
sec->size += PLT_ENTRY_SIZE;
- if (info->shared)
+ if (bfd_link_pic (info))
srel->size += sizeof (Elf64_External_Rela);
}
else
{
*local_opd = sec->size;
sec->size += OPD_ENTRY_SIZE;
- if (info->shared)
+ if (bfd_link_pic (info))
srel->size += sizeof (Elf64_External_Rela);
}
else
if (hppa_info->dlt_sec)
{
data.ofs = hppa_info->dlt_sec->size;
- elf_link_hash_traverse (elf_hash_table (info),
+ elf_link_hash_traverse (&hppa_info->root,
allocate_global_data_dlt, &data);
hppa_info->dlt_sec->size = data.ofs;
}
- if (hppa_info->plt_sec)
+ if (hppa_info->root.splt)
{
- data.ofs = hppa_info->plt_sec->size;
- elf_link_hash_traverse (elf_hash_table (info),
- allocate_global_data_plt, &data);
- hppa_info->plt_sec->size = data.ofs;
+ data.ofs = hppa_info->root.splt->size;
+ elf_link_hash_traverse (&hppa_info->root,
+ allocate_global_data_plt, &data);
+ hppa_info->root.splt->size = data.ofs;
}
if (hppa_info->stub_sec)
{
data.ofs = 0x0;
- elf_link_hash_traverse (elf_hash_table (info),
+ elf_link_hash_traverse (&hppa_info->root,
allocate_global_data_stub, &data);
hppa_info->stub_sec->size = data.ofs;
}
if (hppa_info->opd_sec)
{
data.ofs = hppa_info->opd_sec->size;
- elf_link_hash_traverse (elf_hash_table (info),
+ elf_link_hash_traverse (&hppa_info->root,
allocate_global_data_opd, &data);
hppa_info->opd_sec->size = data.ofs;
}
/* Now allocate space for dynamic relocations, if necessary. */
if (hppa_info->root.dynamic_sections_created)
- elf_link_hash_traverse (elf_hash_table (info),
+ elf_link_hash_traverse (&hppa_info->root,
allocate_dynrel_entries, &data);
/* The sizes of all the sections are set. Allocate memory for them. */
- plt = FALSE;
- relocs = FALSE;
- reltext = FALSE;
+ relocs = false;
for (sec = dynobj->sections; sec != NULL; sec = sec->next)
{
const char *name;
/* 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, sec);
+ name = bfd_section_name (sec);
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_get_section_name (output_bfd,
- 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. */
{
sec->contents = (bfd_byte *) bfd_zalloc (dynobj, sec->size);
if (sec->contents == NULL)
- return FALSE;
+ return false;
}
}
- if (elf_hash_table (info)->dynamic_sections_created)
+ if (hppa_info->root.dynamic_sections_created)
{
/* Always create a DT_PLTGOT. It actually has nothing to do with
the PLT, it is how we communicate the __gp value of a load
#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))
- return FALSE;
+ if (!add_dynamic_entry (DT_HP_DLD_FLAGS, 0))
+ return false;
/* Add some entries to the .dynamic section. We fill in the
values later, in elf64_hppa_finish_dynamic_sections, but we
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
- if (! info->shared)
+ 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;
+ return false;
}
/* Force DT_FLAGS to always be set.
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;
- }
+ return false;
}
#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
/* Finish up dynamic symbol handling. We set the contents of various
dynamic sections here. */
-static bfd_boolean
+static bool
elf64_hppa_finish_dynamic_symbol (bfd *output_bfd,
struct bfd_link_info *info,
struct elf_link_hash_entry *eh,
hppa_info = hppa_link_hash_table (info);
if (hppa_info == NULL)
- return FALSE;
+ 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.
if we are creating a shared library and the symbol is
still undefined, we create a dynamic relocation to fill
in the correct value. */
- if (info->shared && eh->root.type == bfd_link_hash_undefined)
+ if (bfd_link_pic (info) && eh->root.type == bfd_link_hash_undefined)
value = 0;
else
value = (eh->root.u.def.value + eh->root.u.def.section->vma);
in the output_offset of the PLT section. */
bfd_put_64 (splt->owner, value, splt->contents + hh->plt_offset);
- value = _bfd_get_gp_value (splt->output_section->owner);
+ value = _bfd_get_gp_value (info->output_bfd);
bfd_put_64 (splt->owner, value, splt->contents + hh->plt_offset + 0x8);
/* Create a dynamic IPLT relocation for this entry.
loc = spltrel->contents;
loc += spltrel->reloc_count++ * sizeof (Elf64_External_Rela);
- bfd_elf64_swap_reloca_out (splt->output_section->owner, &rel, loc);
+ bfd_elf64_swap_reloca_out (info->output_bfd, &rel, loc);
}
/* Initialize an external call stub entry if requested. */
if ((value & 7) || value + max_offset >= 2*max_offset - 8)
{
- (*_bfd_error_handler) (_("stub entry for %s cannot load .plt, dp offset = %ld"),
- hh->eh.root.root.string,
- (long) value);
- return FALSE;
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("stub entry for %s cannot load .plt, dp offset = %" PRId64),
+ hh->eh.root.root.string, (int64_t) value);
+ return false;
}
bfd_put_32 (stub->owner, (bfd_vma) insn,
stub->contents + hh->stub_offset + 8);
}
- return TRUE;
+ return true;
}
/* The .opd section contains FPTRs for each function this file
exports. Initialize the FPTR entries. */
-static bfd_boolean
+static bool
elf64_hppa_finalize_opd (struct elf_link_hash_entry *eh, void *data)
{
struct elf64_hppa_link_hash_entry *hh = hppa_elf_hash_entry (eh);
hppa_info = hppa_link_hash_table (info);
if (hppa_info == NULL)
- return FALSE;
+ return false;
sopd = hppa_info->opd_sec;
sopdrel = hppa_info->opd_rel_sec;
bfd_put_64 (sopd->owner, value, sopd->contents + hh->opd_offset + 16);
/* The last word is our local __gp value. */
- value = _bfd_get_gp_value (sopd->output_section->owner);
+ value = _bfd_get_gp_value (info->output_bfd);
bfd_put_64 (sopd->owner, value, sopd->contents + hh->opd_offset + 24);
}
/* If we are generating a shared library, we must generate EPLT relocations
for each entry in the .opd, even for static functions (they may have
had their address taken). */
- if (info->shared && hh->want_opd)
+ if (bfd_link_pic (info) && hh->want_opd)
{
Elf_Internal_Rela rel;
bfd_byte *loc;
char *new_name;
struct elf_link_hash_entry *nh;
- new_name = alloca (strlen (eh->root.root.string) + 2);
- new_name[0] = '.';
- strcpy (new_name + 1, eh->root.root.string);
+ new_name = concat (".", eh->root.root.string, NULL);
nh = elf_link_hash_lookup (elf_hash_table (info),
- new_name, TRUE, TRUE, FALSE);
-
+ new_name, true, true, false);
+
/* All we really want from the new symbol is its dynamic
symbol index. */
if (nh)
dynindx = nh->dynindx;
+ free (new_name);
}
rel.r_addend = 0;
loc = sopdrel->contents;
loc += sopdrel->reloc_count++ * sizeof (Elf64_External_Rela);
- bfd_elf64_swap_reloca_out (sopd->output_section->owner, &rel, loc);
+ bfd_elf64_swap_reloca_out (info->output_bfd, &rel, loc);
}
- return TRUE;
+ return true;
}
/* The .dlt section contains addresses for items referenced through the
dlt. Note that we can have a DLTIND relocation for a local symbol, thus
we can not depend on finish_dynamic_symbol to initialize the .dlt. */
-static bfd_boolean
+static bool
elf64_hppa_finalize_dlt (struct elf_link_hash_entry *eh, void *data)
{
struct elf64_hppa_link_hash_entry *hh = hppa_elf_hash_entry (eh);
hppa_info = hppa_link_hash_table (info);
if (hppa_info == NULL)
- return FALSE;
+ return false;
sdlt = hppa_info->dlt_sec;
sdltrel = hppa_info->dlt_rel_sec;
address, so there is no need to create a relocation. Just install
the proper value into the DLT, note this shortcut can not be
skipped when building a shared library. */
- if (! info->shared && hh && hh->want_dlt)
+ if (! bfd_link_pic (info) && hh && hh->want_dlt)
{
bfd_vma value;
/* Create a relocation for the DLT entry associated with this symbol.
When building a shared library the symbol does not have to be dynamic. */
if (hh->want_dlt
- && (elf64_hppa_dynamic_symbol_p (eh, info) || info->shared))
+ && (elf64_hppa_dynamic_symbol_p (eh, info) || bfd_link_pic (info)))
{
Elf_Internal_Rela rel;
bfd_byte *loc;
loc = sdltrel->contents;
loc += sdltrel->reloc_count++ * sizeof (Elf64_External_Rela);
- bfd_elf64_swap_reloca_out (sdlt->output_section->owner, &rel, loc);
+ bfd_elf64_swap_reloca_out (info->output_bfd, &rel, loc);
}
- return TRUE;
+ return true;
}
/* Finalize the dynamic relocations. Specifically the FPTR relocations
for dynamic functions used to initialize static data. */
-static bfd_boolean
+static bool
elf64_hppa_finalize_dynreloc (struct elf_link_hash_entry *eh,
void *data)
{
dynamic_symbol = elf64_hppa_dynamic_symbol_p (eh, info);
- if (!dynamic_symbol && !info->shared)
- return TRUE;
+ if (!dynamic_symbol && !bfd_link_pic (info))
+ return true;
if (hh->reloc_entries)
{
hppa_info = hppa_link_hash_table (info);
if (hppa_info == NULL)
- return FALSE;
+ return false;
/* We may need to do a relocation against a local symbol, in
which case we have to look up it's dynamic symbol index off
/* Allocate one iff we are building a shared library, the relocation
isn't a R_PARISC_FPTR64, or we don't want an opd entry. */
- if (!info->shared && rent->type == R_PARISC_FPTR64 && hh->want_opd)
+ if (!bfd_link_pic (info)
+ && rent->type == R_PARISC_FPTR64 && hh->want_opd)
continue;
/* Create a dynamic relocation for this entry.
We use a section symbol recorded by check_relocs as the
base symbol for the relocation. The addend is the difference
between the section symbol and the address of the .opd entry. */
- if (info->shared && rent->type == R_PARISC_FPTR64 && hh->want_opd)
+ if (bfd_link_pic (info)
+ && rent->type == R_PARISC_FPTR64 && hh->want_opd)
{
bfd_vma value, value2;
loc = hppa_info->other_rel_sec->contents;
loc += (hppa_info->other_rel_sec->reloc_count++
* sizeof (Elf64_External_Rela));
- bfd_elf64_swap_reloca_out (hppa_info->other_rel_sec->output_section->owner,
- &rel, loc);
+ bfd_elf64_swap_reloca_out (info->output_bfd, &rel, loc);
}
}
- return TRUE;
+ return true;
}
/* Used to decide how to sort relocs in an optimal manner for the
dynamic linker, before writing them out. */
static enum elf_reloc_type_class
-elf64_hppa_reloc_type_class (const Elf_Internal_Rela *rela)
+elf64_hppa_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ const asection *rel_sec ATTRIBUTE_UNUSED,
+ const Elf_Internal_Rela *rela)
{
if (ELF64_R_SYM (rela->r_info) == STN_UNDEF)
return reloc_class_relative;
/* Finish up the dynamic sections. */
-static bfd_boolean
+static bool
elf64_hppa_finish_dynamic_sections (bfd *output_bfd,
struct bfd_link_info *info)
{
hppa_info = hppa_link_hash_table (info);
if (hppa_info == NULL)
- return FALSE;
+ return false;
/* Finalize the contents of the .opd section. */
elf_link_hash_traverse (elf_hash_table (info),
elf64_hppa_finalize_dlt,
info);
- sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+ sdyn = bfd_get_linker_section (dynobj, ".dynamic");
if (elf_hash_table (info)->dynamic_sections_created)
{
area at the start of the .data section. So all we have to
to is find the start of the .data section. */
s = bfd_get_section_by_name (output_bfd, ".data");
+ if (!s)
+ return false;
dyn.d_un.d_ptr = s->vma;
bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
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;
}
}
- return TRUE;
+ return true;
}
/* Support for core dump NOTE sections. */
-static bfd_boolean
+static bool
elf64_hppa_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
{
int offset;
switch (note->descsz)
{
default:
- return FALSE;
+ return false;
case 760: /* Linux/hppa */
/* pr_cursig */
- elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+ elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 32);
+ elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 32);
/* pr_reg */
offset = 112;
size, note->descpos + offset);
}
-static bfd_boolean
+static bool
elf64_hppa_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
{
char * command;
switch (note->descsz)
{
default:
- return FALSE;
+ return false;
case 136: /* Linux/hppa elf_prpsinfo. */
- elf_tdata (abfd)->core_program
+ elf_tdata (abfd)->core->program
= _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
- elf_tdata (abfd)->core_command
+ elf_tdata (abfd)->core->command
= _bfd_elfcore_strndup (abfd, note->descdata + 56, 80);
}
/* Note that for some reason, a spurious space is tacked
onto the end of the args in some (at least one anyway)
implementations, so strip it off if it exists. */
- command = elf_tdata (abfd)->core_command;
+ command = elf_tdata (abfd)->core->command;
n = strlen (command);
if (0 < n && command[n - 1] == ' ')
command[n - 1] = '\0';
- return TRUE;
+ return true;
}
/* Return the number of additional phdrs we will need.
return 0;
}
+static bool
+elf64_hppa_allow_non_load_phdr (bfd *abfd ATTRIBUTE_UNUSED,
+ const Elf_Internal_Phdr *phdr ATTRIBUTE_UNUSED,
+ unsigned int count ATTRIBUTE_UNUSED)
+{
+ return true;
+}
+
/* Allocate and initialize any program headers required by this
specific backend.
to guess whether or not we are building a shared library based on the
existence of a .interp section. */
-static bfd_boolean
-elf64_hppa_modify_segment_map (bfd *abfd,
- struct bfd_link_info *info ATTRIBUTE_UNUSED)
+static bool
+elf64_hppa_modify_segment_map (bfd *abfd, struct bfd_link_info *info)
{
struct elf_segment_map *m;
- asection *s;
- s = bfd_get_section_by_name (abfd, ".interp");
- if (! s)
+ m = elf_seg_map (abfd);
+ if (info != NULL && !info->user_phdrs && m != NULL && m->p_type != PT_PHDR)
{
- for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
- if (m->p_type == PT_PHDR)
- break;
+ m = ((struct elf_segment_map *)
+ bfd_zalloc (abfd, (bfd_size_type) sizeof *m));
if (m == NULL)
- {
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd, (bfd_size_type) sizeof *m));
- if (m == NULL)
- return FALSE;
-
- m->p_type = PT_PHDR;
- m->p_flags = PF_R | PF_X;
- m->p_flags_valid = 1;
- m->p_paddr_valid = 1;
- m->includes_phdrs = 1;
-
- m->next = elf_tdata (abfd)->segment_map;
- elf_tdata (abfd)->segment_map = m;
- }
+ return false;
+
+ m->p_type = PT_PHDR;
+ m->p_flags = PF_R | PF_X;
+ m->p_flags_valid = 1;
+ m->p_paddr_valid = 1;
+ m->includes_phdrs = 1;
+
+ m->next = elf_seg_map (abfd);
+ elf_seg_map (abfd) = m;
}
- for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+ for (m = elf_seg_map (abfd) ; m != NULL; m = m->next)
if (m->p_type == PT_LOAD)
{
unsigned int i;
}
}
- return TRUE;
+ return true;
}
/* Called when writing out an object file to decide the type of a
/* Support HP specific sections for core files. */
-static bfd_boolean
+static bool
elf64_hppa_section_from_phdr (bfd *abfd, Elf_Internal_Phdr *hdr, int sec_index,
const char *typename)
{
asection *sect;
if (!_bfd_elf_make_section_from_phdr (abfd, hdr, sec_index, typename))
- return FALSE;
+ return false;
sect = bfd_make_section_anyway (abfd, ".kernel");
if (sect == NULL)
- return FALSE;
+ return false;
sect->size = hdr->p_filesz;
sect->filepos = hdr->p_offset;
sect->flags = SEC_HAS_CONTENTS | SEC_READONLY;
- return TRUE;
+ return true;
}
if (hdr->p_type == PT_HP_CORE_PROC)
int sig;
if (bfd_seek (abfd, hdr->p_offset, SEEK_SET) != 0)
- return FALSE;
- if (bfd_bread (&sig, 4, abfd) != 4)
- return FALSE;
+ return false;
+ if (bfd_read (&sig, 4, abfd) != 4)
+ return false;
- elf_tdata (abfd)->core_signal = sig;
+ elf_tdata (abfd)->core->signal = sig;
if (!_bfd_elf_make_section_from_phdr (abfd, hdr, sec_index, typename))
- return FALSE;
+ return false;
/* GDB uses the ".reg" section to read register contents. */
return _bfd_elfcore_make_pseudosection (abfd, ".reg", hdr->p_filesz,
file. HP's libraries define symbols with HP specific section
indices, which we have to handle. */
-static bfd_boolean
+static bool
elf_hppa_add_symbol_hook (bfd *abfd,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
Elf_Internal_Sym *sym,
break;
}
- return TRUE;
+ return true;
}
-static bfd_boolean
+static bool
elf_hppa_unmark_useless_dynamic_symbols (struct elf_link_hash_entry *h,
void *data)
{
Ultimately we should have better controls over the generic ELF BFD
linker code. */
- if (! info->relocatable
+ if (! bfd_link_relocatable (info)
&& info->unresolved_syms_in_shared_libs != RM_IGNORE
&& h->root.type == bfd_link_hash_undefined
&& h->ref_dynamic
h->pointer_equality_needed = 1;
}
- return TRUE;
+ return true;
}
-static bfd_boolean
+static bool
elf_hppa_remark_useless_dynamic_symbols (struct elf_link_hash_entry *h,
void *data)
{
Ultimately we should have better controls over the generic ELF BFD
linker code. */
- if (! info->relocatable
+ if (! bfd_link_relocatable (info)
&& info->unresolved_syms_in_shared_libs != RM_IGNORE
&& h->root.type == bfd_link_hash_undefined
&& !h->ref_dynamic
h->pointer_equality_needed = 0;
}
- return TRUE;
+ return true;
}
-static bfd_boolean
+static bool
elf_hppa_is_dynamic_loader_symbol (const char *name)
{
return (! strcmp (name, "__CPU_REVISION")
We use this hook to (possibly) provide a value for __gp, then we
fall back to the generic ELF final link routine. */
-static bfd_boolean
+static bool
elf_hppa_final_link (bfd *abfd, struct bfd_link_info *info)
{
- bfd_boolean retval;
+ struct stat buf;
struct elf64_hppa_link_hash_table *hppa_info = hppa_link_hash_table (info);
if (hppa_info == NULL)
- return FALSE;
+ return false;
- if (! info->relocatable)
+ if (! bfd_link_relocatable (info))
{
struct elf_link_hash_entry *gp;
bfd_vma gp_val;
by one of the objects being linked. First try to find the symbol
in the hash table. If that fails, just compute the value __gp
should have had. */
- gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE,
- FALSE, FALSE);
+ gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", false,
+ false, false);
if (gp)
{
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
info);
/* Invoke the regular ELF backend linker to do all the work. */
- retval = bfd_elf_final_link (abfd, info);
+ if (!bfd_elf_final_link (abfd, info))
+ return false;
elf_link_hash_traverse (elf_hash_table (info),
elf_hppa_remark_useless_dynamic_symbols,
/* If we're producing a final executable, sort the contents of the
unwind section. */
- if (retval && !info->relocatable)
- retval = elf_hppa_sort_unwind (abfd);
+ if (bfd_link_relocatable (info))
+ return true;
+
+ /* Do not attempt to sort non-regular files. This is here
+ especially for configure scripts and kernel builds which run
+ tests with "ld [...] -o /dev/null". */
+ if (stat (bfd_get_filename (abfd), &buf) != 0
+ || !S_ISREG(buf.st_mode))
+ return true;
- return retval;
+ return elf_hppa_sort_unwind (abfd);
}
/* Relocate the given INSN. VALUE should be the actual value we want
if (hppa_info == NULL)
return bfd_reloc_notsupported;
-
+
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
local_offsets = elf_local_got_offsets (input_bfd);
insn = bfd_get_32 (input_bfd, hit_data);
if (max_branch_offset != 0
&& value + addend + max_branch_offset >= 2*max_branch_offset)
{
- (*_bfd_error_handler)
- (_("%B(%A+0x" BFD_VMA_FMT "x): cannot reach %s"),
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB(%pA+%#" PRIx64 "): cannot reach %s"),
input_bfd,
input_section,
- offset,
+ (uint64_t) offset,
eh ? eh->root.root.string : "unknown");
bfd_set_error (bfd_error_bad_value);
return bfd_reloc_overflow;
{
bfd_vma *local_opd_offsets, *local_dlt_offsets;
- if (local_offsets == NULL)
- abort ();
+ if (local_offsets == NULL)
+ abort ();
/* Now do .opd creation if needed. */
if (r_type == R_PARISC_LTOFF_FPTR14R
(hppa_info->opd_sec->contents + off + 16));
/* The last word is our local __gp value. */
- value = _bfd_get_gp_value
- (hppa_info->opd_sec->output_section->owner);
+ value = _bfd_get_gp_value (info->output_bfd);
bfd_put_64 (hppa_info->opd_sec->owner, value,
(hppa_info->opd_sec->contents + off + 24));
}
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_LTOFF_FPTR32:
{
- /* We may still need to create the FPTR itself if it was for
- a local symbol. */
- if (hh == NULL)
- {
- /* The first two words of an .opd entry are zero. */
- memset (hppa_info->opd_sec->contents + hh->opd_offset, 0, 16);
-
- /* The next word is the address of the function. */
- bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
- (hppa_info->opd_sec->contents
- + hh->opd_offset + 16));
-
- /* The last word is our local __gp value. */
- value = _bfd_get_gp_value
- (hppa_info->opd_sec->output_section->owner);
- bfd_put_64 (hppa_info->opd_sec->owner, value,
- hppa_info->opd_sec->contents + hh->opd_offset + 24);
-
- /* The DLT value is the address of the .opd entry. */
- value = (hh->opd_offset
- + hppa_info->opd_sec->output_offset
- + hppa_info->opd_sec->output_section->vma);
-
- bfd_put_64 (hppa_info->dlt_sec->owner,
- value,
- hppa_info->dlt_sec->contents + hh->dlt_offset);
- }
+ /* FIXME: There used to be code here to create the FPTR itself if
+ the relocation was against a local symbol. But the code could
+ never have worked. If the assert below is ever triggered then
+ the code will need to be reinstated and fixed so that it does
+ what is needed. */
+ BFD_ASSERT (hh != NULL);
/* We want the value of the DLT offset for this symbol, not
the symbol's actual address. Note that __gp may not point
+ hh->opd_offset + 16));
/* The last word is our local __gp value. */
- value = _bfd_get_gp_value
- (hppa_info->opd_sec->output_section->owner);
+ value = _bfd_get_gp_value (info->output_bfd);
bfd_put_64 (hppa_info->opd_sec->owner, value,
hppa_info->opd_sec->contents + hh->opd_offset + 24);
{
bfd_vma *local_opd_offsets;
- if (local_offsets == NULL)
- abort ();
+ if (local_offsets == NULL)
+ abort ();
local_opd_offsets = local_offsets + 2 * symtab_hdr->sh_info;
off = local_opd_offsets[r_symndx];
if ((off & 1) != 0)
{
BFD_ASSERT (off != (bfd_vma) -1);
- off &= ~1;
+ off &= ~1;
}
else
{
(hppa_info->opd_sec->contents + off + 16));
/* The last word is our local __gp value. */
- value = _bfd_get_gp_value
- (hppa_info->opd_sec->output_section->owner);
+ value = _bfd_get_gp_value (info->output_bfd);
bfd_put_64 (hppa_info->opd_sec->owner, value,
hppa_info->opd_sec->contents + off + 24);
}
}
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;
/* Relocate an HPPA ELF section. */
-static bfd_boolean
+static int
elf64_hppa_relocate_section (bfd *output_bfd,
struct bfd_link_info *info,
bfd *input_bfd,
hppa_info = hppa_link_hash_table (info);
if (hppa_info == NULL)
- return FALSE;
+ return false;
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED)
{
bfd_set_error (bfd_error_bad_value);
- return FALSE;
+ return false;
}
if (r_type == (unsigned int) R_PARISC_GNU_VTENTRY
|| r_type == (unsigned int) R_PARISC_GNU_VTINHERIT)
/* This is not a local symbol. */
struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
- /* It seems this can happen with erroneous or unsupported
+ /* It seems this can happen with erroneous or unsupported
input (mixing a.out and elf in an archive, for example.) */
if (sym_hashes == NULL)
- return FALSE;
+ return false;
eh = sym_hashes[r_symndx - symtab_hdr->sh_info];
- while (eh->root.type == bfd_link_hash_indirect
+ if (info->wrap_hash != NULL
+ && (input_section->flags & SEC_DEBUGGING) != 0)
+ eh = ((struct elf_link_hash_entry *)
+ unwrap_hash_lookup (info, input_bfd, &eh->root));
+
+ while (eh->root.type == bfd_link_hash_indirect
|| eh->root.type == bfd_link_hash_warning)
eh = (struct elf_link_hash_entry *) eh->root.u.i.link;
else if (info->unresolved_syms_in_objects == RM_IGNORE
&& ELF_ST_VISIBILITY (eh->other) == STV_DEFAULT)
;
- else if (!info->relocatable
+ else if (!bfd_link_relocatable (info)
&& elf_hppa_is_dynamic_loader_symbol (eh->root.root.string))
continue;
- else if (!info->relocatable)
+ else if (!bfd_link_relocatable (info))
{
- bfd_boolean err;
- err = (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
- || ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT);
- if (!info->callbacks->undefined_symbol (info,
- eh->root.root.string,
- input_bfd,
- input_section,
- rel->r_offset, err))
- return FALSE;
+ bool err;
+
+ err = (info->unresolved_syms_in_objects == RM_DIAGNOSE
+ && !info->warn_unresolved_syms)
+ || ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT;
+
+ info->callbacks->undefined_symbol
+ (info, eh->root.root.string, input_bfd,
+ input_section, rel->r_offset, err);
}
- if (!info->relocatable
- && relocation == 0
- && eh->root.type != bfd_link_hash_defined
- && eh->root.type != bfd_link_hash_defweak
- && eh->root.type != bfd_link_hash_undefweak)
- {
- if (info->unresolved_syms_in_objects == RM_IGNORE
- && ELF_ST_VISIBILITY (eh->other) == STV_DEFAULT
- && eh->type == STT_PARISC_MILLI)
- {
- if (! info->callbacks->undefined_symbol
- (info, eh_name (eh), input_bfd,
- input_section, rel->r_offset, FALSE))
- return FALSE;
- }
- }
+ if (!bfd_link_relocatable (info)
+ && relocation == 0
+ && eh->root.type != bfd_link_hash_defined
+ && eh->root.type != bfd_link_hash_defweak
+ && eh->root.type != bfd_link_hash_undefweak)
+ {
+ if (info->unresolved_syms_in_objects == RM_IGNORE
+ && ELF_ST_VISIBILITY (eh->other) == STV_DEFAULT
+ && eh->type == STT_PARISC_MILLI)
+ info->callbacks->undefined_symbol
+ (info, eh_name (eh), input_bfd,
+ input_section, rel->r_offset, false);
+ }
}
- if (sym_sec != NULL && elf_discarded_section (sym_sec))
+ if (sym_sec != NULL && discarded_section (sym_sec))
RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
- rel, relend, howto, contents);
+ rel, 1, relend, howto, 0, contents);
- if (info->relocatable)
+ if (bfd_link_relocatable (info))
continue;
r = elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
symtab_hdr->sh_link,
sym->st_name);
if (sym_name == NULL)
- return FALSE;
+ return false;
if (*sym_name == '\0')
- sym_name = bfd_section_name (input_bfd, sym_sec);
+ sym_name = bfd_section_name (sym_sec);
}
- if (!((*info->callbacks->reloc_overflow)
- (info, (eh ? &eh->root : NULL), sym_name,
- howto->name, (bfd_vma) 0, input_bfd,
- input_section, rel->r_offset)))
- return FALSE;
+ (*info->callbacks->reloc_overflow)
+ (info, (eh ? &eh->root : NULL), sym_name, howto->name,
+ (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
}
break;
}
}
}
- return TRUE;
+ return true;
}
static const struct bfd_elf_special_section elf64_hppa_special_sections[] =
{
- { STRING_COMMA_LEN (".fini"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
- { STRING_COMMA_LEN (".init"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
- { STRING_COMMA_LEN (".plt"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT },
- { STRING_COMMA_LEN (".dlt"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT },
+ { STRING_COMMA_LEN (".tbss"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_HP_TLS },
+ { STRING_COMMA_LEN (".fini"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
+ { STRING_COMMA_LEN (".init"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
+ { STRING_COMMA_LEN (".plt"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT },
+ { STRING_COMMA_LEN (".dlt"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT },
{ STRING_COMMA_LEN (".sdata"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT },
- { STRING_COMMA_LEN (".sbss"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT },
- { STRING_COMMA_LEN (".tbss"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_HP_TLS },
- { NULL, 0, 0, 0, 0 }
+ { STRING_COMMA_LEN (".sbss"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT },
+ { NULL, 0, 0, 0, 0 }
};
/* The hash bucket size is the standard one, namely 4. */
bfd_elf64_swap_reloca_out
};
-#define TARGET_BIG_SYM bfd_elf64_hppa_vec
+#define TARGET_BIG_SYM hppa_elf64_vec
#define TARGET_BIG_NAME "elf64-hppa"
#define ELF_ARCH bfd_arch_hppa
#define ELF_TARGET_ID HPPA64_ELF_DATA
#define elf_backend_create_dynamic_sections \
elf64_hppa_create_dynamic_sections
-#define elf_backend_post_process_headers elf64_hppa_post_process_headers
+#define elf_backend_init_file_header elf64_hppa_init_file_header
+
+#define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all
-#define elf_backend_omit_section_dynsym \
- ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
#define elf_backend_adjust_dynamic_symbol \
elf64_hppa_adjust_dynamic_symbol
elf64_hppa_finish_dynamic_sections
#define elf_backend_grok_prstatus elf64_hppa_grok_prstatus
#define elf_backend_grok_psinfo elf64_hppa_grok_psinfo
-
+
/* Stuff for the BFD linker: */
#define bfd_elf64_bfd_link_hash_table_create \
elf64_hppa_hash_table_create
#define elf_backend_modify_segment_map \
elf64_hppa_modify_segment_map
+#define elf_backend_allow_non_load_phdr \
+ elf64_hppa_allow_non_load_phdr
+
#define elf_backend_link_output_symbol_hook \
elf64_hppa_link_output_symbol_hook
#define elf_backend_plt_readonly 0
#define elf_backend_want_plt_sym 0
#define elf_backend_got_header_size 0
-#define elf_backend_type_change_ok TRUE
+#define elf_backend_type_change_ok true
#define elf_backend_get_symbol_type elf64_hppa_elf_get_symbol_type
#define elf_backend_reloc_type_class elf64_hppa_reloc_type_class
#define elf_backend_rela_normal 1
#include "elf64-target.h"
#undef TARGET_BIG_SYM
-#define TARGET_BIG_SYM bfd_elf64_hppa_linux_vec
+#define TARGET_BIG_SYM hppa_elf64_linux_vec
#undef TARGET_BIG_NAME
#define TARGET_BIG_NAME "elf64-hppa-linux"
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_GNU
-#undef elf_backend_post_process_headers
-#define elf_backend_post_process_headers _bfd_elf_set_osabi
#undef elf64_bed
#define elf64_bed elf64_hppa_linux_bed
+#undef elf_backend_special_sections
+#define elf_backend_special_sections (elf64_hppa_special_sections + 1)
#include "elf64-target.h"