From: H.J. Lu Date: Wed, 5 Apr 2006 13:37:32 +0000 (+0000) Subject: 2006-04-05 H.J. Lu X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c0d5a53d5200405a36d98646d8d3387154a21bf9;p=binutils-gdb.git 2006-04-05 H.J. Lu PR ld/2411 * elflink.c (check_dynsym): New. (elf_link_output_extsym): Use it. (bfd_elf_final_link): Likewise. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9f371a802d2..ae9a4a70eb8 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2006-04-05 H.J. Lu + + PR ld/2411 + * elflink.c (check_dynsym): New. + (elf_link_output_extsym): Use it. + (bfd_elf_final_link): Likewise. + 2006-04-05 H.J. Lu PR ld/2404 diff --git a/bfd/elflink.c b/bfd/elflink.c index f3098aedfdf..0900220dbca 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -6204,6 +6204,24 @@ elf_link_output_sym (struct elf_final_link_info *finfo, return TRUE; } +/* Return TRUE if the dynamic symbol SYM in ABFD is supported. */ + +static bfd_boolean +check_dynsym (bfd *abfd, Elf_Internal_Sym *sym) +{ + if (sym->st_shndx > SHN_HIRESERVE) + { + /* The gABI doesn't support dynamic symbols in output sections + beyond 64k. */ + (*_bfd_error_handler) + (_("%B: Too many sections: %d (>= %d)"), + abfd, bfd_count_sections (abfd), SHN_LORESERVE); + bfd_set_error (bfd_error_nonrepresentable_section); + return FALSE; + } + return TRUE; +} + /* For DSOs loaded in via a DT_NEEDED entry, emulate ld.so in allowing an unsatisfied unversioned symbol in the DSO to match a versioned symbol that would normally require an explicit version. @@ -6636,6 +6654,11 @@ elf_link_output_extsym (struct elf_link_hash_entry *h, void *data) sym.st_name = h->dynstr_index; esym = finfo->dynsym_sec->contents + h->dynindx * bed->s->sizeof_sym; + if (! check_dynsym (finfo->output_bfd, &sym)) + { + eoinfo->failed = TRUE; + return FALSE; + } bed->s->swap_symbol_out (finfo->output_bfd, &sym, esym, 0); bucketcount = elf_hash_table (finfo->info)->bucketcount; @@ -8313,6 +8336,8 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) indx = elf_section_data (s)->this_idx; BFD_ASSERT (indx > 0); sym.st_shndx = indx; + if (! check_dynsym (abfd, &sym)) + return FALSE; sym.st_value = s->vma; dest = dynsym + dynindx * bed->s->sizeof_sym; if (last_local < dynindx) @@ -8347,6 +8372,8 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) sym.st_shndx = elf_section_data (s->output_section)->this_idx; + if (! check_dynsym (abfd, &sym)) + return FALSE; sym.st_value = (s->output_section->vma + s->output_offset + e->isym.st_value);