]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* bfd-in.h (bfd_get_dynamic_symcount): Define.
authorDaniel Jacobowitz <drow@false.org>
Wed, 18 Sep 2002 02:39:43 +0000 (02:39 +0000)
committerDaniel Jacobowitz <drow@false.org>
Wed, 18 Sep 2002 02:39:43 +0000 (02:39 +0000)
        * bfd.c (struct _bfd): Add dynsymcount.
        * bfd-in2.h: Regenerated.
        * elf.c (_bfd_elf_canonicalize_dynamic_symtab): Set
        abfd->dynsymcount.
        * elfcode.h (elf_slurp_reloc_table_from_section): Check
        for overflow.

bfd/ChangeLog
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/bfd.c
bfd/elf.c
bfd/elfcode.h

index ce930f809b48f8078ec6b7609cf5345b526dc970..f0c5ef56b83225a2bb06d37b3b2a91e14cd0b678 100644 (file)
@@ -1,3 +1,13 @@
+2002-09-17  Daniel Jacobowitz  <drow@mvista.com>
+
+       * bfd-in.h (bfd_get_dynamic_symcount): Define.
+       * bfd.c (struct _bfd): Add dynsymcount.
+       * bfd-in2.h: Regenerated.
+       * elf.c (_bfd_elf_canonicalize_dynamic_symtab): Set
+       abfd->dynsymcount.
+       * elfcode.h (elf_slurp_reloc_table_from_section): Check
+       for overflow.
+
 2002-09-17  Stan Cox <scox@redhat.com> 
 
        * elf64-mips.c (mips_elf64_be_swap_reloca_out): Handle type2 and type3.
index 3941906979e4ed2c89cbe538e4424adff3878aee..f30e20d0cbd108e6bbbfb3f5e7a261df8e89497a 100644 (file)
@@ -529,6 +529,8 @@ extern void warn_deprecated
 #define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
 #define bfd_count_sections(abfd) ((abfd)->section_count)
 
+#define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount)
+
 #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
 
 #define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean) (bool)), true)
index abb6405f579c674334db238d8ca22dc935d52870..b6edd0a04c9fff474179c2fa5b8e8ff3c0533b1f 100644 (file)
@@ -535,6 +535,8 @@ extern void warn_deprecated
 #define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
 #define bfd_count_sections(abfd) ((abfd)->section_count)
 
+#define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount)
+
 #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
 
 #define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean) (bool)), true)
@@ -1629,7 +1631,6 @@ enum bfd_architecture
   bfd_arch_v850,      /* NEC V850 */
 #define bfd_mach_v850          0
 #define bfd_mach_v850e         'E'
-#define bfd_mach_v850ea        'A'
   bfd_arch_arc,       /* ARC Cores */
 #define bfd_mach_arc_5         0
 #define bfd_mach_arc_6         1
@@ -3462,6 +3463,9 @@ struct _bfd
   /* Symbol table for output BFD (with symcount entries).  */
   struct symbol_cache_entry  **outsymbols;
 
+  /* Used for slurped dynamic symbol tables.  */
+  unsigned int dynsymcount;
+
   /* Pointer to structure which contains architecture information.  */
   const struct bfd_arch_info *arch_info;
 
index 277c74a7422762c8c7a7f44b18522a7ba472d513..cfd77726a3edcb806420e028c31c96b96f7eb779 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -128,6 +128,9 @@ CODE_FRAGMENT
 .  {* Symbol table for output BFD (with symcount entries).  *}
 .  struct symbol_cache_entry  **outsymbols;
 .
+.  {* Used for slurped dynamic symbol tables.  *}
+.  unsigned int dynsymcount;
+.
 .  {* Pointer to structure which contains architecture information.  *}
 .  const struct bfd_arch_info *arch_info;
 .
index 7f54909af96a5d236cfda2ea0d4f3f15b67d1fca..b8a300e4a64ae13cc1954d1cc2236e53f1332082 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5572,7 +5572,11 @@ _bfd_elf_canonicalize_dynamic_symtab (abfd, alocation)
      asymbol **alocation;
 {
   struct elf_backend_data *bed = get_elf_backend_data (abfd);
-  return bed->s->slurp_symbol_table (abfd, alocation, true);
+  long symcount = bed->s->slurp_symbol_table (abfd, alocation, true);
+
+  if (symcount >= 0)
+    bfd_get_dynamic_symcount (abfd) = symcount;
+  return symcount;
 }
 
 /* Return the size required for the dynamic reloc entries.  Any
index eb667eb50e223a17ab7e275e05a785f9f9361f2c..7f9ed5fe3afdc943b889bd114aaffbc295d78d34 100644 (file)
@@ -1421,6 +1421,13 @@ elf_slurp_reloc_table_from_section (abfd, asect, rel_hdr, reloc_count,
 
       if (ELF_R_SYM (rela.r_info) == 0)
        relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+      else if (ELF_R_SYM (rela.r_info) > bfd_get_dynamic_symcount (abfd))
+       {
+         (*_bfd_error_handler)
+           (_("%s(%s): relocation %d has invalid symbol index %ld"),
+            abfd->filename, asect->name, i, ELF_R_SYM (rela.r_info));
+         relent->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+       }
       else
        {
          asymbol **ps, *s;