* hppa-tdep.c (hppa_push_arguments): Allocate enough space for
[deliverable/binutils-gdb.git] / gdb / elfread.c
index 5135e10fc70fed650f79422c2fa0e7d36ecc3eca..4a562e09ce7bfde0a3f702e53e2128108635312d 100644 (file)
@@ -33,11 +33,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  ************************************************************************/
 
 #include "defs.h"
-#include "elf/common.h"
-#include "elf/external.h"
-#include "elf/internal.h"
 #include "bfd.h"
 #include "libbfd.h"            /* For bfd_elf_find_section */
+#include "libelf.h"
 #include "symtab.h"
 #include "symfile.h"
 #include "objfiles.h"
@@ -45,8 +43,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "gdb-stabs.h"
 #include "complaints.h"
 #include <string.h>
-
-#define STREQ(a,b) (strcmp((a),(b))==0)
+#include "demangle.h"
 
 /* The struct elfinfo is available only during ELF symbol table and
    psymtab reading.  It is destroyed at the complation of psymtab-reading.
@@ -96,12 +93,6 @@ free_elfinfo PARAMS ((PTR));
 static struct section_offsets *
 elf_symfile_offsets PARAMS ((struct objfile *, CORE_ADDR));
 
-#if 0
-static void
-record_minimal_symbol PARAMS ((char *, CORE_ADDR, enum minimal_symbol_type,
-                              struct objfile *));
-#endif
-
 static void
 record_minimal_symbol_and_info PARAMS ((char *, CORE_ADDR,
                                        enum minimal_symbol_type, char *,
@@ -185,39 +176,6 @@ elf_interpreter (abfd)
 
 #endif
 
-/*
-
-LOCAL FUNCTION
-
-       record_minimal_symbol -- add entry to minimal symbol table
-
-SYNOPSIS
-
-       static void record_minimal_symbol (char *name, CORE_ADDR address)
-
-DESCRIPTION
-
-       Given a pointer to the name of a symbol that should be added to the
-       minimal symbol table and the address associated with that symbol, records
-       this information for later use in building the minimal symbol table.
-
- */
-
-#if 0  /* FIXME:  Unused */
-
-static void
-record_minimal_symbol (name, address, ms_type, objfile)
-     char *name;
-     CORE_ADDR address;
-     enum minimal_symbol_type ms_type;
-     struct objfile *objfile;
-{
-  name = obsavestring (name, strlen (name), &objfile -> symbol_obstack);
-  prim_record_minimal_symbol (name, address, ms_type);
-}
-
-#endif
-
 static void
 record_minimal_symbol_and_info (name, address, ms_type, info, objfile)
      char *name;
@@ -227,7 +185,7 @@ record_minimal_symbol_and_info (name, address, ms_type, info, objfile)
      struct objfile *objfile;
 {
   name = obsavestring (name, strlen (name), &objfile -> symbol_obstack);
-  prim_record_minimal_symbol_and_info (name, address, ms_type, info);
+  prim_record_minimal_symbol_and_info (name, address, ms_type, info, -1);
 }
 
 /*
@@ -297,7 +255,8 @@ elf_symtab_read (abfd, addr, objfile)
          if ((sym -> flags & (BSF_GLOBAL | BSF_WEAK))
              && (sym -> section != NULL))
            {
-             symaddr = sym -> value;
+             /* Bfd symbols are section relative. */
+             symaddr = sym -> value + sym -> section -> vma;
              /* Relocate all non-absolute symbols by base address.  */
              if (sym -> section != &bfd_abs_section)
                symaddr += addr;
@@ -323,8 +282,12 @@ elf_symtab_read (abfd, addr, objfile)
                  continue;             /* Skip this symbol. */
                }
              /* Pass symbol size field in via BFD.  FIXME!!!  */
-             record_minimal_symbol_and_info ((char *) sym -> name,
-                        symaddr, ms_type, sym->udata, objfile);
+             {
+               elf32_symbol_type *esym = (elf32_symbol_type *) sym;
+               unsigned long size = esym->internal_elf_sym.st_size;
+               record_minimal_symbol_and_info ((char *) sym -> name, symaddr,
+                                               ms_type, (PTR) size, objfile);
+             }
            }
 
          /* See if this is a debugging symbol that helps Solaris
@@ -351,15 +314,15 @@ elf_symtab_read (abfd, addr, objfile)
              switch (sym->name[1])
                {
                  case 'b':
-                       if (!strcmp ("Bbss.bss", sym->name))
+                       if (STREQ ("Bbss.bss", sym->name))
                          index = SECT_OFF_BSS;
                        break;
                  case 'd':
-                       if (!strcmp ("Ddata.data", sym->name))
+                       if (STREQ ("Ddata.data", sym->name))
                          index = SECT_OFF_DATA;
                        break;
                  case 'r':
-                       if (!strcmp ("Drodata.rodata", sym->name))
+                       if (STREQ ("Drodata.rodata", sym->name))
                          index = SECT_OFF_RODATA;
                        break;
                }
@@ -381,7 +344,8 @@ elf_symtab_read (abfd, addr, objfile)
                  if (sectinfo->sections[index])
                    complain (&section_info_dup_complaint, sectinfo->filename);
 
-                 symaddr = sym -> value;
+                 /* Bfd symbols are section relative. */
+                 symaddr = sym -> value + sym -> section -> vma;
                  /* Relocate all non-absolute symbols by base address.  */
                  if (sym -> section != &bfd_abs_section)
                      symaddr += addr;
@@ -476,7 +440,7 @@ elf_symfile_read (objfile, section_offsets, mainline)
         sections visible to the caller.  So we have to search the
         ELF section table, not the BFD section table, for the string
         table.  */
-      struct elf_internal_shdr *elf_sect;
+      struct elf32_internal_shdr *elf_sect;
 
       elf_sect = bfd_elf_find_section (abfd, ".stabstr");
       if (elf_sect)
@@ -628,7 +592,7 @@ elfstab_offset_sections (objfile, pst)
   for (; maybe; maybe = maybe->next)
     {
       if (filename[0] == maybe->filename[0]
-         && !strcmp (filename, maybe->filename))
+         && STREQ (filename, maybe->filename))
        {
          /* We found a match.  But there might be several source files
             (from different directories) with the same name.  */
This page took 0.025546 seconds and 4 git commands to generate.