Touches most files in bfd/, so likely will be blamed for everything..
[deliverable/binutils-gdb.git] / bfd / syms.c
index 5d885a467aef99ac50ddd26bdfe6c3a1ddf47ec0..9c8922b3cfd66785c9d68d09e5edfe5f25cfb37b 100644 (file)
@@ -197,7 +197,7 @@ CODE_FRAGMENT
 .
 .      {* The text of the symbol. The name is left alone, and not copied; the
 .         application may not alter it. *}
-.  CONST char *name;
+.  const char *name;
 .
 .      {* The value of the symbol.  This really should be a union of a
 .          numeric value with a pointer, since some flags indicate that
@@ -508,14 +508,14 @@ DESCRIPTION
 
 struct section_to_type
 {
-  CONST char *section;
+  const char *section;
   char type;
 };
 
 /* Map section names to POSIX/BSD single-character symbol types.
    This table is probably incomplete.  It is sorted for convenience of
    adding entries.  Since it is so short, a linear search is used.  */
-static CONST struct section_to_type stt[] =
+static const struct section_to_type stt[] =
 {
   {"*DEBUG*", 'N'},
   {".bss", 'b'},
@@ -547,7 +547,7 @@ static char
 coff_section_type (s)
      const char *s;
 {
-  CONST struct section_to_type *t;
+  const struct section_to_type *t;
 
   for (t = &stt[0]; t->section; t++)
     if (!strncmp (s, t->section, strlen (t->section)))
@@ -722,7 +722,7 @@ _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep)
   if (storage < 0)
     goto error_return;
 
-  syms = (asymbol **) bfd_malloc ((size_t) storage);
+  syms = (asymbol **) bfd_malloc ((bfd_size_type) storage);
   if (syms == NULL)
     goto error_return;
 
@@ -852,7 +852,8 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
   bfd_byte *last_stab = NULL;
   bfd_size_type stroff;
   struct indexentry *indexentry;
-  char *directory_name, *file_name;
+  char *file_name;
+  char *directory_name;
   int saw_fun;
 
   *pfound = false;
@@ -898,11 +899,10 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
       arelent **reloc_vector;
       int i;
       char *name;
-      char *file_name;
-      char *directory_name;
       char *function_name;
+      bfd_size_type amt = sizeof *info;
 
-      info = (struct stab_find_info *) bfd_zalloc (abfd, sizeof *info);
+      info = (struct stab_find_info *) bfd_zalloc (abfd, amt);
       if (info == NULL)
        return false;
 
@@ -929,10 +929,10 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
       if (info->stabs == NULL || info->strs == NULL)
        return false;
 
-      if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs, 0,
-                                     stabsize)
-         || ! bfd_get_section_contents (abfd, info->strsec, info->strs, 0,
-                                        strsize))
+      if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs,
+                                     (bfd_vma) 0, stabsize)
+         || ! bfd_get_section_contents (abfd, info->strsec, info->strs,
+                                        (bfd_vma) 0, strsize))
        return false;
 
       /* If this is a relocateable object file, we have to relocate
@@ -942,7 +942,7 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
       reloc_size = bfd_get_reloc_upper_bound (abfd, info->stabsec);
       if (reloc_size < 0)
        return false;
-      reloc_vector = (arelent **) bfd_malloc (reloc_size);
+      reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
       if (reloc_vector == NULL && reloc_size != 0)
        return false;
       reloc_count = bfd_canonicalize_reloc (abfd, info->stabsec, reloc_vector,
@@ -983,7 +983,7 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
              val &= r->howto->src_mask;
              sym = *r->sym_ptr_ptr;
              val += sym->value + sym->section->vma + r->addend;
-             bfd_put_32 (abfd, val, info->stabs + r->address);
+             bfd_put_32 (abfd, (bfd_vma) val, info->stabs + r->address);
            }
        }
 
@@ -1033,10 +1033,9 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
        return true;
       ++info->indextablesize;
 
-      info->indextable = ((struct indexentry *)
-                         bfd_alloc (abfd,
-                                    (sizeof (struct indexentry)
-                                     * info->indextablesize)));
+      amt = info->indextablesize;
+      amt *= sizeof (struct indexentry);
+      info->indextable = (struct indexentry *) bfd_alloc (abfd, amt);
       if (info->indextable == NULL)
        return false;
 
@@ -1154,7 +1153,8 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
       ++i;
 
       info->indextablesize = i;
-      qsort (info->indextable, i, sizeof (struct indexentry), cmpindexentry);
+      qsort (info->indextable, (size_t) i, sizeof (struct indexentry),
+            cmpindexentry);
 
       *pinfo = (PTR) info;
     }
@@ -1276,9 +1276,8 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
        {
          if (info->filename != NULL)
            free (info->filename);
-         info->filename = (char *) bfd_malloc (dirlen +
-                                               strlen (file_name)
-                                               + 1);
+         info->filename = (char *) bfd_malloc ((bfd_size_type) dirlen
+                                               + strlen (file_name) + 1);
          if (info->filename == NULL)
            return false;
          strcpy (info->filename, directory_name);
This page took 0.025708 seconds and 4 git commands to generate.