{
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. */
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);
/* 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)
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)
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++;
}
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);
}
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);
}
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;
}
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;
struct strtab_save
{
- bfd_size_type size;
+ size_t size;
unsigned int refcount[1];
};
_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);
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);
}
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;
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;
_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;
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)
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
if (p != NULL)
*p = ELF_VER_CHR;
- if (indx == (bfd_size_type) -1)
+ if (indx == (size_t) -1)
return FALSE;
h->dynstr_index = indx;
}
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)];
}
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;
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;
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;
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;
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)
{
asection *s;
bfd_byte *p;
- bfd_size_type i;
+ size_t i;
Elf_Internal_Verdef def;
Elf_Internal_Verdaux defaux;
{
asection *s;
bfd_byte *p;
- bfd_size_type i;
+ size_t i;
Elf_Internal_Verneed need;
Elf_Internal_Vernaux needaux;
{
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;
{
/* 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;
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)
{
/* 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;
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;
{
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;
}
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;
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;
}
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;
}
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;
}
+ 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);
}
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;
}
{
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)
? 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);
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)
struct elf_symbuf_head
{
struct elf_symbuf_symbol *ssym;
- bfd_size_type count;
+ size_t count;
unsigned int st_shndx;
};
}
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)
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));
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;
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;
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;
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)
{
{
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;
{
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
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)