* cgen-ibld.in (insert_normal): Support CGEN_IFLD_SIGN_OPT.
[deliverable/binutils-gdb.git] / gdb / elfread.c
index 3de6b5eb23b7e63b6e0e5d29392b0f77d1399129..4394e5a51877e6c2325bee142c384b7aac3d0619 100644 (file)
@@ -1,5 +1,7 @@
 /* Read ELF (Executable and Linking Format) object files for GDB.
-   Copyright 1991, 92, 93, 94, 95, 96, 1998 Free Software Foundation, Inc.
+   Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+   2001
+   Free Software Foundation, Inc.
    Written by Fred Fish at Cygnus Support.
 
    This file is part of GDB.
@@ -74,7 +76,7 @@ static void elf_symfile_finish (struct objfile *);
 
 static void elf_symtab_read (struct objfile *, int);
 
-static void free_elfinfo (void *);
+static void free_elfinfo (PTR);
 
 static struct minimal_symbol *record_minimal_symbol_and_info (char *,
                                                              CORE_ADDR,
@@ -86,7 +88,7 @@ static struct minimal_symbol *record_minimal_symbol_and_info (char *,
                                                              struct objfile
                                                              *);
 
-static void elf_locate_sections (bfd *, asection *, void *);
+static void elf_locate_sections (bfd *, asection *, PTR);
 
 /* We are called once per section from elf_symfile_read.  We
    need to examine each section we are passed, check to see
@@ -171,32 +173,13 @@ record_minimal_symbol_and_info (char *name, CORE_ADDR address,
                                enum minimal_symbol_type ms_type, char *info,   /* FIXME, is this really char *? */
                                asection *bfd_section, struct objfile *objfile)
 {
-  int section;
-
-  /* Guess the section from the type.  This is likely to be wrong in
-     some cases.  */
-  switch (ms_type)
-    {
-    case mst_text:
-    case mst_file_text:
-      section = bfd_section->index;
 #ifdef SMASH_TEXT_ADDRESS
-      SMASH_TEXT_ADDRESS (address);
+  if (ms_type == mst_text || ms_type == mst_file_text)
+    SMASH_TEXT_ADDRESS (address);
 #endif
-      break;
-    case mst_data:
-    case mst_file_data:
-    case mst_bss:
-    case mst_file_bss:
-      section = bfd_section->index;
-      break;
-    default:
-      section = -1;
-      break;
-    }
 
   return prim_record_minimal_symbol_and_info
-    (name, address, ms_type, info, section, bfd_section, objfile);
+    (name, address, ms_type, info, bfd_section->index, bfd_section, objfile);
 }
 
 /*
@@ -268,7 +251,7 @@ elf_symtab_read (struct objfile *objfile, int dynamic)
   if (storage_needed > 0)
     {
       symbol_table = (asymbol **) xmalloc (storage_needed);
-      back_to = make_cleanup (free, symbol_table);
+      back_to = make_cleanup (xfree, symbol_table);
       if (dynamic)
        number_of_symbols = bfd_canonicalize_dynamic_symtab (objfile->obfd,
                                                             symbol_table);
@@ -423,7 +406,7 @@ elf_symtab_read (struct objfile *objfile, int dynamic)
                }
              else if (sym->section->flags & SEC_ALLOC)
                {
-                 if (sym->flags & BSF_GLOBAL)
+                 if (sym->flags & (BSF_GLOBAL | BSF_WEAK))
                    {
                      if (sym->section->flags & SEC_LOAD)
                        {
@@ -474,11 +457,17 @@ elf_symtab_read (struct objfile *objfile, int dynamic)
                                    (char *) filesym->name;
                                }
                            }
-                         if (sectinfo->sections[index] != 0)
-                           {
-                             complain (&section_info_dup_complaint,
-                                       sectinfo->filename);
+                         if (index != -1)
+                           { 
+                             if (sectinfo->sections[index] != 0)
+                               {
+                                 complain (&section_info_dup_complaint,
+                                           sectinfo->filename);
+                               }
                            }
+                         else
+                           internal_error (__FILE__, __LINE__,
+                                           "Section index uninitialized.");
                          /* Bfd symbols are section relative. */
                          symaddr = sym->value + sym->section->vma;
                          /* Relocate non-absolute symbols by the section offset. */
@@ -486,7 +475,11 @@ elf_symtab_read (struct objfile *objfile, int dynamic)
                            {
                              symaddr += offset;
                            }
-                         sectinfo->sections[index] = symaddr;
+                         if (index != -1)
+                           sectinfo->sections[index] = symaddr;
+                         else
+                           internal_error (__FILE__, __LINE__,
+                                           "Section index uninitialized.");
                          /* The special local symbols don't go in the
                             minimal symbol table, so ignore this one. */
                          continue;
@@ -790,7 +783,7 @@ elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst)
       pst->section_offsets = (struct section_offsets *)
        obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
       for (i = 0; i < SECT_OFF_MAX; i++)
-       ANOFFSET (pst->section_offsets, i) = maybe->sections[i];
+       (pst->section_offsets)->offsets[i] = maybe->sections[i];
       return;
     }
 
This page took 0.033409 seconds and 4 git commands to generate.