+2008-02-12 Nick Clifton <nickc@redhat.com>
+
+ PR ld/5692
+ * elf-bfd.h (enum elf_object_id): New enum, used to identify
+ target specific extensions to the elf_obj_tdata structure.
+ (struct elf_obj_tdata): New field 'object_id'.
+ (elf_object_id, elf_program_header_size, elf_symtab_hdr): New
+ macros for accessing fields in the elf_obj_tdata structure.
+ (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object.
+ (bfd_elf_allocate_object): New function.
+ * elf.c (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object
+ and implement by calling bfd_elf_allocate_object.
+ (bfd_elf_allocate_object): New function: Allocates an
+ elf_obj_tdata structure, possibly with a target specific
+ extension.
+ * elfxx-target.h (bfd_elfNN_mkobject): Use
+ bfd_elf_make_generic_object as the default value.
+ * elf32-arm.c (elf32_arm_obj_tdata): Rename to elf_arm_obj_tdata
+ for consistency with other, similar structures.
+ (is_arm_elf): New macro. Checks a BFD to make sure that is an ARM
+ ELF bfd.
+ (elf32_arm_mkobject): Call bfd_elf_allocate_object.
+ (bfd_elf32_arm_vfp11_erratum_scan): Use is_arm_elf macro to check
+ the bfd being processed.
+ (bfd_elf32_arm_vfp11_fix_veneer_locations): Likewise.
+ (bfd_elf32_arm_set_target_relocs): Likewise.
+ (bfd_elf32_arm_final_link_relocate): Likewise.
+ (bfd_elf32_arm_copy_private_bfd_data): Likewise.
+ (bfd_elf32_arm_merge_eabi_attributes): Likewise.
+ (bfd_elf32_arm_merge_private_bfd_data): Likewise.
+ (bfd_elf32_arm_check_relocs): Likewise.
+ (bfd_elf32_arm_gc_mark_extra_sections): Likewise.
+ (bfd_elf32_arm_size_dynamic_sections): Likewise.
+ (bfd_elf32_arm_process_before_allocation): Use elf_symtab_hdr.
+ (bfd_elf32_arm_init_maps): Likewise.
+ (bfd_elf32_arm_final_link_relocate): Likewise.
+ (bfd_elf32_arm_relocate_section): Likewise.
+ (bfd_elf32_arm_gc_sweep_hook): Likewise.
+ (bfd_elf32_arm_check_relocs): Likewise.
+ (bfd_elf32_arm_size_dynamic_sections): Likewise.
+ * elf32-i386.c (elf_i386_mkobject): Call bfd_elf_allocate_object.
+ (is_i386_elf): New macro. Checks a BFD to make sure that is an x86
+ ELF bfd.
+ (elf_i386_check_relocs): Use is_i386_elf macro to check the bfd
+ being processed.
+ (elf_i386_size_dynamic_sections): Likewise.
+ (elf_i386_relocate_section): Likewise.
+ (elf_i386_check_relocs): Use elf_symtab_hdr.
+ (elf_i386_gc_sweep_hook): Likewise.
+ (elf_i386_size_dynamic_sections): Likewise.
+ (elf_i386_relocate_section): Likewise.
+ * elf32-ppc.c (ppc_elf_mkobject): Call bfd_elf_allocate_object.
+ (elf_create_pointer_linker_section): Use is_ppc_elf_target to
+ verify that the bfd before accessing target specific fields.
+ (ppc_elf_check_relocs): Likewise.
+ (elf_finish_pointer_linker_section): Likewise.
+ (elf_create_pointer_linker_section): Use elf_symtab_hdr.
+ (ppc_elf_check_relocs): Likewise.
+ (ppc_elf_gc_sweep_hook): Likewise.
+ (ppc_elf_tls_optimize): Likewise.
+ (ppc_elf_size_dynamic_sections): Likewise.
+ (ppc_elf_relax_section): Likewise.
+ (ppc_elf_relocate_section): Likewise.
+ * elf32-s390.c (struct elf_s390_obj_tdata): Add a comment
+ reminding programmers to keep this structure in sync with the one
+ defined in elf64-s390.c.
+ (elf_s390_mkobject): Call bfd_elf_allocate_object.
+ (is_s390_elf): New macro. Checks a BFD to make sure that is an s390
+ ELF bfd.
+ (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd
+ being processed.
+ (elf_s390_size_dynamic_sections): Likewise.
+ (elf_s390_relocate_section): Likewise.
+ (elf_s390_check_relocs): Use elf_symtab_hdr.
+ (elf_s390_gc_sweep_hook): Likewise.
+ (elf_s390_size_dynamic_sections): Likewise.
+ (elf_s390_relocate_section): Likewise.
+ * elf32-sh.c (sh_elf_mkobject): Call bfd_elf_allocate_object.
+ (is_sh_elf): New macro. Checks a BFD to make sure that is an SH
+ ELF bfd.
+ (sh_elf_size_dynamic_sections): Use is_sh_elf macro to check the
+ bfd being processed.
+ (sh_elf_relocate_section): Likewise.
+ (sh_elf_check_relocs): Likewise.
+ (sh_elf_copy_private_data): Likewise.
+ (sh_elf_relax_section): Use elf_symtab_hdr.
+ (sh_elf_size_dynamic_sections): Likewise.
+ (sh_elf_relocate_section): Likewise.
+ (sh_elf_get_relocated_section_contents): Likewise.
+ (sh_elf_gc_sweep_hook): Likewise.
+ (sh_elf_check_relocs): Likewise.
+ * elf64-alpha.c (elf64_alpha_mkobject): Call bfd_elf_allocate_object.
+ (is_alpha_elf): New macro. Checks a BFD to make sure that is an
+ Alpha ELF bfd.
+ (elf64_alpha_create_got_section): Use is_alpha_elf macro to check
+ the bfd being processed.
+ (elf64_alpha_create_dynamic_section): Likewise.
+ (elf64_alpha_check_relocs): Likewise.
+ (elf64_alpha_size_got_sections): Likewise.
+ (elf64_alpha_relax_section): Likewise.
+ (elf64_alpha_relocate_section): Likewise.
+ (elf64_alpha_final_link): Likewise.
+ (elf64_alpha_check_relocs): Use elf_symtab_hdr.
+ (elf64_alpha_relax_section): Likewise.
+ (elf64_alpha_relocate_section_r): Likewise.
+ (elf64_alpha_relocate_section): Likewise.
+ * elf64-ppc.c (ppc64_elf_mkobject): Call bfd_elf_allocate_object.
+ (ppc64_elf_check_relocs): Use is_ppc64_elf_target to check the bfd
+ being processed.
+ (opd_entry_value): Likewise.
+ (allocate_dynrelocs): Likewise.
+ (ppc64_elf_relocate_section): Likewise.
+ (ppc64_elf_check_relocs): Use elf_symtab_hdr.
+ (opd_entry_value): Likewise.
+ (ppc64_elf_gc_sweep_hook): Likewise.
+ (get_sym_h): Likewise.
+ (ppc64_elf_edit_opd): Likewise.
+ (ppc64_elf_tls_optimize): Likewise.
+ (ppc64_elf_edit_toc): Likewise.
+ (ppc64_elf_size_dynamic_sections): Likewise.
+ (toc_adjusting_stub_needed): Likewise.
+ (ppc64_elf_size_stubs): Likewise.
+ (ppc64_elf_relocate_section): Likewise.
+ * elf64-s390.c (struct elf_s390_obj_tdata): Add a comment
+ reminding programmers to keep this structure in sync with the one
+ defined in elf32-s390.c.
+ (elf_s390_mkobject): Call bfd_elf_allocate_object.
+ (is_s390_elf): New macro. Checks a BFD to make sure that is an s390
+ ELF bfd.
+ (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd
+ being processed.
+ (elf_s390_size_dynamic_sections): Likewise.
+ (elf_s390_relocate_section): Likewise.
+ (elf_s390_check_relocs): Use elf_symtab_hdr.
+ (elf_s390_gc_sweep_hook): Likewise.
+ (elf_s390_size_dynamic_sections): Likewise.
+ (elf_s390_relocate_section): Likewise.
+ * elf64-x86_64.c (elf64_x86_64_mkobject): Call bfd_elf_allocate_object.
+ (is_x86_64_elf): New macro. Checks a BFD to make sure that is an
+ x86_64 ELF bfd.
+ (elf64_x86_64_check_relocs): Use is_x86_64_elf macro to check the bfd
+ being processed.
+ (elf64_x86_64_size_dynamic_sections): Likewise.
+ (elf64_x86_64_relocate_section): Likewise.
+ (elf64_x86_64_check_relocs): Use elf_symtab_hdr.
+ (elf64_x86_64_gc_sweep_hook): Likewise.
+ (elf64_x86_64_size_dynamic_sections): Likewise.
+ (elf64_x86_64_relocate_section): Likewise.
+ * elfxx-sparc.c (_bfd_sparc_elf_mkobject): Call bfd_elf_allocate_object.
+ (is_sparc_elf): New macro. Checks a BFD to make sure that is a Sparc
+ ELF bfd.
+ (_bfd_sparc_elf_check_relocs): Use is_sparc_elf macro to check the
+ bfd being processed.
+ (_bfd_sparc_elf_gc_sweep_hook): Likewise.
+ (_bfd_sparc_elf_size_dynamic_sections): Likewise.
+ (_bfd_sparc_elf_check_relocs): Use elf_symtab_hdr.
+ (_bfd_sparc_elf_gc_sweep_hook): Likewise.
+ (_bfd_sparc_elf_size_dynamic_sections): Likewise.
+ (_bfd_sparc_elf_relocate_section): Likewise.
+
2008-02-12 Alan Modra <amodra@bigpond.net.au>
PR 5303, 5755
Tag_compatibility = 32
};
+/* Enum used to identify target specific extensions to the elf_obj_tdata
+ structure. Note the enums deliberately start from 1 so that we can
+ detect an uninitialized field. The generic value is last so that
+ additions to this enum do not need to modify more than one line. */
+enum elf_object_id
+{
+ ALPHA_ELF_TDATA = 1,
+ ARM_ELF_TDATA,
+ I386_ELF_TDATA,
+ PPC32_ELF_TDATA,
+ PPC64_ELF_TDATA,
+ S390_ELF_TDATA,
+ SH_ELF_TDATA,
+ SPARC_ELF_TDATA,
+ X86_64_ELF_TDATA,
+ GENERIC_ELF_TDATA
+};
+
/* Some private data is stashed away for future use using the tdata pointer
in the bfd structure. */
/* NT_GNU_BUILD_ID note type. */
bfd_size_type build_id_size;
bfd_byte *build_id;
+
+ /* An identifier used to distinguish different target
+ specific extensions to this structure. */
+ enum elf_object_id object_id;
};
#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
+
+#define elf_object_id(bfd) (elf_tdata(bfd) -> object_id)
+#define elf_program_header_size(bfd) (elf_tdata(bfd) -> program_header_size)
#define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
#define elf_numsections(bfd) (elf_tdata(bfd) -> num_elf_sections)
#define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
#define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
#define elf_symtab_shndx(bfd) (elf_tdata(bfd) -> symtab_shndx_section)
+#define elf_symtab_hdr(bfd) (elf_tdata(bfd) -> symtab_hdr)
#define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section)
#define elf_dynversym(bfd) (elf_tdata(bfd) -> dynversym_section)
#define elf_dynverdef(bfd) (elf_tdata(bfd) -> dynverdef_section)
extern bfd_reloc_status_type bfd_elf_generic_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
-extern bfd_boolean bfd_elf_mkobject
+extern bfd_boolean bfd_elf_allocate_object
+ (bfd *, size_t, enum elf_object_id);
+extern bfd_boolean bfd_elf_make_generic_object
(bfd *);
extern bfd_boolean bfd_elf_mkcorefile
(bfd *);
return h & 0xffffffff;
}
+/* If ABFD does not already have an allocated tdata field then create
+ one, OBJECT_SIZE bytes is length, zeroed out and with the object_id
+ field of an elf_obj_tdata field set to OBJECT_ID. */
bfd_boolean
-bfd_elf_mkobject (bfd *abfd)
+bfd_elf_allocate_object (bfd * abfd,
+ size_t object_size,
+ enum elf_object_id object_id)
{
- if (abfd->tdata.any == NULL)
- {
- abfd->tdata.any = bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
- if (abfd->tdata.any == NULL)
- return FALSE;
- }
+ if (abfd->tdata.any != NULL)
+ return TRUE;
- elf_tdata (abfd)->program_header_size = (bfd_size_type) -1;
+ BFD_ASSERT (object_size >= sizeof (struct elf_obj_tdata));
+ abfd->tdata.any = bfd_zalloc (abfd, object_size);
+ if (abfd->tdata.any == NULL)
+ return FALSE;
+ elf_object_id (abfd) = object_id;
+ elf_program_header_size (abfd) = (bfd_size_type) -1;
return TRUE;
}
+
+bfd_boolean
+bfd_elf_make_generic_object (bfd *abfd)
+{
+ return bfd_elf_allocate_object (abfd, sizeof (struct elf_obj_tdata),
+ GENERIC_ELF_TDATA);
+}
+
bfd_boolean
bfd_elf_mkcorefile (bfd *abfd)
{
/* I think this can be done just like an object file. */
- return bfd_elf_mkobject (abfd);
+ return bfd_elf_make_generic_object (abfd);
}
char *
/* The size of the thread control block. */
#define TCB_SIZE 8
-struct elf32_arm_obj_tdata
+struct elf_arm_obj_tdata
{
struct elf_obj_tdata root;
int no_enum_size_warning;
};
-#define elf32_arm_tdata(abfd) \
- ((struct elf32_arm_obj_tdata *) (abfd)->tdata.any)
+#define elf_arm_tdata(bfd) \
+ ((struct elf_arm_obj_tdata *) (bfd)->tdata.any)
-#define elf32_arm_local_got_tls_type(abfd) \
- (elf32_arm_tdata (abfd)->local_got_tls_type)
+#define elf32_arm_local_got_tls_type(bfd) \
+ (elf_arm_tdata (bfd)->local_got_tls_type)
+
+#define is_arm_elf(bfd) \
+ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
+ && elf_tdata (bfd) != NULL \
+ && elf_object_id (bfd) == ARM_ELF_TDATA)
static bfd_boolean
elf32_arm_mkobject (bfd *abfd)
{
- if (abfd->tdata.any == NULL)
- {
- bfd_size_type amt = sizeof (struct elf32_arm_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
- if (abfd->tdata.any == NULL)
- return FALSE;
- }
- return bfd_elf_mkobject (abfd);
+ return bfd_elf_allocate_object (abfd, sizeof (struct elf_arm_obj_tdata),
+ ARM_ELF_TDATA);
}
/* The ARM linker needs to keep track of the number of relocs that it
if ((sec->flags & SEC_EXCLUDE) != 0)
continue;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = & elf_symtab_hdr (abfd);
/* Load the relocs. */
internal_relocs
if ((abfd->flags & DYNAMIC) != 0)
return;
- hdr = &elf_tdata (abfd)->symtab_hdr;
+ hdr = & elf_symtab_hdr (abfd);
localsyms = hdr->sh_info;
/* Obtain a buffer full of symbols for this BFD. The hdr->sh_info field
if (link_info->relocatable)
return TRUE;
+ /* Skip if this bfd does not correspond to an ELF image. */
+ if (! is_arm_elf (abfd))
+ return TRUE;
+
/* We should have chosen a fix type by the time we get here. */
BFD_ASSERT (globals->vfp11_fix != BFD_ARM_VFP11_FIX_DEFAULT);
if (globals->vfp11_fix == BFD_ARM_VFP11_FIX_NONE)
return TRUE;
- /* Skip if this bfd does not correspond to an ELF image. */
- if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
- return TRUE;
-
for (sec = abfd->sections; sec != NULL; sec = sec->next)
{
unsigned int i, span, first_fmac = 0, veneer_of_insn = 0;
return;
/* Skip if this bfd does not correspond to an ELF image. */
- if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
+ if (! is_arm_elf (abfd))
return;
globals = elf32_arm_hash_table (link_info);
globals->vfp11_fix = vfp11_fix;
globals->pic_veneer = pic_veneer;
- elf32_arm_tdata (output_bfd)->no_enum_size_warning = no_enum_warn;
+ BFD_ASSERT (is_arm_elf (output_bfd));
+ elf_arm_tdata (output_bfd)->no_enum_size_warning = no_enum_warn;
}
/* The thumb form of a long branch is a bit finicky, because the offset
globals = elf32_arm_hash_table (info);
- /* Some relocation type map to different relocations depending on the
+ BFD_ASSERT (is_arm_elf (input_bfd));
+
+ /* Some relocation types map to different relocations depending on the
target. We pick the right one here. */
r_type = arm_real_reloc_type (globals, r_type);
if (r_type != howto->type)
sgot = bfd_get_section_by_name (dynobj, ".got");
splt = bfd_get_section_by_name (dynobj, ".plt");
}
- symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = & elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);
local_got_offsets = elf_local_got_offsets (input_bfd);
r_symndx = ELF32_R_SYM (rel->r_info);
globals = elf32_arm_hash_table (info);
- symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = & elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);
rel = relocs;
flagword in_flags;
flagword out_flags;
- if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ if (! is_arm_elf (ibfd) || ! is_arm_elf (obfd))
return TRUE;
in_flags = elf_elfheader (ibfd)->e_flags;
}
else if (in_attr[i].i != AEABI_enum_forced_wide
&& out_attr[i].i != in_attr[i].i
- && !elf32_arm_tdata (obfd)->no_enum_size_warning)
+ && !elf_arm_tdata (obfd)->no_enum_size_warning)
{
const char *aeabi_enum_names[] =
{ "", "variable-size", "32-bit", "" };
if (! _bfd_generic_verify_endian_match (ibfd, obfd))
return FALSE;
- if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ if (! is_arm_elf (ibfd) || ! is_arm_elf (obfd))
return TRUE;
if (!elf32_arm_merge_eabi_attributes (ibfd, obfd))
elf_section_data (sec)->local_dynrel = NULL;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = & elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
local_got_refcounts = elf_local_got_refcounts (abfd);
if (info->relocatable)
return TRUE;
+ BFD_ASSERT (is_arm_elf (abfd));
+
htab = elf32_arm_hash_table (info);
sreloc = NULL;
dynobj = elf_hash_table (info)->dynobj;
local_got_offsets = elf_local_got_offsets (abfd);
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = & elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
rel_end = relocs + sec->reloc_count;
{
asection *o;
- if (bfd_get_flavour (sub) != bfd_target_elf_flavour)
+ if (! is_arm_elf (sub))
continue;
elf_shdrp = elf_elfsections (sub);
for (o = sub->sections; o != NULL; o = o->next)
{
Elf_Internal_Shdr *hdr;
+
hdr = &elf_section_data (o)->this_hdr;
if (hdr->sh_type == SHT_ARM_EXIDX && hdr->sh_link
&& !o->gc_mark
Elf_Internal_Shdr *symtab_hdr;
asection *srel;
- /* FIXME: Here and elsewhere the test for an ELF input BFD is
- not sufficiently strict. Since we use elf32_arm_tdata and
- elf32_arm_section_data, we should only allow those targets
- that in fact have such data. This of course is the set of
- targets defined in this file. */
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+ if (! is_arm_elf (ibfd))
continue;
for (s = ibfd->sections; s != NULL; s = s->next)
if (!local_got)
continue;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = & elf_symtab_hdr (ibfd);
locsymcount = symtab_hdr->sh_info;
end_local_got = local_got + locsymcount;
local_tls_type = elf32_arm_local_got_tls_type (ibfd);
/* Here we rummage through the found bfds to collect glue information. */
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
{
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+ if (! is_arm_elf (ibfd))
continue;
/* Initialise mapping tables for code/data. */
/* Intel 80386/80486-specific support for 32-bit ELF
Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
#define elf_i386_local_tlsdesc_gotent(abfd) \
(elf_i386_tdata (abfd)->local_tlsdesc_gotent)
+#define is_i386_elf(bfd) \
+ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
+ && elf_tdata (bfd) != NULL \
+ && elf_object_id (bfd) == I386_ELF_TDATA)
+
static bfd_boolean
elf_i386_mkobject (bfd *abfd)
{
- if (abfd->tdata.any == NULL)
- {
- bfd_size_type amt = sizeof (struct elf_i386_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
- if (abfd->tdata.any == NULL)
- return FALSE;
- }
- return bfd_elf_mkobject (abfd);
+ return bfd_elf_allocate_object (abfd, sizeof (struct elf_i386_obj_tdata),
+ I386_ELF_TDATA);
}
/* i386 ELF linker hash table. */
if (info->relocatable)
return TRUE;
+ BFD_ASSERT (is_i386_elf (abfd));
+
htab = elf_i386_hash_table (info);
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
sreloc = NULL;
elf_section_data (sec)->local_dynrel = NULL;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
local_got_refcounts = elf_local_got_refcounts (abfd);
Elf_Internal_Shdr *symtab_hdr;
asection *srel;
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+ if (! is_i386_elf (ibfd))
continue;
for (s = ibfd->sections; s != NULL; s = s->next)
if (!local_got)
continue;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
locsymcount = symtab_hdr->sh_info;
end_local_got = local_got + locsymcount;
local_tls_type = elf_i386_local_got_tls_type (ibfd);
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
+ BFD_ASSERT (is_i386_elf (input_bfd));
+
htab = elf_i386_hash_table (info);
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);
local_got_offsets = elf_local_got_offsets (input_bfd);
local_tlsdesc_gotents = elf_i386_local_tlsdesc_gotent (input_bfd);
/* PowerPC-specific support for 32-bit ELF
Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
- 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
static bfd_boolean
ppc_elf_mkobject (bfd *abfd)
{
- if (abfd->tdata.any == NULL)
- {
- bfd_size_type amt = sizeof (struct ppc_elf_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
- if (abfd->tdata.any == NULL)
- return FALSE;
- }
- return bfd_elf_mkobject (abfd);
+ return bfd_elf_allocate_object (abfd, sizeof (struct ppc_elf_obj_tdata),
+ PPC32_ELF_TDATA);
}
/* Fix bad default arch selected for a 32 bit input bfd when the
}
else
{
+ BFD_ASSERT (is_ppc_elf_target (abfd->xvec));
+
/* Allocation of a pointer to a local symbol. */
elf_linker_section_pointers_t **ptr = elf_local_ptr_offsets (abfd);
/* Allocate a table to hold the local symbols if first time. */
if (!ptr)
{
- unsigned int num_symbols = elf_tdata (abfd)->symtab_hdr.sh_info;
+ unsigned int num_symbols = elf_symtab_hdr (abfd).sh_info;
amt = num_symbols;
amt *= sizeof (elf_linker_section_pointers_t *);
sec, abfd);
#endif
+ BFD_ASSERT (is_ppc_elf_target (abfd->xvec));
+
/* Initialize howto table if not already done. */
if (!ppc_elf_howto_table[R_PPC_ADDR32])
ppc_elf_howto_init ();
htab = ppc_elf_hash_table (info);
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
got2 = bfd_get_section_by_name (abfd, ".got2");
sreloc = NULL;
elf_section_data (sec)->local_dynrel = NULL;
htab = ppc_elf_hash_table (info);
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
local_got_refcounts = elf_local_got_refcounts (abfd);
got2 = bfd_get_section_by_name (abfd, ".got2");
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
{
Elf_Internal_Sym *locsyms = NULL;
- Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (ibfd);
for (sec = ibfd->sections; sec != NULL; sec = sec->next)
if (sec->has_tls_reloc && !bfd_is_abs_section (sec->output_section))
if (!local_got)
continue;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
locsymcount = symtab_hdr->sh_info;
end_local_got = local_got + locsymcount;
lgot_masks = (char *) end_local_got;
/* Space for a branch around any trampolines. */
trampoff += 4;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
/* Get a copy of the native relocations. */
internal_relocs = _bfd_elf_link_read_relocs (abfd, isec, NULL, NULL,
/* Handle local symbol. */
unsigned long r_symndx = ELF32_R_SYM (rel->r_info);
+ BFD_ASSERT (is_ppc_elf_target (input_bfd->xvec));
BFD_ASSERT (elf_local_ptr_offsets (input_bfd) != NULL);
linker_section_ptr = elf_local_ptr_offsets (input_bfd)[r_symndx];
}
htab = ppc_elf_hash_table (info);
local_got_offsets = elf_local_got_offsets (input_bfd);
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);
rel = relocs;
relend = relocs + input_section->reloc_count;
/* IBM S/390-specific support for 32-bit ELF
- Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
Contributed by Carl B. Pedersen and Martin Schwidefsky.
#define elf_s390_hash_entry(ent) \
((struct elf_s390_link_hash_entry *)(ent))
+/* NOTE: Keep this structure in sync with
+ the one declared in elf64-s390.c. */
struct elf_s390_obj_tdata
{
struct elf_obj_tdata root;
- /* tls_type for each local got entry. */
+ /* TLS type for each local got entry. */
char *local_got_tls_type;
};
#define elf_s390_local_got_tls_type(abfd) \
(elf_s390_tdata (abfd)->local_got_tls_type)
+#define is_s390_elf(bfd) \
+ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
+ && elf_tdata (bfd) != NULL \
+ && elf_object_id (bfd) == S390_ELF_TDATA)
+
static bfd_boolean
elf_s390_mkobject (bfd *abfd)
{
- if (abfd->tdata.any == NULL)
- {
- bfd_size_type amt = sizeof (struct elf_s390_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
- if (abfd->tdata.any == NULL)
- return FALSE;
- }
- return bfd_elf_mkobject (abfd);
+ return bfd_elf_allocate_object (abfd, sizeof (struct elf_s390_obj_tdata),
+ S390_ELF_TDATA);
}
static bfd_boolean
if (info->relocatable)
return TRUE;
+ BFD_ASSERT (is_s390_elf (abfd));
+
htab = elf_s390_hash_table (info);
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
local_got_refcounts = elf_local_got_refcounts (abfd);
elf_section_data (sec)->local_dynrel = NULL;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
local_got_refcounts = elf_local_got_refcounts (abfd);
Elf_Internal_Shdr *symtab_hdr;
asection *srela;
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+ if (! is_s390_elf (ibfd))
continue;
for (s = ibfd->sections; s != NULL; s = s->next)
if (!local_got)
continue;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
locsymcount = symtab_hdr->sh_info;
end_local_got = local_got + locsymcount;
local_tls_type = elf_s390_local_got_tls_type (ibfd);
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
+ BFD_ASSERT (is_s390_elf (input_bfd));
+
htab = elf_s390_hash_table (info);
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);
local_got_offsets = elf_local_got_offsets (input_bfd);
/* Renesas / SuperH SH specific support for 32-bit ELF
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2006, 2007 Free Software Foundation, Inc.
+ 2006, 2007, 2008 Free Software Foundation, Inc.
Contributed by Ian Lance Taylor, Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
}
#endif
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
internal_relocs = (_bfd_elf_link_read_relocs
(abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
unsigned int symcount;
asection *o;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
#define sh_elf_local_got_tls_type(abfd) \
(sh_elf_tdata (abfd)->local_got_tls_type)
+#define is_sh_elf(bfd) \
+ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
+ && elf_tdata (bfd) != NULL \
+ && elf_object_id (bfd) == SH_ELF_TDATA)
+
/* Override the generic function because we need to store sh_elf_obj_tdata
as the specific tdata. */
static bfd_boolean
sh_elf_mkobject (bfd *abfd)
{
- if (abfd->tdata.any == NULL)
- {
- bfd_size_type amt = sizeof (struct sh_elf_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
- if (abfd->tdata.any == NULL)
- return FALSE;
- }
- return bfd_elf_mkobject (abfd);
+ return bfd_elf_allocate_object (abfd, sizeof (struct sh_elf_obj_tdata),
+ SH_ELF_TDATA);
}
/* sh ELF linker hash table. */
Elf_Internal_Shdr *symtab_hdr;
asection *srel;
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+ if (! is_sh_elf (ibfd))
continue;
for (s = ibfd->sections; s != NULL; s = s->next)
if (!local_got)
continue;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
locsymcount = symtab_hdr->sh_info;
#ifdef INCLUDE_SHMEDIA
/* Count datalabel local GOT. */
asection *sreloc;
asection *srelgot;
+ BFD_ASSERT (is_sh_elf (input_bfd));
+
htab = sh_elf_hash_table (info);
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);
dynobj = htab->root.dynobj;
local_got_offsets = elf_local_got_offsets (input_bfd);
relocatable,
symbols);
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (input_bfd);
memcpy (data, elf_section_data (input_section)->this_hdr.contents,
(size_t) input_section->size);
elf_section_data (sec)->local_dynrel = NULL;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
local_got_refcounts = elf_local_got_refcounts (abfd);
if (info->relocatable)
return TRUE;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ BFD_ASSERT (is_sh_elf (abfd));
+
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
htab = sh_elf_hash_table (info);
static bfd_boolean
sh_elf_copy_private_data (bfd * ibfd, bfd * obfd)
{
- if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
- return TRUE;
-
/* Copy object attributes. */
_bfd_elf_copy_obj_attributes (ibfd, obfd);
+ if (! is_sh_elf (ibfd) || ! is_sh_elf (obfd))
+ return TRUE;
+
return sh_elf_set_private_flags (obfd, elf_elfheader (ibfd)->e_flags);
}
#endif /* not sh_elf_copy_private_data */
{
extern bfd_boolean sh_merge_bfd_arch (bfd *, bfd *);
- if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ if (! is_sh_elf (ibfd) || ! is_sh_elf (obfd))
return TRUE;
if (! elf_flags_init (obfd))
/* Alpha specific support for 64-bit ELF
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2006, 2007 Free Software Foundation, Inc.
+ 2006, 2007, 2008 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@tamu.edu>.
This file is part of BFD, the Binary File Descriptor library.
#define alpha_elf_tdata(abfd) \
((struct alpha_elf_obj_tdata *) (abfd)->tdata.any)
+#define is_alpha_elf(bfd) \
+ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
+ && elf_tdata (bfd) != NULL \
+ && elf_object_id (bfd) == ALPHA_ELF_TDATA)
+
static bfd_boolean
elf64_alpha_mkobject (bfd *abfd)
{
- if (abfd->tdata.any == NULL)
- {
- bfd_size_type amt = sizeof (struct alpha_elf_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
- if (abfd->tdata.any == NULL)
- return FALSE;
- }
- return bfd_elf_mkobject (abfd);
+ return bfd_elf_allocate_object (abfd, sizeof (struct alpha_elf_obj_tdata),
+ ALPHA_ELF_TDATA);
}
static bfd_boolean
flagword flags;
asection *s;
+ if (! is_alpha_elf (abfd))
+ return FALSE;
+
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
| SEC_LINKER_CREATED);
s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
flagword flags;
struct elf_link_hash_entry *h;
+ if (! is_alpha_elf (abfd))
+ return FALSE;
+
/* We need to create .plt, .rela.plt, .got, and .rela.got sections. */
flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_IN_MEMORY
if ((sec->flags & SEC_ALLOC) == 0)
return TRUE;
- dynobj = elf_hash_table(info)->dynobj;
+ BFD_ASSERT (is_alpha_elf (abfd));
+
+ dynobj = elf_hash_table (info)->dynobj;
if (dynobj == NULL)
- elf_hash_table(info)->dynobj = dynobj = abfd;
+ elf_hash_table (info)->dynobj = dynobj = abfd;
sreloc = NULL;
rel_sec_name = NULL;
- symtab_hdr = &elf_tdata(abfd)->symtab_hdr;
- sym_hashes = alpha_elf_sym_hashes(abfd);
+ symtab_hdr = &elf_symtab_hdr (abfd);
+ sym_hashes = alpha_elf_sym_hashes (abfd);
relend = relocs + sec->reloc_count;
for (rel = relocs; rel < relend; ++rel)
{
for (i = info->input_bfds; i ; i = i->link_next)
{
- bfd *this_got = alpha_elf_tdata (i)->gotobj;
+ bfd *this_got;
+
+ if (! is_alpha_elf (i))
+ continue;
+
+ this_got = alpha_elf_tdata (i)->gotobj;
if (this_got == NULL)
continue;
}
cur_got_obj = got_list;
+ if (cur_got_obj == NULL)
+ return FALSE;
+
i = alpha_elf_tdata(cur_got_obj)->got_link_next;
while (i != NULL)
{
|| sec->reloc_count == 0)
return TRUE;
+ BFD_ASSERT (is_alpha_elf (abfd));
+
/* Make sure our GOT and PLT tables are up-to-date. */
if (alpha_elf_hash_table(link_info)->relax_trip != link_info->relax_trip)
{
}
}
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
local_got_entries = alpha_elf_tdata(abfd)->local_got_entries;
/* Load the relocations for this section. */
struct elf_link_hash_entry **sym_hashes;
bfd_boolean ret_val = TRUE;
- symtab_hdr_sh_info = elf_tdata (input_bfd)->symtab_hdr.sh_info;
+ symtab_hdr_sh_info = elf_symtab_hdr (input_bfd).sh_info;
sym_hashes = elf_sym_hashes (input_bfd);
relend = relocs + input_section->reloc_count;
struct alpha_elf_got_entry **local_got_entries;
bfd_boolean ret_val;
+ BFD_ASSERT (is_alpha_elf (input_bfd));
+
/* Handle relocatable links with a smaller loop. */
if (info->relocatable)
return elf64_alpha_relocate_section_r (output_bfd, info, input_bfd,
ret_val = TRUE;
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (input_bfd);
dynobj = elf_hash_table (info)->dynobj;
if (dynobj)
input_section = p->u.indirect.section;
input_bfd = input_section->owner;
- if (bfd_get_flavour (input_bfd) != bfd_target_elf_flavour
- || (get_elf_backend_data (input_bfd)
- ->elf_backend_ecoff_debug_swap) == NULL)
- {
- /* I don't know what a non ALPHA ELF bfd would be
- doing with a .mdebug section, but I don't really
- want to deal with it. */
- continue;
- }
+ if (! is_alpha_elf (input_bfd))
+ /* I don't know what a non ALPHA ELF bfd would be
+ doing with a .mdebug section, but I don't really
+ want to deal with it. */
+ continue;
input_swap = (get_elf_backend_data (input_bfd)
->elf_backend_ecoff_debug_swap);
static bfd_boolean
ppc64_elf_mkobject (bfd *abfd)
{
- if (abfd->tdata.any == NULL)
- {
- bfd_size_type amt = sizeof (struct ppc64_elf_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
- if (abfd->tdata.any == NULL)
- return FALSE;
- }
- return bfd_elf_mkobject (abfd);
+ return bfd_elf_allocate_object (abfd, sizeof (struct ppc64_elf_obj_tdata),
+ PPC64_ELF_TDATA);
}
/* Return 1 if target is one of ours. */
flagword flags;
struct ppc_link_hash_table *htab = ppc_hash_table (info);
+ if (! is_ppc64_elf_target (abfd->xvec))
+ return FALSE;
+
if (!htab->got)
{
if (! _bfd_elf_create_got_section (htab->elf.dynobj, info))
if ((sec->flags & SEC_ALLOC) == 0)
return TRUE;
+ BFD_ASSERT (is_ppc64_elf_target (abfd->xvec));
+
htab = ppc_hash_table (info);
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
sym_hashes_end = (sym_hashes
return val;
}
+ BFD_ASSERT (is_ppc64_elf_target (opd_bfd->xvec));
+
relocs = ppc64_elf_tdata (opd_bfd)->opd_relocs;
if (relocs == NULL)
relocs = _bfd_elf_link_read_relocs (opd_bfd, opd_sec, NULL, NULL, TRUE);
hi = look;
else
{
- Elf_Internal_Shdr *symtab_hdr = &elf_tdata (opd_bfd)->symtab_hdr;
+ Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (opd_bfd);
+
if (ELF64_R_TYPE (look->r_info) == R_PPC64_ADDR64
&& ELF64_R_TYPE ((look + 1)->r_info) == R_PPC64_TOC)
{
elf_section_data (sec)->local_dynrel = NULL;
htab = ppc_hash_table (info);
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
local_got_ents = elf_local_got_ents (abfd);
unsigned long r_symndx,
bfd *ibfd)
{
- Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (ibfd);
if (r_symndx >= symtab_hdr->sh_info)
{
continue;
local_syms = NULL;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
sym_hashes = elf_sym_hashes (ibfd);
/* Read the relocations. */
if (toc_ref != NULL)
free (toc_ref);
if (locsyms != NULL
- && (elf_tdata (ibfd)->symtab_hdr.contents
+ && (elf_symtab_hdr (ibfd).contents
!= (unsigned char *) locsyms))
free (locsyms);
return FALSE;
unsigned long r_symndx2;
struct elf_link_hash_entry *h2;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
/* The next instruction should be a call to
__tls_get_addr. Peek at the reloc to be sure. */
free (toc_ref);
if (locsyms != NULL
- && (elf_tdata (ibfd)->symtab_hdr.contents
- != (unsigned char *) locsyms))
+ && (elf_symtab_hdr (ibfd).contents != (unsigned char *) locsyms))
{
if (!info->keep_memory)
free (locsyms);
else
- elf_tdata (ibfd)->symtab_hdr.contents = (unsigned char *) locsyms;
+ elf_symtab_hdr (ibfd).contents = (unsigned char *) locsyms;
}
}
return TRUE;
continue;
local_syms = NULL;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
sym_hashes = elf_sym_hashes (ibfd);
/* Look at sections dropped from the final link. */
continue;
}
+ if (! is_ppc64_elf_target (gent->owner->xvec))
+ continue;
+
s = ppc64_elf_tdata (gent->owner)->got;
gent->got.offset = s->size;
s->size
if (!lgot_ents)
continue;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
locsymcount = symtab_hdr->sh_info;
end_lgot_ents = lgot_ents + locsymcount;
lgot_masks = (char *) end_lgot_ents;
}
if (local_syms != NULL
- && (elf_tdata (isec->owner)->symtab_hdr.contents
- != (unsigned char *) local_syms))
+ && (elf_symtab_hdr (isec->owner).contents != (unsigned char *) local_syms))
free (local_syms);
if (elf_section_data (isec)->relocs != relstart)
free (relstart);
continue;
/* We'll need the symbol table in a second. */
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (input_bfd);
if (symtab_hdr->sh_info == 0)
continue;
if (input_section->owner == htab->stub_bfd)
return TRUE;
+ BFD_ASSERT (is_ppc64_elf_target (input_bfd->xvec));
+
local_got_ents = elf_local_got_ents (input_bfd);
TOCstart = elf_gp (output_bfd);
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);
is_opd = ppc64_elf_section_data (input_section)->sec_type == sec_opd;
/* IBM S/390-specific support for 64-bit ELF
- Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
Contributed Martin Schwidefsky (schwidefsky@de.ibm.com).
#define elf_s390_hash_entry(ent) \
((struct elf_s390_link_hash_entry *)(ent))
+/* NOTE: Keep this structure in sync with
+ the one declared in elf32-s390.c. */
struct elf_s390_obj_tdata
{
struct elf_obj_tdata root;
- /* tls_type for each local got entry. */
+ /* TLS type for each local got entry. */
char *local_got_tls_type;
};
#define elf_s390_local_got_tls_type(abfd) \
(elf_s390_tdata (abfd)->local_got_tls_type)
+#define is_s390_elf(bfd) \
+ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
+ && elf_tdata (bfd) != NULL \
+ && elf_object_id (bfd) == S390_ELF_TDATA)
+
static bfd_boolean
elf_s390_mkobject (bfd *abfd)
{
- if (abfd->tdata.any == NULL)
- {
- bfd_size_type amt = sizeof (struct elf_s390_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
- if (abfd->tdata.any == NULL)
- return FALSE;
- }
- return bfd_elf_mkobject (abfd);
+ return bfd_elf_allocate_object (abfd, sizeof (struct elf_s390_obj_tdata),
+ S390_ELF_TDATA);
}
static bfd_boolean
if (info->relocatable)
return TRUE;
+ BFD_ASSERT (is_s390_elf (abfd));
+
htab = elf_s390_hash_table (info);
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
local_got_refcounts = elf_local_got_refcounts (abfd);
elf_section_data (sec)->local_dynrel = NULL;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
local_got_refcounts = elf_local_got_refcounts (abfd);
Elf_Internal_Shdr *symtab_hdr;
asection *srela;
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+ if (! is_s390_elf (ibfd))
continue;
for (s = ibfd->sections; s != NULL; s = s->next)
if (!local_got)
continue;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
locsymcount = symtab_hdr->sh_info;
end_local_got = local_got + locsymcount;
local_tls_type = elf_s390_local_got_tls_type (ibfd);
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
+ BFD_ASSERT (is_s390_elf (input_bfd));
+
htab = elf_s390_hash_table (info);
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);
local_got_offsets = elf_local_got_offsets (input_bfd);
/* X86-64 specific support for 64-bit ELF
- Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
Contributed by Jan Hubicka <jh@suse.cz>.
#define elf64_x86_64_local_tlsdesc_gotent(abfd) \
(elf64_x86_64_tdata (abfd)->local_tlsdesc_gotent)
+#define is_x86_64_elf(bfd) \
+ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
+ && elf_tdata (bfd) != NULL \
+ && elf_object_id (bfd) == X86_64_ELF_TDATA)
+
+static bfd_boolean
+elf64_x86_64_mkobject (bfd *abfd)
+{
+ return bfd_elf_allocate_object (abfd, sizeof (struct elf64_x86_64_obj_tdata),
+ X86_64_ELF_TDATA);
+}
+
/* x86-64 ELF linker hash table. */
struct elf64_x86_64_link_hash_table
_bfd_elf_link_hash_copy_indirect (info, dir, ind);
}
-static bfd_boolean
-elf64_x86_64_mkobject (bfd *abfd)
-{
- if (abfd->tdata.any == NULL)
- {
- bfd_size_type amt = sizeof (struct elf64_x86_64_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
- if (abfd->tdata.any == NULL)
- return FALSE;
- }
- return bfd_elf_mkobject (abfd);
-}
-
static bfd_boolean
elf64_x86_64_elf_object_p (bfd *abfd)
{
if (info->relocatable)
return TRUE;
+ BFD_ASSERT (is_x86_64_elf (abfd));
+
htab = elf64_x86_64_hash_table (info);
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
sreloc = NULL;
elf_section_data (sec)->local_dynrel = NULL;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
local_got_refcounts = elf_local_got_refcounts (abfd);
Elf_Internal_Shdr *symtab_hdr;
asection *srel;
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+ if (! is_x86_64_elf (ibfd))
continue;
for (s = ibfd->sections; s != NULL; s = s->next)
if (!local_got)
continue;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
locsymcount = symtab_hdr->sh_info;
end_local_got = local_got + locsymcount;
local_tls_type = elf64_x86_64_local_got_tls_type (ibfd);
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
+ BFD_ASSERT (is_x86_64_elf (input_bfd));
+
htab = elf64_x86_64_hash_table (info);
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);
local_got_offsets = elf_local_got_offsets (input_bfd);
local_tlsdesc_gotents = elf64_x86_64_local_tlsdesc_gotent (input_bfd);
/* SPARC-specific support for ELF
- Copyright 2005, 2006, 2007 Free Software Foundation, Inc.
+ Copyright 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
#define _bfd_sparc_elf_local_got_tls_type(abfd) \
(_bfd_sparc_elf_tdata (abfd)->local_got_tls_type)
+#define is_sparc_elf(bfd) \
+ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
+ && elf_tdata (bfd) != NULL \
+ && elf_object_id (bfd) == SPARC_ELF_TDATA)
+
bfd_boolean
_bfd_sparc_elf_mkobject (bfd *abfd)
{
- if (abfd->tdata.any == NULL)
- {
- bfd_size_type amt = sizeof (struct _bfd_sparc_elf_obj_tdata);
- abfd->tdata.any = bfd_zalloc (abfd, amt);
- if (abfd->tdata.any == NULL)
- return FALSE;
- }
- return bfd_elf_mkobject (abfd);
+ return bfd_elf_allocate_object (abfd, sizeof (struct _bfd_sparc_elf_obj_tdata),
+ SPARC_ELF_TDATA);
}
static void
return TRUE;
htab = _bfd_sparc_elf_hash_table (info);
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
local_got_offsets = elf_local_got_offsets (abfd);
num_relocs = NUM_SHDR_ENTRIES (& elf_section_data (sec)->rel_hdr);
else
num_relocs = sec->reloc_count;
+
+ BFD_ASSERT (is_sparc_elf (abfd) || num_relocs == 0);
+
rel_end = relocs + num_relocs;
for (rel = relocs; rel < rel_end; rel++)
{
if (info->relocatable)
return TRUE;
+ BFD_ASSERT (is_sparc_elf (abfd) || sec->reloc_count == 0);
+
elf_section_data (sec)->local_dynrel = NULL;
htab = _bfd_sparc_elf_hash_table (info);
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
local_got_refcounts = elf_local_got_refcounts (abfd);
Elf_Internal_Shdr *symtab_hdr;
asection *srel;
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+ if (! is_sparc_elf (ibfd))
continue;
for (s = ibfd->sections; s != NULL; s = s->next)
if (!local_got)
continue;
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (ibfd);
locsymcount = symtab_hdr->sh_info;
end_local_got = local_got + locsymcount;
local_tls_type = _bfd_sparc_elf_local_got_tls_type (ibfd);
int num_relocs;
htab = _bfd_sparc_elf_hash_table (info);
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ symtab_hdr = &elf_symtab_hdr (input_bfd);
sym_hashes = elf_sym_hashes (input_bfd);
local_got_offsets = elf_local_got_offsets (input_bfd);
#endif
#ifndef bfd_elfNN_mkobject
-#define bfd_elfNN_mkobject bfd_elf_mkobject
+#define bfd_elfNN_mkobject bfd_elf_make_generic_object
#endif
#ifndef bfd_elfNN_mkcorefile