From c48cc8a51e9c991bdfc476a01d014465cc5dbb51 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 4 Feb 2010 09:16:36 +0000 Subject: * 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. --- bfd/elf32-hppa.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 6 deletions(-) (limited to 'bfd/elf32-hppa.c') diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index babe9f20a2..5142d3cf21 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -1,6 +1,6 @@ /* BFD back-end for HP PA-RISC ELF files. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001, - 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 + 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Original code by @@ -314,7 +314,8 @@ struct elf32_hppa_link_hash_table /* Various hash macros and functions. */ #define hppa_link_hash_table(p) \ - ((struct elf32_hppa_link_hash_table *) ((p)->hash)) + (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \ + == HPPA32_ELF_DATA ? ((struct elf32_hppa_link_hash_table *) ((p)->hash)) : NULL) #define hppa_elf_hash_entry(ent) \ ((struct elf32_hppa_link_hash_entry *)(ent)) @@ -341,7 +342,7 @@ static bfd_boolean elf32_hppa_mkobject (bfd *abfd) { return bfd_elf_allocate_object (abfd, sizeof (struct elf_obj_tdata), - HPPA_ELF_TDATA); + HPPA32_ELF_DATA); } /* Assorted hash table functions. */ @@ -432,7 +433,8 @@ elf32_hppa_link_hash_table_create (bfd *abfd) return NULL; if (!_bfd_elf_link_hash_table_init (&htab->etab, abfd, hppa_link_hash_newfunc, - sizeof (struct elf32_hppa_link_hash_entry))) + sizeof (struct elf32_hppa_link_hash_entry), + HPPA32_ELF_DATA)) { free (htab); return NULL; @@ -728,6 +730,9 @@ hppa_build_one_stub (struct bfd_hash_entry *bh, void *in_arg) info = (struct bfd_link_info *)in_arg; htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; + stub_sec = hsh->stub_sec; /* Make a note of the offset within the stubs for this entry. */ @@ -1000,6 +1005,8 @@ elf32_hppa_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) /* Don't try to create the .plt and .got twice. */ htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; if (htab->splt != NULL) return TRUE; @@ -1160,6 +1167,8 @@ elf32_hppa_check_relocs (bfd *abfd, return TRUE; htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; symtab_hdr = &elf_tdata (abfd)->symtab_hdr; eh_syms = elf_sym_hashes (abfd); sreloc = NULL; @@ -1369,7 +1378,7 @@ elf32_hppa_check_relocs (bfd *abfd, if (r_type == R_PARISC_TLS_LDM21L || r_type == R_PARISC_TLS_LDM14R) - hppa_link_hash_table (info)->tls_ldm_got.refcount += 1; + htab->tls_ldm_got.refcount += 1; else { if (hh != NULL) @@ -1601,10 +1610,15 @@ elf32_hppa_gc_sweep_hook (bfd *abfd, bfd_signed_vma *local_got_refcounts; bfd_signed_vma *local_plt_refcounts; const Elf_Internal_Rela *rela, *relend; + struct elf32_hppa_link_hash_table *htab; if (info->relocatable) return TRUE; + htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; + elf_section_data (sec)->local_dynrel = NULL; symtab_hdr = &elf_tdata (abfd)->symtab_hdr; @@ -1669,7 +1683,7 @@ elf32_hppa_gc_sweep_hook (bfd *abfd, case R_PARISC_TLS_LDM21L: case R_PARISC_TLS_LDM14R: - hppa_link_hash_table (info)->tls_ldm_got.refcount -= 1; + htab->tls_ldm_got.refcount -= 1; break; case R_PARISC_PCREL12F: @@ -1904,6 +1918,8 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info, same memory location for the variable. */ htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; /* We must generate a COPY reloc to tell the dynamic linker to copy the initial value out of the dynamic object and into the @@ -1939,6 +1955,9 @@ allocate_plt_static (struct elf_link_hash_entry *eh, void *inf) info = (struct bfd_link_info *) inf; hh = hppa_elf_hash_entry (eh); htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; + if (htab->etab.dynamic_sections_created && eh->plt.refcount > 0) { @@ -2005,6 +2024,9 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf) info = inf; htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; + hh = hppa_elf_hash_entry (eh); if (htab->etab.dynamic_sections_created @@ -2212,6 +2234,9 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, bfd_boolean relocs; htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; + dynobj = htab->etab.dynobj; if (dynobj == NULL) abort (); @@ -2505,6 +2530,9 @@ elf32_hppa_setup_section_lists (bfd *output_bfd, struct bfd_link_info *info) bfd_size_type amt; struct elf32_hppa_link_hash_table *htab = hppa_link_hash_table (info); + if (htab == NULL) + return -1; + /* Count the number of input BFDs and find the top input section id. */ for (input_bfd = info->input_bfds, bfd_count = 0, top_id = 0; input_bfd != NULL; @@ -2572,6 +2600,9 @@ elf32_hppa_next_input_section (struct bfd_link_info *info, asection *isec) { struct elf32_hppa_link_hash_table *htab = hppa_link_hash_table (info); + if (htab == NULL) + return; + if (isec->output_section->index <= htab->top_index) { asection **list = htab->input_list + isec->output_section->index; @@ -2679,6 +2710,9 @@ get_local_syms (bfd *output_bfd, bfd *input_bfd, struct bfd_link_info *info) int stub_changed = 0; struct elf32_hppa_link_hash_table *htab = hppa_link_hash_table (info); + if (htab == NULL) + return -1; + /* We want to read in symbol extension records only once. To do this we need to read in the local symbols in parallel and save them for later use; so hold pointers to the local symbols in an array. */ @@ -2807,6 +2841,9 @@ elf32_hppa_size_stubs bfd_boolean stub_changed; struct elf32_hppa_link_hash_table *htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; + /* Stash our params away. */ htab->stub_bfd = stub_bfd; htab->multi_subspace = multi_subspace; @@ -3092,6 +3129,9 @@ elf32_hppa_set_gp (bfd *abfd, struct bfd_link_info *info) struct elf32_hppa_link_hash_table *htab; htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; + h = bfd_link_hash_lookup (&htab->etab.root, "$global$", FALSE, FALSE, FALSE); if (h != NULL @@ -3176,6 +3216,8 @@ elf32_hppa_build_stubs (struct bfd_link_info *info) struct elf32_hppa_link_hash_table *htab; htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; for (stub_sec = htab->stub_bfd->sections; stub_sec != NULL; @@ -3252,6 +3294,8 @@ hppa_record_segment_addr (bfd *abfd, asection *section, void *data) struct elf32_hppa_link_hash_table *htab; htab = (struct elf32_hppa_link_hash_table*) data; + if (htab == NULL) + return; if ((section->flags & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD)) { @@ -3633,6 +3677,9 @@ elf32_hppa_relocate_section (bfd *output_bfd, symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; + local_got_offsets = elf_local_got_offsets (input_bfd); rela = relocs; @@ -4300,6 +4347,8 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd, bfd_byte *loc; htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; if (eh->plt.offset != (bfd_vma) -1) { @@ -4469,6 +4518,9 @@ elf32_hppa_finish_dynamic_sections (bfd *output_bfd, asection *sdyn; htab = hppa_link_hash_table (info); + if (htab == NULL) + return FALSE; + dynobj = htab->etab.dynobj; sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); -- cgit v1.2.1