From c9bf311ca5aa459abd2ad9c35bf2a1d48ed8db09 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 29 Sep 2001 06:21:59 +0000 Subject: * elf-bfd.h (struct elf_link_local_dynamic_entry): Add init_refcount. (struct elf_backend_data): Add can_refcount. * elf.c (_bfd_elf_link_hash_newfunc): Get rid of a few casts. Set got.refcount and plt.refcount from init_refcount. (_bfd_elf_link_hash_table_init): Set up init_refcount. (_bfd_elf_link_hash_copy_indirect): Reference got/plt.refcount rather than got/plt.offset, and test for <= 0 rather than -1. * elflink.h (size_dynamic_sections): Set init_refcount to -1. * elfxx-target.h (elf_backend_can_refcount): Define. (elfNN_bed): Init can_refcount. * linker.c (_bfd_link_hash_newfunc): Get rid of a few casts. (_bfd_generic_link_hash_newfunc): Likewise. * elf32-cris.c (cris_elf_check_relocs): Modify for refcounts starting from zero. (elf_backend_can_refcount): Define. * elf32-hppa.c (elf32_hppa_check_relocs): Modify for refcounts starting from zero. (elf32_hppa_copy_indirect_symbol): Make static to agree with prototype. (elf_backend_can_refcount): Define. * elf32-i386.c (elf_i386_check_relocs): Modify for refcounts starting from zero. (allocate_dynrelocs): Set plt/got.offset rather than *.refcount. (elf_i386_finish_dynamic_symbol): Expand SHN_UNDEF comment. (elf_i386_finish_dynamic_sections): Use local var so line < 80 chars. (elf_backend_can_refcount): Define. (elf_i386_copy_indirect_symbol): Make static to agree with prototype. Formatting fix. * elf32-m68k.c (elf_m68k_check_relocs): Modify for refcounts starting from zero. (elf_backend_can_refcount): Define. * elf32-ppc.c (ppc_elf_check_relocs): Modify for refcounts starting from zero. (elf_backend_can_refcount): Define. * elf32-s390.c (elf_s390_check_relocs): Modify for refcounts starting from zero. (elf_backend_can_refcount): Define. * elf64-s390.c (elf_s390_check_relocs): Modify for refcounts starting from zero. (elf_backend_can_refcount): Define. * elf64-x86-64.c (elf64_x86_64_check_relocs): Modify for refcounts starting from zero. (elf_backend_can_refcount): Define. --- bfd/linker.c | 54 ++++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'bfd/linker.c') diff --git a/bfd/linker.c b/bfd/linker.c index 182786e361..e3828957da 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -445,28 +445,27 @@ _bfd_link_hash_newfunc (entry, table, string) struct bfd_hash_table *table; const char *string; { - struct bfd_link_hash_entry *ret = (struct bfd_link_hash_entry *) entry; - /* Allocate the structure if it has not already been allocated by a subclass. */ - if (ret == (struct bfd_link_hash_entry *) NULL) - ret = ((struct bfd_link_hash_entry *) - bfd_hash_allocate (table, sizeof (struct bfd_link_hash_entry))); - if (ret == (struct bfd_link_hash_entry *) NULL) - return NULL; + if (entry == NULL) + { + entry = bfd_hash_allocate (table, sizeof (struct bfd_link_hash_entry)); + if (entry == NULL) + return entry; + } /* Call the allocation method of the superclass. */ - ret = ((struct bfd_link_hash_entry *) - bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string)); - - if (ret) + entry = bfd_hash_newfunc (entry, table, string); + if (entry) { + struct bfd_link_hash_entry *h = (struct bfd_link_hash_entry *) entry; + /* Initialize the local fields. */ - ret->type = bfd_link_hash_new; - ret->next = NULL; + h->type = bfd_link_hash_new; + h->next = NULL; } - return (struct bfd_hash_entry *) ret; + return entry; } /* Initialize a link hash table. The BFD argument is the one @@ -642,30 +641,29 @@ _bfd_generic_link_hash_newfunc (entry, table, string) struct bfd_hash_table *table; const char *string; { - struct generic_link_hash_entry *ret = - (struct generic_link_hash_entry *) entry; - /* Allocate the structure if it has not already been allocated by a subclass. */ - if (ret == (struct generic_link_hash_entry *) NULL) - ret = ((struct generic_link_hash_entry *) - bfd_hash_allocate (table, sizeof (struct generic_link_hash_entry))); - if (ret == (struct generic_link_hash_entry *) NULL) - return NULL; + if (entry == NULL) + { + entry = bfd_hash_allocate (table, + sizeof (struct generic_link_hash_entry)); + if (entry == NULL) + return entry; + } /* Call the allocation method of the superclass. */ - ret = ((struct generic_link_hash_entry *) - _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret, - table, string)); - - if (ret) + entry = _bfd_link_hash_newfunc (entry, table, string); + if (entry) { + struct generic_link_hash_entry *ret; + /* Set local fields. */ + ret = (struct generic_link_hash_entry *) entry; ret->written = false; ret->sym = NULL; } - return (struct bfd_hash_entry *) ret; + return entry; } /* Create an generic link hash table. */ -- cgit v1.2.1