Resolve more problems with readelf uncovered by fuzzing binary files.
[deliverable/binutils-gdb.git] / gdb / solib-dsbt.c
index 3585251e02622c54d6aa822d3d37756ade90918b..8da6ea4426b5c5611d48263994ed0c4dcb416b40 100644 (file)
@@ -1,5 +1,5 @@
 /* Handle TIC6X (DSBT) shared libraries for GDB, the GNU Debugger.
-   Copyright (C) 2010-2013 Free Software Foundation, Inc.
+   Copyright (C) 2010-2014 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -18,7 +18,6 @@
 
 
 #include "defs.h"
-#include "gdb_string.h"
 #include "inferior.h"
 #include "gdbcore.h"
 #include "solib.h"
@@ -29,7 +28,6 @@
 #include "command.h"
 #include "gdbcmd.h"
 #include "elf-bfd.h"
-#include "exceptions.h"
 #include "gdb_bfd.h"
 
 #define GOT_MODULE_OFFSET 4
@@ -154,8 +152,6 @@ struct dsbt_info
   /* Link map address for main module.  */
   CORE_ADDR main_lm_addr;
 
-  int enable_break2_done;
-
   CORE_ADDR interp_text_sect_low;
   CORE_ADDR interp_text_sect_high;
   CORE_ADDR interp_plt_sect_low;
@@ -168,10 +164,7 @@ static const struct program_space_data *solib_dsbt_pspace_data;
 static void
 dsbt_pspace_data_cleanup (struct program_space *pspace, void *arg)
 {
-  struct dsbt_info *info;
-
-  info = program_space_data (pspace, solib_dsbt_pspace_data);
-  xfree (info);
+  xfree (arg);
 }
 
 /* Get the current dsbt data.  If none is found yet, add it now.  This
@@ -186,10 +179,9 @@ get_dsbt_info (void)
   if (info != NULL)
     return info;
 
-  info = XZALLOC (struct dsbt_info);
+  info = XCNEW (struct dsbt_info);
   set_program_space_data (current_program_space, solib_dsbt_pspace_data, info);
 
-  info->enable_break2_done = 0;
   info->lm_base_cache = 0;
   info->main_lm_addr = 0;
 
@@ -556,7 +548,7 @@ static CORE_ADDR
 lm_base (void)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
-  struct minimal_symbol *got_sym;
+  struct bound_minimal_symbol got_sym;
   CORE_ADDR addr;
   gdb_byte buf[TIC6X_PTR_SIZE];
   struct dsbt_info *info = get_dsbt_info ();
@@ -576,9 +568,9 @@ lm_base (void)
   got_sym = lookup_minimal_symbol ("_GLOBAL_OFFSET_TABLE_", NULL,
                                   symfile_objfile);
 
-  if (got_sym != 0)
+  if (got_sym.minsym != 0)
     {
-      addr = SYMBOL_VALUE_ADDRESS (got_sym);
+      addr = BMSYMBOL_VALUE_ADDRESS (got_sym);
       if (solib_dsbt_debug)
        fprintf_unfiltered (gdb_stdlog,
                            "lm_base: get addr %x by _GLOBAL_OFFSET_TABLE_.\n",
@@ -767,7 +759,7 @@ dsbt_in_dynsym_resolve_code (CORE_ADDR pc)
 
   return ((pc >= info->interp_text_sect_low && pc < info->interp_text_sect_high)
          || (pc >= info->interp_plt_sect_low && pc < info->interp_plt_sect_high)
-         || in_plt_section (pc, NULL));
+         || in_plt_section (pc));
 }
 
 /* Print a warning about being unable to set the dynamic linker
@@ -812,9 +804,6 @@ enable_break (void)
 
   info = get_dsbt_info ();
 
-  if (info->enable_break2_done)
-    return 1;
-
   info->interp_text_sect_low = 0;
   info->interp_text_sect_high = 0;
   info->interp_plt_sect_low = 0;
@@ -899,7 +888,6 @@ enable_break (void)
          /* Now (finally!) create the solib breakpoint.  */
          create_solib_event_breakpoint (target_gdbarch (), addr);
 
-         info->enable_break2_done = 1;
          ret = 1;
        }
       else
@@ -1023,7 +1011,6 @@ dsbt_clear_solib (void)
   struct dsbt_info *info = get_dsbt_info ();
 
   info->lm_base_cache = 0;
-  info->enable_break2_done = 0;
   info->main_lm_addr = 0;
   if (info->main_executable_lm_info != 0)
     {
This page took 0.02937 seconds and 4 git commands to generate.