* ld-selective/selective.exp <no CXX>: Fix typo for argument to
[deliverable/binutils-gdb.git] / gdb / elfread.c
index afb043de1f1f81ff3680dc4949d9352c89510a58..b964552ea0075590340e43dc7e9a558ae610b4f7 100644 (file)
@@ -33,7 +33,7 @@
 #include "complaints.h"
 #include "demangle.h"
 
-extern void _initialize_elfread PARAMS ((void));
+extern void _initialize_elfread (void);
 
 /* The struct elfinfo is available only during ELF symbol table and
    psymtab reading.  It is destroyed at the completion of psymtab-reading.
@@ -64,32 +64,29 @@ struct complaint stab_info_mismatch_complaint =
 struct complaint stab_info_questionable_complaint =
 {"elf/stab section information questionable for %s", 0, 0};
 
-static void
-elf_symfile_init PARAMS ((struct objfile *));
+static void elf_symfile_init (struct objfile *);
 
-static void
-elf_new_init PARAMS ((struct objfile *));
+static void elf_new_init (struct objfile *);
 
-static void
-elf_symfile_read PARAMS ((struct objfile *, int));
+static void elf_symfile_read (struct objfile *, int);
 
-static void
-elf_symfile_finish PARAMS ((struct objfile *));
+static void elf_symfile_finish (struct objfile *);
 
-static void
-elf_symtab_read PARAMS ((struct objfile *, int));
+static void elf_symtab_read (struct objfile *, int);
 
-static void
-free_elfinfo PARAMS ((void *));
+static void free_elfinfo (void *);
 
-static struct minimal_symbol *
-  record_minimal_symbol_and_info PARAMS ((char *, CORE_ADDR,
-                                         enum minimal_symbol_type, char *,
-                                         asection * bfd_section,
-                                         struct objfile *));
+static struct minimal_symbol *record_minimal_symbol_and_info (char *,
+                                                             CORE_ADDR,
+                                                             enum
+                                                             minimal_symbol_type,
+                                                             char *,
+                                                             asection *
+                                                             bfd_section,
+                                                             struct objfile
+                                                             *);
 
-static void
-elf_locate_sections PARAMS ((bfd *, asection *, void *));
+static void elf_locate_sections (bfd *, asection *, void *);
 
 /* We are called once per section from elf_symfile_read.  We
    need to examine each section we are passed, check to see
@@ -111,10 +108,7 @@ elf_locate_sections PARAMS ((bfd *, asection *, void *));
    -kingdon).  */
 
 static void
-elf_locate_sections (ignore_abfd, sectp, eip)
-     bfd *ignore_abfd;
-     asection *sectp;
-     PTR eip;
+elf_locate_sections (bfd *ignore_abfd, asection *sectp, PTR eip)
 {
   register struct elfinfo *ei;
 
@@ -146,8 +140,7 @@ elf_locate_sections (ignore_abfd, sectp, eip)
 #if 0                          /* Currently unused */
 
 char *
-elf_interpreter (abfd)
-     bfd *abfd;
+elf_interpreter (bfd *abfd)
 {
   sec_ptr interp_sec;
   unsigned size;
@@ -174,14 +167,9 @@ elf_interpreter (abfd)
 #endif
 
 static struct minimal_symbol *
-record_minimal_symbol_and_info (name, address, ms_type, info, bfd_section,
-                               objfile)
-     char *name;
-     CORE_ADDR address;
-     enum minimal_symbol_type ms_type;
-     char *info;               /* FIXME, is this really char *? */
-     asection *bfd_section;
-     struct objfile *objfile;
+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;
 
@@ -191,18 +179,16 @@ record_minimal_symbol_and_info (name, address, ms_type, info, bfd_section,
     {
     case mst_text:
     case mst_file_text:
-      section = SECT_OFF_TEXT;
+      section = bfd_section->index;
 #ifdef SMASH_TEXT_ADDRESS
       SMASH_TEXT_ADDRESS (address);
 #endif
       break;
     case mst_data:
     case mst_file_data:
-      section = SECT_OFF_DATA;
-      break;
     case mst_bss:
     case mst_file_bss:
-      section = SECT_OFF_BSS;
+      section = bfd_section->index;
       break;
     default:
       section = -1;
@@ -238,9 +224,7 @@ record_minimal_symbol_and_info (name, address, ms_type, info, bfd_section,
  */
 
 static void
-elf_symtab_read (objfile, dynamic)
-     struct objfile *objfile;
-     int dynamic;
+elf_symtab_read (struct objfile *objfile, int dynamic)
 {
   long storage_needed;
   asymbol *sym;
@@ -293,8 +277,7 @@ elf_symtab_read (objfile, dynamic)
       if (number_of_symbols < 0)
        error ("Can't read symbols from %s: %s", bfd_get_filename (objfile->obfd),
               bfd_errmsg (bfd_get_error ()));
-      /* FIXME: Should use section specific offset, not SECT_OFF_TEXT. */
-      offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+
       for (i = 0; i < number_of_symbols; i++)
        {
          sym = symbol_table[i];
@@ -305,6 +288,7 @@ elf_symtab_read (objfile, dynamic)
              continue;
            }
 
+          offset = ANOFFSET (objfile->section_offsets, sym->section->index);
          if (dynamic
              && sym->section == &bfd_und_section
              && (sym->flags & BSF_FUNCTION))
@@ -375,7 +359,7 @@ elf_symtab_read (objfile, dynamic)
              if (sym->section == &bfd_abs_section)
                {
                  /* This is a hack to get the minimal symbol type
-                    right for Irix 5, which has absolute adresses
+                    right for Irix 5, which has absolute addresses
                     with special section indices for dynamic symbols. */
                  unsigned short shndx =
                  ((elf_symbol_type *) sym)->internal_elf_sym.st_shndx;
@@ -460,15 +444,15 @@ elf_symtab_read (objfile, dynamic)
                      index = SECT_OFF_MAX;
                      if (STREQ ("Bbss.bss", sym->name))
                        {
-                         index = SECT_OFF_BSS;
+                         index = SECT_OFF_BSS (objfile);
                        }
                      else if (STREQ ("Ddata.data", sym->name))
                        {
-                         index = SECT_OFF_DATA;
+                         index = SECT_OFF_DATA (objfile);
                        }
                      else if (STREQ ("Drodata.rodata", sym->name))
                        {
-                         index = SECT_OFF_RODATA;
+                         index = SECT_OFF_RODATA (objfile);
                        }
                      if (index != SECT_OFF_MAX)
                        {
@@ -490,11 +474,16 @@ elf_symtab_read (objfile, 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 ("Section index uninitialized.");
                          /* Bfd symbols are section relative. */
                          symaddr = sym->value + sym->section->vma;
                          /* Relocate non-absolute symbols by the section offset. */
@@ -502,7 +491,10 @@ elf_symtab_read (objfile, dynamic)
                            {
                              symaddr += offset;
                            }
-                         sectinfo->sections[index] = symaddr;
+                         if (index != -1)
+                           sectinfo->sections[index] = symaddr;
+                         else
+                           internal_error ("Section index uninitialized.");
                          /* The special local symbols don't go in the
                             minimal symbol table, so ignore this one. */
                          continue;
@@ -583,9 +575,7 @@ elf_symtab_read (objfile, dynamic)
    capability even for files compiled without -g.  */
 
 static void
-elf_symfile_read (objfile, mainline)
-     struct objfile *objfile;
-     int mainline;
+elf_symfile_read (struct objfile *objfile, int mainline)
 {
   bfd *abfd = objfile->obfd;
   struct elfinfo ei;
@@ -593,7 +583,7 @@ elf_symfile_read (objfile, mainline)
   CORE_ADDR offset;
 
   init_minimal_symbol_collection ();
-  back_to = make_cleanup ((make_cleanup_func) discard_minimal_symbols, 0);
+  back_to = make_cleanup_discard_minimal_symbols ();
 
   memset ((char *) &ei, 0, sizeof (ei));
 
@@ -693,8 +683,7 @@ elf_symfile_read (objfile, mainline)
    stab_section_info's, that might be dangling from it.  */
 
 static void
-free_elfinfo (objp)
-     PTR objp;
+free_elfinfo (PTR objp)
 {
   struct objfile *objfile = (struct objfile *) objp;
   struct dbx_symfile_info *dbxinfo = objfile->sym_stab_info;
@@ -719,8 +708,7 @@ free_elfinfo (objp)
    We reinitialize buildsym, since we may be reading stabs from an ELF file.  */
 
 static void
-elf_new_init (ignore)
-     struct objfile *ignore;
+elf_new_init (struct objfile *ignore)
 {
   stabsread_new_init ();
   buildsym_new_init ();
@@ -732,8 +720,7 @@ elf_new_init (ignore)
    objfile struct from the global list of known objfiles. */
 
 static void
-elf_symfile_finish (objfile)
-     struct objfile *objfile;
+elf_symfile_finish (struct objfile *objfile)
 {
   if (objfile->sym_stab_info != NULL)
     {
@@ -751,8 +738,7 @@ elf_symfile_finish (objfile)
    just a stub. */
 
 static void
-elf_symfile_init (objfile)
-     struct objfile *objfile;
+elf_symfile_init (struct objfile *objfile)
 {
   /* ELF objects may be reordered, so set OBJF_REORDERED.  If we
      find this causes a significant slowdown in gdb then we could
@@ -769,9 +755,7 @@ elf_symfile_init (objfile)
    with wierd names.  Go get 'em when needed.  */
 
 void
-elfstab_offset_sections (objfile, pst)
-     struct objfile *objfile;
-     struct partial_symtab *pst;
+elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst)
 {
   char *filename = pst->filename;
   struct dbx_symfile_info *dbx = objfile->sym_stab_info;
@@ -814,7 +798,7 @@ elfstab_offset_sections (objfile, 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;
     }
 
@@ -837,7 +821,7 @@ static struct sym_fns elf_sym_fns =
 };
 
 void
-_initialize_elfread ()
+_initialize_elfread (void)
 {
   add_symtab_fns (&elf_sym_fns);
 }
This page took 0.026666 seconds and 4 git commands to generate.