diff options
author | Nick Clifton <nickc@redhat.com> | 2010-02-04 09:16:43 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2010-02-04 09:16:43 +0000 |
commit | 4dfe6ac6feb4515960e05c7c4a428b54318c75a3 (patch) | |
tree | a7abb34e98ddf06506e83475dde75472851f83c0 /bfd/elf64-x86-64.c | |
parent | 11334b8260ff935cb9a6e98de0096048a662e48a (diff) | |
download | gdb-4dfe6ac6feb4515960e05c7c4a428b54318c75a3.zip gdb-4dfe6ac6feb4515960e05c7c4a428b54318c75a3.tar.gz gdb-4dfe6ac6feb4515960e05c7c4a428b54318c75a3.tar.bz2 |
* elf-bfd.h (emum elf_object_id): Rename to elf_target_id. Add
entries for other architectures.
(struct elf_link_hash_table): Add hash_table_id field.
(elf_hash_table_id): New accessor macro.
* elflink.c (_bfd_elf_link_hash_table_init): Add target_id
parameter.
* elf-m10300.c (elf32_mn10300_hash_table): Check table id before
returning cast pointer.
(elf32_mn10300_link_hash_table_create): Identify new table as
containing MN10300 extensions.
(mn10300_elf_relax_section): Check pointer returned by
elf32_mn10300_hash_table.
* elf32-arm.c: Likewise, except using ARM extensions.
* elf32-avr.c: Likewise, except using AVR extensions.
* elf32-bfin.c: Likewise, except using BFIN extensions.
* elf32-cris.c: Likewise, except using CRIS extensions.
* elf32-frv.c: Likewise, except using FRV extensions.
* elf32-hppa.c: Likewise, except using HPPA32 extensions.
* elf32-i386.c: Likewise, except using I386 extensions.
* elf32-lm32.c: Likewise, except using LM32 extensions.
* elf32-m32r.c: Likewise, except using M32RM extensions.
* elf32-m68hc11.c: Likewise, except using M68HC11 extensions.
* elf32-m68hc1x.c: Likewise, except using M68HC11 extensions.
* elf32-m68hc1x.h: Likewise, except using M68HC11 extensions.
* elf32-m68k.c: Likewise, except using M68K extensions.
* elf32-microblaze.c: Likewise, except using MICROBLAZE extensions.
* elf32-ppc.c: Likewise, except using PPC32 extensions.
* elf32-s390.c: Likewise, except using S390 extensions.
* elf32-sh.c: Likewise, except using SH extensions.
* elf32-spu.c: Likewise, except using SPU extensions.
* elf32-xtensa.c: Likewise, except using XTENSA extensions.
* elf64-alpha.c: Likewise, except using ALPHA extensions.
* elf64-hppa.c: Likewise, except using HPPA64 extensions.
* elf64-ppc.c: Likewise, except using PPC64 extensions.
* elf64-s390.c: Likewise, except using S390 extensions.
* elf64-x86-64.c: Likewise, except using X86_64 extensions.
* elfxx-ia64.c: Likewise, except using IA64 extensions.
* elfxx-mips.c: Likewise, except using MIPS extensions.
* elfxx-sparc.c: Likewise, except using SPARC extensions.
* elfxx-sparc.h: Likewise, except using SPARC extensions.
* elf32-cr16.c (struct elf32_cr16_link_hash_table): Delete
redundant structure.
(elf32_cr16_hash_table): Delete unused macro.
(elf32_cr16_link_hash_traverse): Delete unused macro.
* elf32-score.c: Likewise.
* elf32-score7.c: Likewise.
* elf32-vax.c: Likewise.
* elf64-sh64.c: Likewise.
* emultempl/alphaelf.em: Update value expected from elf_object_id.
* emultempl/hppaelf.em: Likewise.
* emultempl/mipself.em: Likewise.
* emultempl/ppc32elf.em: Likewise.
* emultempl/ppc64elf.em: Likewise.
Diffstat (limited to 'bfd/elf64-x86-64.c')
-rw-r--r-- | bfd/elf64-x86-64.c | 100 |
1 files changed, 72 insertions, 28 deletions
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index e6b1f11..373cab8 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -1,6 +1,6 @@ /* X86-64 specific support for 64-bit ELF - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 - Free Software Foundation, Inc. + Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, + 2010 Free Software Foundation, Inc. Contributed by Jan Hubicka <jh@suse.cz>. This file is part of BFD, the Binary File Descriptor library. @@ -451,13 +451,13 @@ struct elf64_x86_64_obj_tdata #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) + && elf_object_id (bfd) == X86_64_ELF_DATA) 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_DATA); } /* x86-64 ELF linker hash table. */ @@ -470,16 +470,8 @@ struct elf64_x86_64_link_hash_table asection *sdynbss; asection *srelbss; - /* The offset into splt of the PLT entry for the TLS descriptor - resolver. Special values are 0, if not necessary (or not found - to be necessary yet), and -1 if needed but not determined - yet. */ - bfd_vma tlsdesc_plt; - /* The offset into sgot of the GOT entry used by the PLT entry - above. */ - bfd_vma tlsdesc_got; - - union { + union + { bfd_signed_vma refcount; bfd_vma offset; } tls_ld_got; @@ -495,13 +487,23 @@ struct elf64_x86_64_link_hash_table /* Used by local STT_GNU_IFUNC symbols. */ htab_t loc_hash_table; - void *loc_hash_memory; + void * loc_hash_memory; + + /* The offset into splt of the PLT entry for the TLS descriptor + resolver. Special values are 0, if not necessary (or not found + to be necessary yet), and -1 if needed but not determined + yet. */ + bfd_vma tlsdesc_plt; + /* The offset into sgot of the GOT entry used by the PLT entry + above. */ + bfd_vma tlsdesc_got; }; /* Get the x86-64 ELF linker hash table from a link_info structure. */ #define elf64_x86_64_hash_table(p) \ - ((struct elf64_x86_64_link_hash_table *) ((p)->hash)) + (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \ + == X86_64_ELF_DATA ? ((struct elf64_x86_64_link_hash_table *) ((p)->hash)) : NULL) #define elf64_x86_64_compute_jump_table_size(htab) \ ((htab)->elf.srelplt->reloc_count * GOT_ENTRY_SIZE) @@ -622,7 +624,8 @@ elf64_x86_64_link_hash_table_create (bfd *abfd) if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, elf64_x86_64_link_hash_newfunc, - sizeof (struct elf64_x86_64_link_hash_entry))) + sizeof (struct elf64_x86_64_link_hash_entry), + X86_64_ELF_DATA)) { free (ret); return NULL; @@ -636,7 +639,7 @@ elf64_x86_64_link_hash_table_create (bfd *abfd) ret->tls_ld_got.refcount = 0; ret->sgotplt_jump_table_size = 0; ret->tls_module_base = NULL; - + ret->loc_hash_table = htab_try_create (1024, elf64_x86_64_local_htab_hash, elf64_x86_64_local_htab_eq, @@ -679,6 +682,9 @@ elf64_x86_64_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) return FALSE; htab = elf64_x86_64_hash_table (info); + if (htab == NULL) + return FALSE; + htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss"); if (!info->shared) htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss"); @@ -1018,12 +1024,19 @@ elf64_x86_64_tls_transition (struct bfd_link_info *info, bfd *abfd, name = h->root.root.string; else { - Elf_Internal_Sym *isym; struct elf64_x86_64_link_hash_table *htab; + htab = elf64_x86_64_hash_table (info); - isym = bfd_sym_from_r_symndx (&htab->sym_cache, - abfd, r_symndx); - name = bfd_elf_sym_name (abfd, symtab_hdr, isym, NULL); + if (htab == NULL) + name = "*unknown*"; + else + { + Elf_Internal_Sym *isym; + + isym = bfd_sym_from_r_symndx (&htab->sym_cache, + abfd, r_symndx); + name = bfd_elf_sym_name (abfd, symtab_hdr, isym, NULL); + } } (*_bfd_error_handler) @@ -1061,6 +1074,9 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, BFD_ASSERT (is_x86_64_elf (abfd)); htab = elf64_x86_64_hash_table (info); + if (htab == NULL) + return FALSE; + symtab_hdr = &elf_symtab_hdr (abfd); sym_hashes = elf_sym_hashes (abfd); @@ -1594,6 +1610,7 @@ elf64_x86_64_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info, asection *sec, const Elf_Internal_Rela *relocs) { + struct elf64_x86_64_link_hash_table *htab; Elf_Internal_Shdr *symtab_hdr; struct elf_link_hash_entry **sym_hashes; bfd_signed_vma *local_got_refcounts; @@ -1602,6 +1619,10 @@ elf64_x86_64_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info, if (info->relocatable) return TRUE; + htab = elf64_x86_64_hash_table (info); + if (htab == NULL) + return FALSE; + elf_section_data (sec)->local_dynrel = NULL; symtab_hdr = &elf_symtab_hdr (abfd); @@ -1647,8 +1668,8 @@ elf64_x86_64_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info, switch (r_type) { case R_X86_64_TLSLD: - if (elf64_x86_64_hash_table (info)->tls_ld_got.refcount > 0) - elf64_x86_64_hash_table (info)->tls_ld_got.refcount -= 1; + if (htab->tls_ld_got.refcount > 0) + htab->tls_ld_got.refcount -= 1; break; case R_X86_64_TLSGD: @@ -1834,6 +1855,8 @@ elf64_x86_64_adjust_dynamic_symbol (struct bfd_link_info *info, same memory location for the variable. */ htab = elf64_x86_64_hash_table (info); + if (htab == NULL) + return FALSE; /* We must generate a R_X86_64_COPY reloc to tell the dynamic linker to copy the initial value out of the dynamic object and into the @@ -1869,6 +1892,8 @@ elf64_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) info = (struct bfd_link_info *) inf; htab = elf64_x86_64_hash_table (info); + if (htab == NULL) + return FALSE; /* Since STT_GNU_IFUNC symbol must go through PLT, we handle it here if it is defined and referenced in a non-shared object. */ @@ -2159,6 +2184,9 @@ elf64_x86_64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, bfd *ibfd; htab = elf64_x86_64_hash_table (info); + if (htab == NULL) + return FALSE; + dynobj = htab->elf.dynobj; if (dynobj == NULL) abort (); @@ -2454,17 +2482,22 @@ elf64_x86_64_always_size_sections (bfd *output_bfd, if (tlsbase && tlsbase->type == STT_TLS) { + struct elf64_x86_64_link_hash_table *htab; struct bfd_link_hash_entry *bh = NULL; const struct elf_backend_data *bed = get_elf_backend_data (output_bfd); + htab = elf64_x86_64_hash_table (info); + if (htab == NULL) + return FALSE; + if (!(_bfd_generic_link_add_one_symbol (info, output_bfd, "_TLS_MODULE_BASE_", BSF_LOCAL, tls_sec, 0, NULL, FALSE, bed->collect, &bh))) return FALSE; - elf64_x86_64_hash_table (info)->tls_module_base = bh; + htab->tls_module_base = bh; tlsbase = (struct elf_link_hash_entry *)bh; tlsbase->def_regular = 1; @@ -2484,17 +2517,21 @@ elf64_x86_64_always_size_sections (bfd *output_bfd, static void elf64_x86_64_set_tls_module_base (struct bfd_link_info *info) { + struct elf64_x86_64_link_hash_table *htab; struct bfd_link_hash_entry *base; if (!info->executable) return; - base = elf64_x86_64_hash_table (info)->tls_module_base; + htab = elf64_x86_64_hash_table (info); + if (htab == NULL) + return; - if (!base) + base = htab->tls_module_base; + if (base == NULL) return; - base->u.def.value = elf_hash_table (info)->tls_size; + base->u.def.value = htab->elf.tls_size; } /* Return the base VMA address which should be subtracted from real addresses @@ -2572,6 +2609,8 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, BFD_ASSERT (is_x86_64_elf (input_bfd)); htab = elf64_x86_64_hash_table (info); + if (htab == NULL) + return FALSE; symtab_hdr = &elf_symtab_hdr (input_bfd); sym_hashes = elf_sym_hashes (input_bfd); local_got_offsets = elf_local_got_offsets (input_bfd); @@ -3702,6 +3741,8 @@ elf64_x86_64_finish_dynamic_symbol (bfd *output_bfd, struct elf64_x86_64_link_hash_table *htab; htab = elf64_x86_64_hash_table (info); + if (htab == NULL) + return FALSE; if (h->plt.offset != (bfd_vma) -1) { @@ -3981,6 +4022,9 @@ elf64_x86_64_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *inf asection *sdyn; htab = elf64_x86_64_hash_table (info); + if (htab == NULL) + return FALSE; + dynobj = htab->elf.dynobj; sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); |