Put GDB's terminal settings into effect when paginating
[deliverable/binutils-gdb.git] / gdb / somread.c
index 44b0c85c8d689f5a7bea9aaa91749d792bbc30ba..4a7837e5923ba24450ff44b9cea7747f4fece3ce 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-2014 Free Software Foundation, Inc.
    Written by Fred Fish at Cygnus Support.
 
    This file is part of GDB.
@@ -27,7 +27,7 @@
 #include "stabsread.h"
 #include "gdb-stabs.h"
 #include "complaints.h"
-#include "gdb_string.h"
+#include <string.h>
 #include "demangle.h"
 #include "som.h"
 #include "libhppa.h"
@@ -46,6 +46,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 +54,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 +91,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 +149,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 +161,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 +193,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 +223,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 +233,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 +265,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 +287,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;
@@ -314,9 +307,10 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
       prim_record_minimal_symbol_and_info (symname, symbol_value, ms_type,
                                           gdb_bfd_section_index (objfile->obfd,
                                                                  section),
-                                          section,
                                           objfile);
     }
+
+  do_cleanups (cleanup);
 }
 
 /* Scan and build partial symbols for a symbol file.
@@ -488,7 +482,8 @@ set_section_index (struct objfile *objfile, flagword invert, flagword flags,
    Plain and simple for now.  */
 
 static void
-som_symfile_offsets (struct objfile *objfile, struct section_addr_info *addrs)
+som_symfile_offsets (struct objfile *objfile,
+                    const struct section_addr_info *addrs)
 {
   int i;
   CORE_ADDR text_addr;
@@ -531,7 +526,6 @@ som_symfile_offsets (struct objfile *objfile, struct section_addr_info *addrs)
 
 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 +544,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.026214 seconds and 4 git commands to generate.