Trivially tweak the comment documenting initial_gdb_ttystate
[deliverable/binutils-gdb.git] / gdb / somread.c
index db6c4d441e9287632653f32130403e15f9e55935..2bee2b1fa55b1d01a3f28aad5866281021bb6040 100644 (file)
@@ -1,5 +1,5 @@
 /* Read HP PA/Risc object files for GDB.
-   Copyright (C) 1991-2013 Free Software Foundation, Inc.
+   Copyright (C) 1991-2015 Free Software Foundation, Inc.
    Written by Fred Fish at Cygnus Support.
 
    This file is part of GDB.
@@ -27,7 +27,6 @@
 #include "stabsread.h"
 #include "gdb-stabs.h"
 #include "complaints.h"
-#include "gdb_string.h"
 #include "demangle.h"
 #include "som.h"
 #include "libhppa.h"
@@ -46,6 +45,7 @@ static void
 som_symtab_read (bfd *abfd, struct objfile *objfile,
                 struct section_offsets *section_offsets)
 {
+  struct cleanup *cleanup;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   unsigned int number_of_symbols;
   int val, dynamic;
@@ -53,19 +53,16 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
   asection *shlib_info;
   struct som_external_symbol_dictionary_record *buf, *bufp, *endbufp;
   char *symname;
-  CONST int symsize = sizeof (struct som_external_symbol_dictionary_record);
+  const int symsize = sizeof (struct som_external_symbol_dictionary_record);
 
 
-#define text_offset ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile))
-#define data_offset ANOFFSET (section_offsets, SECT_OFF_DATA (objfile))
-
   number_of_symbols = bfd_get_symcount (abfd);
 
   /* Allocate a buffer to read in the debug info.
      We avoid using alloca because the memory size could be so large
      that we could hit the stack size limit.  */
   buf = xmalloc (symsize * number_of_symbols);
-  make_cleanup (xfree, buf);
+  cleanup = make_cleanup (xfree, buf);
   bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET);
   val = bfd_bread (buf, symsize * number_of_symbols, abfd);
   if (val != symsize * number_of_symbols)
@@ -93,7 +90,7 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
      more accurate to check for a nonzero text offset, but they
      have not provided any information about why that test is
      more accurate.  */
-  dynamic = (text_offset != 0);
+  dynamic = (ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)) != 0);
 
   endbufp = buf + number_of_symbols;
   for (bufp = buf; bufp < endbufp; ++bufp)
@@ -151,7 +148,6 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
            case ST_MILLICODE:
              symname = bfd_getb32 (bufp->name) + stringtab;
              ms_type = mst_text;
-             symbol_value += text_offset;
              symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
              break;
 
@@ -164,20 +160,17 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
                ms_type = mst_solib_trampoline;
              else
                ms_type = mst_text;
-             symbol_value += text_offset;
              symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
              break;
 
            case ST_STUB:
              symname = bfd_getb32 (bufp->name) + stringtab;
              ms_type = mst_solib_trampoline;
-             symbol_value += text_offset;
              symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
              break;
 
            case ST_DATA:
              symname = bfd_getb32 (bufp->name) + stringtab;
-             symbol_value += data_offset;
              ms_type = mst_data;
              break;
            default:
@@ -199,7 +192,6 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
            case ST_CODE:
              symname = bfd_getb32 (bufp->name) + stringtab;
              ms_type = mst_file_text;
-             symbol_value += text_offset;
              symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
 
            check_strange_names:
@@ -230,7 +222,6 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
            case ST_MILLICODE:
              symname = bfd_getb32 (bufp->name) + stringtab;
              ms_type = mst_file_text;
-             symbol_value += text_offset;
              symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
              break;
 
@@ -241,21 +232,18 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
                 using mst_file_text vs mst_solib_trampoline here like
                 we do for SS_UNIVERSAL and SS_EXTERNAL symbols above.  */
              ms_type = mst_file_text;
-             symbol_value += text_offset;
              symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
              break;
 
            case ST_STUB:
              symname = bfd_getb32 (bufp->name) + stringtab;
              ms_type = mst_solib_trampoline;
-             symbol_value += text_offset;
              symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
              break;
 
 
            case ST_DATA:
              symname = bfd_getb32 (bufp->name) + stringtab;
-             symbol_value += data_offset;
              ms_type = mst_file_data;
              goto check_strange_names;
 
@@ -276,7 +264,6 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
            case ST_STORAGE:
            case ST_DATA:
              symname = bfd_getb32 (bufp->name) + stringtab;
-             symbol_value += data_offset;
              ms_type = mst_data;
              break;
 
@@ -299,11 +286,16 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
 
          ALL_OBJFILE_OSECTIONS (objfile, iter)
            {
+             CORE_ADDR start;
+             CORE_ADDR len;
+
              if (bfd_is_const_section (iter->the_bfd_section))
                continue;
 
-             if (obj_section_addr (iter) <= symbol_value
-                 && symbol_value < obj_section_endaddr (iter))
+             start = bfd_get_section_vma (iter->objfile->obfd,
+                                          iter->the_bfd_section);
+             len = bfd_get_section_size (iter->the_bfd_section);
+             if (start <= symbol_value && symbol_value < start + len)
                {
                  section = iter->the_bfd_section;
                  break;
@@ -316,6 +308,8 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
                                                                  section),
                                           objfile);
     }
+
+  do_cleanups (cleanup);
 }
 
 /* Scan and build partial symbols for a symbol file.
@@ -531,7 +525,6 @@ som_symfile_offsets (struct objfile *objfile,
 
 static const struct sym_fns som_sym_fns =
 {
-  bfd_target_som_flavour,
   som_new_init,                        /* init anything gbl to entire symtab */
   som_symfile_init,            /* read initial info, setup for sym_read() */
   som_symfile_read,            /* read a symbol file into symtab */
@@ -550,5 +543,5 @@ initialize_file_ftype _initialize_somread;
 void
 _initialize_somread (void)
 {
-  add_symtab_fns (&som_sym_fns);
+  add_symtab_fns (bfd_target_som_flavour, &som_sym_fns);
 }
This page took 0.0267 seconds and 4 git commands to generate.