{
bfd *abfd;
Elf_Internal_Rela *rels, *rel, *relend;
+ /* Number of symbols in .symtab. */
+ unsigned int num_sym;
/* Number of symbols that may be local syms (all when bad_symtab). */
unsigned int locsymcount;
/* Symbol index of first possible global sym (0 when bad_symtab). */
(asection *);
extern struct elf_link_hash_entry * _bfd_elf_get_link_hash_entry
- (struct elf_link_hash_entry **, unsigned int, unsigned int);
+ (struct elf_link_hash_entry **, unsigned int, unsigned int, unsigned int);
extern asection *_bfd_get_local_sym_section
(struct elf_reloc_cookie *, unsigned int);
struct elf_link_hash_entry *
_bfd_elf_get_link_hash_entry (struct elf_link_hash_entry **sym_hashes,
unsigned int symndx,
- unsigned int ext_sym_start)
+ unsigned int ext_sym_start,
+ unsigned int num_sym)
{
if (sym_hashes == NULL
/* Guard against corrupt input. See PR 32636 for an example. */
- || symndx < ext_sym_start)
+ || symndx < ext_sym_start
+ || symndx >= num_sym)
return NULL;
struct elf_link_hash_entry *h = sym_hashes[symndx - ext_sym_start];
return NULL;
return _bfd_elf_get_link_hash_entry (elf_sym_hashes (cookie->abfd), symndx,
- cookie->extsymoff);
+ cookie->extsymoff, cookie->num_sym);
}
asection *
set_symbol_value (bfd *bfd_with_globals,
Elf_Internal_Sym *isymbuf,
size_t locsymcount,
+ size_t num_sym,
size_t symidx,
bfd_vma val)
{
/* It is a global symbol: set its link type
to "defined" and give it a value. */
h = _bfd_elf_get_link_hash_entry (elf_sym_hashes (bfd_with_globals), symidx,
- extsymoff);
+ extsymoff, num_sym);
if (h == NULL)
return false;
h->root.type = bfd_link_hash_defined;
Elf_Internal_Shdr *symtab_hdr;
size_t locsymcount;
size_t extsymoff;
+ size_t num_sym;
Elf_Internal_Sym *isymbuf;
Elf_Internal_Sym *isym;
Elf_Internal_Sym *isymend;
return true;
symtab_hdr = &elf_symtab_hdr (input_bfd);
+ num_sym = symtab_hdr->sh_size / bed->s->sizeof_sym;
if (elf_bad_symtab (input_bfd))
{
- locsymcount = symtab_hdr->sh_size / bed->s->sizeof_sym;
+ locsymcount = num_sym;
extsymoff = 0;
}
else
struct elf_link_hash_entry *h;
h = _bfd_elf_get_link_hash_entry (sym_hashes, symndx,
- extsymoff);
+ extsymoff, num_sym);
if (h == NULL)
{
_bfd_error_handler
&& flinfo->sections[r_symndx] == NULL))
{
h = _bfd_elf_get_link_hash_entry (sym_hashes, r_symndx,
- extsymoff);
+ extsymoff, num_sym);
/* Badly formatted input files can contain relocs that
reference non-existant symbols. Check here so that
return false;
/* Symbol evaluated OK. Update to absolute value. */
- if (!set_symbol_value (input_bfd, isymbuf, locsymcount, r_symndx,
- val))
+ if (!set_symbol_value (input_bfd, isymbuf, locsymcount,
+ num_sym, r_symndx, val))
return false;
continue;
for this symbol. The symbol index is then
set at the end of bfd_elf_final_link. */
rh = _bfd_elf_get_link_hash_entry (sym_hashes, r_symndx,
- extsymoff);
+ extsymoff, num_sym);
if (rh == NULL)
{
/* FIXME: Generate an error ? */
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
cookie->abfd = abfd;
+ cookie->num_sym = symtab_hdr->sh_size / bed->s->sizeof_sym;
if (elf_bad_symtab (abfd))
{
- cookie->locsymcount = symtab_hdr->sh_size / bed->s->sizeof_sym;
+ cookie->locsymcount = cookie->num_sym;
cookie->extsymoff = 0;
}
else
}
h = _bfd_elf_get_link_hash_entry (sym_hashes, r_symndx,
- symtab_hdr->sh_info);
+ symtab_hdr->sh_info,
+ NUM_SHDR_ENTRIES (symtab_hdr));
if (X86_NEED_DYNAMIC_RELOC_TYPE_P (is_x86_64, r_type)
&& NEED_DYNAMIC_RELOCATION_P (is_x86_64, info, true, h, sec,
{
/* Get H and SEC for GENERATE_DYNAMIC_RELOCATION_P below. */
h = _bfd_elf_get_link_hash_entry (sym_hashes, r_symndx,
- symtab_hdr->sh_info);
+ symtab_hdr->sh_info,
+ NUM_SHDR_ENTRIES (symtab_hdr));
if (h == NULL)
{
/* FIXMEL: Issue an error message ? */