From ef53be89160126f2fa5dec8f1ec3bd6d99fb0681 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 11 Jun 2016 17:22:55 +0930 Subject: [PATCH] Use size_t rather than bfd_size_type I noticed when writing _bfd_elf_strtab_save/restore that size_t would be better than bfd_size_type for a number of things in elf-strtab.c. Using a 64-bit bfd_size_type on a 32-bit host doesn't make much sense for array sizes and indices. * elf-strtab.c (struct strtab_save): Use size_t for "size". (struct elf_strtab_hash): Likewise for "size" and "alloced". (_bfd_elf_strtab_init): Formatting. (_bfd_elf_strtab_add): Return size_t rather than bfd_size_type. (_bfd_elf_strtab_addref): Take size_t idx param. (_bfd_elf_strtab_delref, _bfd_elf_strtab_refcount): Likewise. (_bfd_elf_strtab_offset): Likewise. (_bfd_elf_strtab_clear_all_refs): Use size_t idx. (_bfd_elf_strtab_save): Use size_t "idx" and "size" vars. (_bfd_elf_strtab_restore, _bfd_elf_strtab_emit): Similarly. (_bfd_elf_strtab_finalize): Similarly. * elf-bfd.h (_bfd_elf_strtab_add): Update prototypes. (_bfd_elf_strtab_addref, _bfd_elf_strtab_delref): Likewise. (_bfd_elf_strtab_refcount, _bfd_elf_strtab_offset): Likewise. * elf.c (bfd_elf_get_elf_syms): Calculate symbol buffer size using bfd_size_type. (bfd_section_from_shdr): Delete amt. (_bfd_elf_init_reloc_shdr): Likewise. (_bfd_elf_link_assign_sym_version): Likewise. (assign_section_numbers): Use size_t reloc_count. * elflink.c (struct elf_symbuf_head): Use size_t "count". (bfd_elf_link_record_dynamic_symbol): Use size_t for some vars. (elf_link_is_defined_archive_symbol): Likewise. (elf_add_dt_needed_tag): Likewise. (elf_finalize_dynstr): Likewise. (elf_link_add_object_symbols): Likewise. (bfd_elf_size_dynamic_sections): Likewise. (elf_create_symbuf): Similarly. (bfd_elf_match_symbols_in_sections): Likewise. (elf_link_swap_symbols_out): Likewise. (elf_link_check_versioned_symbol): Likewise. (bfd_elf_gc_record_vtinherit): Likewise. (bfd_elf_gc_common_finalize_got_offsets): Likewise. --- bfd/ChangeLog | 36 +++++++++++++++ bfd/elf-bfd.h | 10 ++--- bfd/elf-strtab.c | 57 ++++++++++++------------ bfd/elf.c | 14 +++--- bfd/elflink.c | 112 ++++++++++++++++++++++++----------------------- 5 files changed, 130 insertions(+), 99 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 460e68b8f0e..67b9778130c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,39 @@ +2016-06-10 Alan Modra + + * elf-strtab.c (struct strtab_save): Use size_t for "size". + (struct elf_strtab_hash): Likewise for "size" and "alloced". + (_bfd_elf_strtab_init): Formatting. + (_bfd_elf_strtab_add): Return size_t rather than bfd_size_type. + (_bfd_elf_strtab_addref): Take size_t idx param. + (_bfd_elf_strtab_delref, _bfd_elf_strtab_refcount): Likewise. + (_bfd_elf_strtab_offset): Likewise. + (_bfd_elf_strtab_clear_all_refs): Use size_t idx. + (_bfd_elf_strtab_save): Use size_t "idx" and "size" vars. + (_bfd_elf_strtab_restore, _bfd_elf_strtab_emit): Similarly. + (_bfd_elf_strtab_finalize): Similarly. + * elf-bfd.h (_bfd_elf_strtab_add): Update prototypes. + (_bfd_elf_strtab_addref, _bfd_elf_strtab_delref): Likewise. + (_bfd_elf_strtab_refcount, _bfd_elf_strtab_offset): Likewise. + * elf.c (bfd_elf_get_elf_syms): Calculate symbol buffer size + using bfd_size_type. + (bfd_section_from_shdr): Delete amt. + (_bfd_elf_init_reloc_shdr): Likewise. + (_bfd_elf_link_assign_sym_version): Likewise. + (assign_section_numbers): Use size_t reloc_count. + * elflink.c (struct elf_symbuf_head): Use size_t "count". + (bfd_elf_link_record_dynamic_symbol): Use size_t for some vars. + (elf_link_is_defined_archive_symbol): Likewise. + (elf_add_dt_needed_tag): Likewise. + (elf_finalize_dynstr): Likewise. + (elf_link_add_object_symbols): Likewise. + (bfd_elf_size_dynamic_sections): Likewise. + (elf_create_symbuf): Similarly. + (bfd_elf_match_symbols_in_sections): Likewise. + (elf_link_swap_symbols_out): Likewise. + (elf_link_check_versioned_symbol): Likewise. + (bfd_elf_gc_record_vtinherit): Likewise. + (bfd_elf_gc_common_finalize_got_offsets): Likewise. + 2016-06-08 Senthil Kumar Selvaraj PR ld/20221 diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index d37c2081339..6825530dceb 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2049,14 +2049,14 @@ extern struct elf_strtab_hash * _bfd_elf_strtab_init (void); extern void _bfd_elf_strtab_free (struct elf_strtab_hash *); -extern bfd_size_type _bfd_elf_strtab_add +extern size_t _bfd_elf_strtab_add (struct elf_strtab_hash *, const char *, bfd_boolean); extern void _bfd_elf_strtab_addref - (struct elf_strtab_hash *, bfd_size_type); + (struct elf_strtab_hash *, size_t); extern void _bfd_elf_strtab_delref - (struct elf_strtab_hash *, bfd_size_type); + (struct elf_strtab_hash *, size_t); extern unsigned int _bfd_elf_strtab_refcount - (struct elf_strtab_hash *, bfd_size_type); + (struct elf_strtab_hash *, size_t); extern void _bfd_elf_strtab_clear_all_refs (struct elf_strtab_hash *); extern void *_bfd_elf_strtab_save @@ -2066,7 +2066,7 @@ extern void _bfd_elf_strtab_restore extern bfd_size_type _bfd_elf_strtab_size (struct elf_strtab_hash *); extern bfd_size_type _bfd_elf_strtab_offset - (struct elf_strtab_hash *, bfd_size_type); + (struct elf_strtab_hash *, size_t); extern bfd_boolean _bfd_elf_strtab_emit (bfd *, struct elf_strtab_hash *); extern void _bfd_elf_strtab_finalize diff --git a/bfd/elf-strtab.c b/bfd/elf-strtab.c index 19b0ad8586c..a91a03da746 100644 --- a/bfd/elf-strtab.c +++ b/bfd/elf-strtab.c @@ -48,9 +48,9 @@ struct elf_strtab_hash { struct bfd_hash_table table; /* Next available index. */ - bfd_size_type size; + size_t size; /* Number of array entries alloced. */ - bfd_size_type alloced; + size_t alloced; /* Final strtab size. */ bfd_size_type sec_size; /* Array of pointers to strtab entries. */ @@ -112,8 +112,8 @@ _bfd_elf_strtab_init (void) table->size = 1; table->alloced = 64; amt = sizeof (struct elf_strtab_hasn_entry *); - table->array = (struct elf_strtab_hash_entry **) - bfd_malloc (table->alloced * amt); + table->array = ((struct elf_strtab_hash_entry **) + bfd_malloc (table->alloced * amt)); if (table->array == NULL) { free (table); @@ -138,7 +138,7 @@ _bfd_elf_strtab_free (struct elf_strtab_hash *tab) /* Get the index of an entity in a hash table, adding it if it is not already present. */ -bfd_size_type +size_t _bfd_elf_strtab_add (struct elf_strtab_hash *tab, const char *str, bfd_boolean copy) @@ -155,7 +155,7 @@ _bfd_elf_strtab_add (struct elf_strtab_hash *tab, bfd_hash_lookup (&tab->table, str, TRUE, copy); if (entry == NULL) - return (bfd_size_type) -1; + return (size_t) -1; entry->refcount++; if (entry->len == 0) @@ -170,7 +170,7 @@ _bfd_elf_strtab_add (struct elf_strtab_hash *tab, tab->array = (struct elf_strtab_hash_entry **) bfd_realloc_or_free (tab->array, tab->alloced * amt); if (tab->array == NULL) - return (bfd_size_type) -1; + return (size_t) -1; } entry->u.index = tab->size++; @@ -180,9 +180,9 @@ _bfd_elf_strtab_add (struct elf_strtab_hash *tab, } void -_bfd_elf_strtab_addref (struct elf_strtab_hash *tab, bfd_size_type idx) +_bfd_elf_strtab_addref (struct elf_strtab_hash *tab, size_t idx) { - if (idx == 0 || idx == (bfd_size_type) -1) + if (idx == 0 || idx == (size_t) -1) return; BFD_ASSERT (tab->sec_size == 0); BFD_ASSERT (idx < tab->size); @@ -190,9 +190,9 @@ _bfd_elf_strtab_addref (struct elf_strtab_hash *tab, bfd_size_type idx) } void -_bfd_elf_strtab_delref (struct elf_strtab_hash *tab, bfd_size_type idx) +_bfd_elf_strtab_delref (struct elf_strtab_hash *tab, size_t idx) { - if (idx == 0 || idx == (bfd_size_type) -1) + if (idx == 0 || idx == (size_t) -1) return; BFD_ASSERT (tab->sec_size == 0); BFD_ASSERT (idx < tab->size); @@ -201,7 +201,7 @@ _bfd_elf_strtab_delref (struct elf_strtab_hash *tab, bfd_size_type idx) } unsigned int -_bfd_elf_strtab_refcount (struct elf_strtab_hash *tab, bfd_size_type idx) +_bfd_elf_strtab_refcount (struct elf_strtab_hash *tab, size_t idx) { return tab->array[idx]->refcount; } @@ -209,7 +209,7 @@ _bfd_elf_strtab_refcount (struct elf_strtab_hash *tab, bfd_size_type idx) void _bfd_elf_strtab_clear_all_refs (struct elf_strtab_hash *tab) { - bfd_size_type idx; + size_t idx; for (idx = 1; idx < tab->size; idx++) tab->array[idx]->refcount = 0; @@ -219,7 +219,7 @@ _bfd_elf_strtab_clear_all_refs (struct elf_strtab_hash *tab) struct strtab_save { - bfd_size_type size; + size_t size; unsigned int refcount[1]; }; @@ -227,7 +227,7 @@ void * _bfd_elf_strtab_save (struct elf_strtab_hash *tab) { struct strtab_save *save; - bfd_size_type idx, size; + size_t idx, size; size = sizeof (*save) + (tab->size - 1) * sizeof (save->refcount[0]); save = bfd_malloc (size); @@ -245,7 +245,7 @@ _bfd_elf_strtab_save (struct elf_strtab_hash *tab) void _bfd_elf_strtab_restore (struct elf_strtab_hash *tab, void *buf) { - bfd_size_type idx, curr_size = tab->size; + size_t idx, curr_size = tab->size; struct strtab_save *save = (struct strtab_save *) buf; BFD_ASSERT (tab->sec_size == 0); @@ -271,7 +271,7 @@ _bfd_elf_strtab_size (struct elf_strtab_hash *tab) } bfd_size_type -_bfd_elf_strtab_offset (struct elf_strtab_hash *tab, bfd_size_type idx) +_bfd_elf_strtab_offset (struct elf_strtab_hash *tab, size_t idx) { struct elf_strtab_hash_entry *entry; @@ -288,7 +288,8 @@ _bfd_elf_strtab_offset (struct elf_strtab_hash *tab, bfd_size_type idx) bfd_boolean _bfd_elf_strtab_emit (register bfd *abfd, struct elf_strtab_hash *tab) { - bfd_size_type off = 1, i; + bfd_size_type off = 1; + size_t i; if (bfd_bwrite ("", 1, abfd) != 1) return FALSE; @@ -358,16 +359,12 @@ void _bfd_elf_strtab_finalize (struct elf_strtab_hash *tab) { struct elf_strtab_hash_entry **array, **a, *e; - bfd_size_type size, amt; - - /* GCC 2.91.66 (egcs-1.1.2) on i386 miscompiles this function when i is - a 64-bit bfd_size_type: a 64-bit target or --enable-64-bit-bfd. - Besides, indexing with a long long wouldn't give anything but extra - cycles. */ - size_t i; + bfd_size_type amt, sec_size; + size_t size, i; /* Sort the strings by suffix and length. */ - amt = tab->size * sizeof (struct elf_strtab_hash_entry *); + amt = tab->size; + amt *= sizeof (struct elf_strtab_hash_entry *); array = (struct elf_strtab_hash_entry **) bfd_malloc (amt); if (array == NULL) goto alloc_failure; @@ -426,18 +423,18 @@ alloc_failure: free (array); /* Assign positions to the strings we want to keep. */ - size = 1; + sec_size = 1; for (i = 1; i < tab->size; ++i) { e = tab->array[i]; if (e->refcount && e->len > 0) { - e->u.index = size; - size += e->len; + e->u.index = sec_size; + sec_size += e->len; } } - tab->sec_size = size; + tab->sec_size = sec_size; /* Adjust the rest. */ for (i = 1; i < tab->size; ++i) diff --git a/bfd/elf.c b/bfd/elf.c index fa4cc4c468e..aaf2b5351d3 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -435,7 +435,7 @@ bfd_elf_get_elf_syms (bfd *ibfd, alloc_intsym = NULL; bed = get_elf_backend_data (ibfd); extsym_size = bed->s->sizeof_sym; - amt = symcount * extsym_size; + amt = (bfd_size_type) symcount * extsym_size; pos = symtab_hdr->sh_offset + symoffset * extsym_size; if (extsym_buf == NULL) { @@ -454,7 +454,7 @@ bfd_elf_get_elf_syms (bfd *ibfd, extshndx_buf = NULL; else { - amt = symcount * sizeof (Elf_External_Sym_Shndx); + amt = (bfd_size_type) symcount * sizeof (Elf_External_Sym_Shndx); pos = shndx_hdr->sh_offset + symoffset * sizeof (Elf_External_Sym_Shndx); if (extshndx_buf == NULL) { @@ -2227,7 +2227,6 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex) Elf_Internal_Shdr *hdr2, **p_hdr; unsigned int num_sec = elf_numsections (abfd); struct bfd_elf_section_data *esdt; - bfd_size_type amt; if (hdr->sh_entsize != (bfd_size_type) (hdr->sh_type == SHT_REL @@ -2320,8 +2319,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex) /* PR 17512: file: 0b4f81b7. */ if (*p_hdr != NULL) goto fail; - amt = sizeof (*hdr2); - hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt); + hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, sizeof (*hdr2)); if (hdr2 == NULL) goto fail; *hdr2 = *hdr; @@ -3021,11 +3019,9 @@ _bfd_elf_init_reloc_shdr (bfd *abfd, { Elf_Internal_Shdr *rel_hdr; const struct elf_backend_data *bed = get_elf_backend_data (abfd); - bfd_size_type amt; - amt = sizeof (Elf_Internal_Shdr); BFD_ASSERT (reldata->hdr == NULL); - rel_hdr = bfd_zalloc (abfd, amt); + rel_hdr = bfd_zalloc (abfd, sizeof (*rel_hdr)); reldata->hdr = rel_hdr; if (delay_st_name_p) @@ -3544,7 +3540,7 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info) /* SHT_GROUP sections are in relocatable files only. */ if (link_info == NULL || bfd_link_relocatable (link_info)) { - bfd_size_type reloc_count = 0; + size_t reloc_count = 0; /* Put SHT_GROUP sections first. */ for (sec = abfd->sections; sec != NULL; sec = sec->next) diff --git a/bfd/elflink.c b/bfd/elflink.c index 8bb10664a72..6d591de58da 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -468,7 +468,7 @@ bfd_elf_link_record_dynamic_symbol (struct bfd_link_info *info, struct elf_strtab_hash *dynstr; char *p; const char *name; - bfd_size_type indx; + size_t indx; /* XXX: The ABI draft says the linker must turn hidden and internal symbols into STB_LOCAL symbols when producing the @@ -519,7 +519,7 @@ bfd_elf_link_record_dynamic_symbol (struct bfd_link_info *info, if (p != NULL) *p = ELF_VER_CHR; - if (indx == (bfd_size_type) -1) + if (indx == (size_t) -1) return FALSE; h->dynstr_index = indx; } @@ -698,7 +698,7 @@ bfd_elf_link_record_local_dynamic_symbol (struct bfd_link_info *info, struct elf_link_local_dynamic_entry *entry; struct elf_link_hash_table *eht; struct elf_strtab_hash *dynstr; - unsigned long dynstr_index; + size_t dynstr_index; char *name; Elf_External_Sym_Shndx eshndx; char esym[sizeof (Elf64_External_Sym)]; @@ -753,7 +753,7 @@ bfd_elf_link_record_local_dynamic_symbol (struct bfd_link_info *info, } dynstr_index = _bfd_elf_strtab_add (dynstr, name, FALSE); - if (dynstr_index == (unsigned long) -1) + if (dynstr_index == (size_t) -1) return 0; entry->isym.st_name = dynstr_index; @@ -2104,7 +2104,6 @@ _bfd_elf_link_assign_sym_version (struct elf_link_hash_entry *h, void *data) const struct elf_backend_data *bed; struct elf_info_failed eif; char *p; - bfd_size_type amt; sinfo = (struct elf_info_failed *) data; info = sinfo->info; @@ -2194,8 +2193,8 @@ _bfd_elf_link_assign_sym_version (struct elf_link_hash_entry *h, void *data) if (h->dynindx == -1) return TRUE; - amt = sizeof *t; - t = (struct bfd_elf_version_tree *) bfd_zalloc (info->output_bfd, amt); + t = (struct bfd_elf_version_tree *) bfd_zalloc (info->output_bfd, + sizeof *t); if (t == NULL) { sinfo->failed = TRUE; @@ -3113,9 +3112,9 @@ static bfd_boolean elf_link_is_defined_archive_symbol (bfd * abfd, carsym * symdef) { Elf_Internal_Shdr * hdr; - bfd_size_type symcount; - bfd_size_type extsymcount; - bfd_size_type extsymoff; + size_t symcount; + size_t extsymcount; + size_t extsymoff; Elf_Internal_Sym *isymbuf; Elf_Internal_Sym *isym; Elf_Internal_Sym *isymend; @@ -3233,14 +3232,14 @@ elf_add_dt_needed_tag (bfd *abfd, bfd_boolean do_it) { struct elf_link_hash_table *hash_table; - bfd_size_type strindex; + size_t strindex; if (!_bfd_elf_link_create_dynstrtab (abfd, info)) return -1; hash_table = elf_hash_table (info); strindex = _bfd_elf_strtab_add (hash_table->dynstr, soname, FALSE); - if (strindex == (bfd_size_type) -1) + if (strindex == (size_t) -1) return -1; if (_bfd_elf_strtab_refcount (hash_table->dynstr, strindex) != 1) @@ -3408,7 +3407,7 @@ elf_finalize_dynstr (bfd *output_bfd, struct bfd_link_info *info) { asection *s; bfd_byte *p; - bfd_size_type i; + size_t i; Elf_Internal_Verdef def; Elf_Internal_Verdaux defaux; @@ -3440,7 +3439,7 @@ elf_finalize_dynstr (bfd *output_bfd, struct bfd_link_info *info) { asection *s; bfd_byte *p; - bfd_size_type i; + size_t i; Elf_Internal_Verneed need; Elf_Internal_Vernaux needaux; @@ -3590,16 +3589,16 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) { Elf_Internal_Ehdr *ehdr; Elf_Internal_Shdr *hdr; - bfd_size_type symcount; - bfd_size_type extsymcount; - bfd_size_type extsymoff; + size_t symcount; + size_t extsymcount; + size_t extsymoff; struct elf_link_hash_entry **sym_hash; bfd_boolean dynamic; Elf_External_Versym *extversym = NULL; Elf_External_Versym *ever; struct elf_link_hash_entry *weaks; struct elf_link_hash_entry **nondeflt_vers = NULL; - bfd_size_type nondeflt_vers_cnt = 0; + size_t nondeflt_vers_cnt = 0; Elf_Internal_Sym *isymbuf = NULL; Elf_Internal_Sym *isym; Elf_Internal_Sym *isymend; @@ -3980,7 +3979,8 @@ error_free_dyn: { /* We store a pointer to the hash table entry for each external symbol. */ - amt = extsymcount * sizeof (struct elf_link_hash_entry *); + amt = extsymcount; + amt *= sizeof (struct elf_link_hash_entry *); sym_hash = (struct elf_link_hash_entry **) bfd_zalloc (abfd, amt); if (sym_hash == NULL) goto error_free_sym; @@ -4861,7 +4861,7 @@ error_free_dyn: such that any relocs against foo become foo@BAR. */ if (!bfd_link_relocatable (info) && nondeflt_vers != NULL) { - bfd_size_type cnt, symidx; + size_t cnt, symidx; for (cnt = 0; cnt < nondeflt_vers_cnt; ++cnt) { @@ -4932,7 +4932,8 @@ error_free_dyn: /* Since we have to search the whole symbol list for each weak defined symbol, search time for N weak defined symbols will be O(N^2). Binary search will cut it down to O(NlogN). */ - amt = extsymcount * sizeof (struct elf_link_hash_entry *); + amt = extsymcount; + amt *= sizeof (struct elf_link_hash_entry *); sorted_sym_hash = (struct elf_link_hash_entry **) bfd_malloc (amt); if (sorted_sym_hash == NULL) goto error_return; @@ -5794,14 +5795,14 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info, asection **sinterpptr) { - bfd_size_type soname_indx; + size_t soname_indx; bfd *dynobj; const struct elf_backend_data *bed; struct elf_info_failed asvinfo; *sinterpptr = NULL; - soname_indx = (bfd_size_type) -1; + soname_indx = (size_t) -1; if (!is_elf_hash_table (info->hash)) return TRUE; @@ -5882,7 +5883,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, { soname_indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, soname, TRUE); - if (soname_indx == (bfd_size_type) -1 + if (soname_indx == (size_t) -1 || !_bfd_elf_add_dynamic_entry (info, DT_SONAME, soname_indx)) return FALSE; } @@ -5896,12 +5897,12 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, if (rpath != NULL) { - bfd_size_type indx; + size_t indx; bfd_vma tag; indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, rpath, TRUE); - if (indx == (bfd_size_type) -1) + if (indx == (size_t) -1) return FALSE; tag = info->new_dtags ? DT_RUNPATH : DT_RPATH; @@ -5911,11 +5912,11 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, if (filter_shlib != NULL) { - bfd_size_type indx; + size_t indx; indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, filter_shlib, TRUE); - if (indx == (bfd_size_type) -1 + if (indx == (size_t) -1 || !_bfd_elf_add_dynamic_entry (info, DT_FILTER, indx)) return FALSE; } @@ -5926,11 +5927,11 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, for (p = auxiliary_filters; *p != NULL; p++) { - bfd_size_type indx; + size_t indx; indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, *p, TRUE); - if (indx == (bfd_size_type) -1 + if (indx == (size_t) -1 || !_bfd_elf_add_dynamic_entry (info, DT_AUXILIARY, indx)) return FALSE; } @@ -5938,22 +5939,22 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, if (audit != NULL) { - bfd_size_type indx; + size_t indx; indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, audit, TRUE); - if (indx == (bfd_size_type) -1 + if (indx == (size_t) -1 || !_bfd_elf_add_dynamic_entry (info, DT_AUDIT, indx)) return FALSE; } if (depaudit != NULL) { - bfd_size_type indx; + size_t indx; indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, depaudit, TRUE); - if (indx == (bfd_size_type) -1 + if (indx == (size_t) -1 || !_bfd_elf_add_dynamic_entry (info, DT_DEPAUDIT, indx)) return FALSE; } @@ -6261,7 +6262,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, + sizeof (Elf_External_Verdaux)); } - if (soname_indx != (bfd_size_type) -1) + if (soname_indx != (size_t) -1) { _bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, soname_indx); @@ -6271,13 +6272,13 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, } else { - bfd_size_type indx; + size_t indx; name = lbasename (output_bfd->filename); def.vd_hash = bfd_elf_hash (name); indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, name, FALSE); - if (indx == (bfd_size_type) -1) + if (indx == (size_t) -1) return FALSE; defaux.vda_name = indx; } @@ -6496,7 +6497,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, { unsigned int caux; Elf_Internal_Vernaux *a; - bfd_size_type indx; + size_t indx; caux = 0; for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) @@ -6509,7 +6510,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, ? elf_dt_name (t->vn_bfd) : lbasename (t->vn_bfd->filename), FALSE); - if (indx == (bfd_size_type) -1) + if (indx == (size_t) -1) return FALSE; t->vn_file = indx; t->vn_aux = sizeof (Elf_External_Verneed); @@ -6528,7 +6529,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, a->vna_hash = bfd_elf_hash (a->vna_nodename); indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, a->vna_nodename, FALSE); - if (indx == (bfd_size_type) -1) + if (indx == (size_t) -1) return FALSE; a->vna_name = indx; if (a->vna_nextptr == NULL) @@ -7307,7 +7308,7 @@ struct elf_symbuf_symbol struct elf_symbuf_head { struct elf_symbuf_symbol *ssym; - bfd_size_type count; + size_t count; unsigned int st_shndx; }; @@ -7341,12 +7342,12 @@ elf_sym_name_compare (const void *arg1, const void *arg2) } static struct elf_symbuf_head * -elf_create_symbuf (bfd_size_type symcount, Elf_Internal_Sym *isymbuf) +elf_create_symbuf (size_t symcount, Elf_Internal_Sym *isymbuf) { Elf_Internal_Sym **ind, **indbufend, **indbuf; struct elf_symbuf_symbol *ssym; struct elf_symbuf_head *ssymbuf, *ssymhead; - bfd_size_type i, shndx_count, total_size; + size_t i, shndx_count, total_size; indbuf = (Elf_Internal_Sym **) bfd_malloc2 (symcount, sizeof (*indbuf)); if (indbuf == NULL) @@ -7393,7 +7394,7 @@ elf_create_symbuf (bfd_size_type symcount, Elf_Internal_Sym *isymbuf) ssym->st_other = (*ind)->st_other; ssymhead->count++; } - BFD_ASSERT ((bfd_size_type) (ssymhead - ssymbuf) == shndx_count + BFD_ASSERT ((size_t) (ssymhead - ssymbuf) == shndx_count && (((bfd_hostptr_t) ssym - (bfd_hostptr_t) ssymbuf) == total_size)); @@ -7411,12 +7412,12 @@ bfd_elf_match_symbols_in_sections (asection *sec1, asection *sec2, bfd *bfd1, *bfd2; const struct elf_backend_data *bed1, *bed2; Elf_Internal_Shdr *hdr1, *hdr2; - bfd_size_type symcount1, symcount2; + size_t symcount1, symcount2; Elf_Internal_Sym *isymbuf1, *isymbuf2; struct elf_symbuf_head *ssymbuf1, *ssymbuf2; Elf_Internal_Sym *isym, *isymend; struct elf_symbol *symtable1 = NULL, *symtable2 = NULL; - bfd_size_type count1, count2, i; + size_t count1, count2, i; unsigned int shndx1, shndx2; bfd_boolean result; @@ -7479,7 +7480,7 @@ bfd_elf_match_symbols_in_sections (asection *sec1, asection *sec2, if (ssymbuf1 != NULL && ssymbuf2 != NULL) { /* Optimized faster version. */ - bfd_size_type lo, hi, mid; + size_t lo, hi, mid; struct elf_symbol *symp; struct elf_symbuf_symbol *ssym, *ssymend; @@ -8920,7 +8921,8 @@ static bfd_boolean elf_link_swap_symbols_out (struct elf_final_link_info *flinfo) { struct elf_link_hash_table *hash_table = elf_hash_table (flinfo->info); - bfd_size_type amt, i; + bfd_size_type amt; + size_t i; const struct elf_backend_data *bed; bfd_byte *symbuf; Elf_Internal_Shdr *hdr; @@ -8941,8 +8943,8 @@ elf_link_swap_symbols_out (struct elf_final_link_info *flinfo) if (flinfo->symshndxbuf) { - amt = (sizeof (Elf_External_Sym_Shndx) - * (bfd_get_symcount (flinfo->output_bfd))); + amt = sizeof (Elf_External_Sym_Shndx); + amt *= bfd_get_symcount (flinfo->output_bfd); flinfo->symshndxbuf = (Elf_External_Sym_Shndx *) bfd_zmalloc (amt); if (flinfo->symshndxbuf == NULL) { @@ -9059,9 +9061,9 @@ elf_link_check_versioned_symbol (struct bfd_link_info *info, { bfd *input; Elf_Internal_Shdr *hdr; - bfd_size_type symcount; - bfd_size_type extsymcount; - bfd_size_type extsymoff; + size_t symcount; + size_t extsymcount; + size_t extsymoff; Elf_Internal_Shdr *versymhdr; Elf_Internal_Sym *isym; Elf_Internal_Sym *isymend; @@ -13040,7 +13042,7 @@ bfd_elf_gc_record_vtinherit (bfd *abfd, { struct elf_link_hash_entry **sym_hashes, **sym_hashes_end; struct elf_link_hash_entry **search, *child; - bfd_size_type extsymcount; + size_t extsymcount; const struct elf_backend_data *bed = get_elf_backend_data (abfd); /* The sh_info field of the symtab header tells us where the @@ -13313,7 +13315,7 @@ bfd_elf_gc_common_finalize_got_offsets (bfd *abfd, for (i = info->input_bfds; i; i = i->link.next) { bfd_signed_vma *local_got; - bfd_size_type j, locsymcount; + size_t j, locsymcount; Elf_Internal_Shdr *symtab_hdr; if (bfd_get_flavour (i) != bfd_target_elf_flavour) -- 2.30.2