Implement Ada operator overloading
[deliverable/binutils-gdb.git] / gdb / solib-dsbt.c
index 52fa0e868aacd7746ddd4e3227d3e28d8bb52fc4..4b1b7560e16a7cfb85a1cedf3c4306df32321351 100644 (file)
@@ -1,5 +1,5 @@
 /* Handle TIC6X (DSBT) shared libraries for GDB, the GNU Debugger.
-   Copyright (C) 2010-2020 Free Software Foundation, Inc.
+   Copyright (C) 2010-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -407,7 +407,6 @@ scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr)
   Elf32_External_Dyn *x_dynp_32;
   Elf64_External_Dyn *x_dynp_64;
   struct bfd_section *sect;
-  struct target_section *target_section;
 
   if (abfd == NULL)
     return 0;
@@ -424,14 +423,16 @@ scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr)
   if (sect == NULL)
     return 0;
 
-  for (target_section = current_target_sections->sections;
-       target_section < current_target_sections->sections_end;
-       target_section++)
-    if (sect == target_section->the_bfd_section)
-      break;
-  if (target_section < current_target_sections->sections_end)
-    dyn_addr = target_section->addr;
-  else
+  bool found = false;
+  for (const target_section &target_section
+        : current_program_space->target_sections ())
+    if (sect == target_section.the_bfd_section)
+      {
+       dyn_addr = target_section.addr;
+       found = true;
+       break;
+      }
+  if (!found)
     {
       /* ABFD may come from OBJFILE acting only as a symbol file without being
         loaded into the target (see add_symbol_file_command).  This case is
@@ -552,7 +553,7 @@ lm_base (void)
     return info->lm_base_cache;
 
   got_sym = lookup_minimal_symbol ("_GLOBAL_OFFSET_TABLE_", NULL,
-                                  symfile_objfile);
+                                  current_program_space->symfile_object_file);
 
   if (got_sym.minsym != 0)
     {
@@ -562,7 +563,7 @@ lm_base (void)
                            "lm_base: get addr %x by _GLOBAL_OFFSET_TABLE_.\n",
                            (unsigned int) addr);
     }
-  else if (scan_dyntag (DT_PLTGOT, exec_bfd, &addr))
+  else if (scan_dyntag (DT_PLTGOT, current_program_space->exec_bfd (), &addr))
     {
       struct int_elf32_dsbt_loadmap *ldm;
 
@@ -681,8 +682,6 @@ dsbt_current_sos (void)
         this in the list of shared objects.  */
       if (dsbt_index != 0)
        {
-         int errcode;
-         gdb::unique_xmalloc_ptr<char> name_buf;
          struct int_elf32_dsbt_loadmap *loadmap;
          struct so_list *sop;
          CORE_ADDR addr;
@@ -703,12 +702,11 @@ dsbt_current_sos (void)
          addr = extract_unsigned_integer (lm_buf.l_name,
                                           sizeof (lm_buf.l_name),
                                           byte_order);
-         target_read_string (addr, &name_buf, SO_NAME_MAX_PATH_SIZE - 1,
-                             &errcode);
+         gdb::unique_xmalloc_ptr<char> name_buf
+           = target_read_string (addr, SO_NAME_MAX_PATH_SIZE - 1);
 
-         if (errcode != 0)
-           warning (_("Can't read pathname for link map entry: %s."),
-                    safe_strerror (errcode));
+         if (name_buf == nullptr)
+           warning (_("Can't read pathname for link map entry."));
          else
            {
              if (solib_dsbt_debug)
@@ -781,10 +779,10 @@ enable_break (void)
   asection *interp_sect;
   struct dsbt_info *info;
 
-  if (exec_bfd == NULL)
+  if (current_program_space->exec_bfd () == NULL)
     return 0;
 
-  if (!target_has_execution)
+  if (!target_has_execution ())
     return 0;
 
   info = get_dsbt_info ();
@@ -796,7 +794,8 @@ enable_break (void)
 
   /* Find the .interp section; if not found, warn the user and drop
      into the old breakpoint at symbol code.  */
-  interp_sect = bfd_get_section_by_name (exec_bfd, ".interp");
+  interp_sect = bfd_get_section_by_name (current_program_space->exec_bfd (),
+                                        ".interp");
   if (interp_sect)
     {
       unsigned int interp_sect_size;
@@ -809,8 +808,8 @@ enable_break (void)
         the contents specify the dynamic linker this program uses.  */
       interp_sect_size = bfd_section_size (interp_sect);
       buf = (char *) alloca (interp_sect_size);
-      bfd_get_section_contents (exec_bfd, interp_sect,
-                               buf, 0, interp_sect_size);
+      bfd_get_section_contents (current_program_space->exec_bfd (),
+                               interp_sect, buf, 0, interp_sect_size);
 
       /* Now we need to figure out where the dynamic linker was
         loaded so that we can load its symbols and place a breakpoint
@@ -911,21 +910,22 @@ dsbt_relocate_main_executable (void)
   info->main_executable_lm_info = new lm_info_dsbt;
   info->main_executable_lm_info->map = ldm;
 
-  section_offsets new_offsets (symfile_objfile->section_offsets.size ());
+  objfile *objf = current_program_space->symfile_object_file;
+  section_offsets new_offsets (objf->section_offsets.size ());
   changed = 0;
 
-  ALL_OBJFILE_OSECTIONS (symfile_objfile, osect)
+  ALL_OBJFILE_OSECTIONS (objf, osect)
     {
       CORE_ADDR orig_addr, addr, offset;
       int osect_idx;
       int seg;
 
-      osect_idx = osect - symfile_objfile->sections;
+      osect_idx = osect - objf->sections;
 
       /* Current address of section.  */
       addr = obj_section_addr (osect);
       /* Offset from where this section started.  */
-      offset = symfile_objfile->section_offsets[osect_idx];
+      offset = objf->section_offsets[osect_idx];
       /* Original address prior to any past relocations.  */
       orig_addr = addr - offset;
 
@@ -945,10 +945,10 @@ dsbt_relocate_main_executable (void)
     }
 
   if (changed)
-    objfile_relocate (symfile_objfile, new_offsets);
+    objfile_relocate (objf, new_offsets);
 
-  /* Now that symfile_objfile has been relocated, we can compute the
-     GOT value and stash it away.  */
+  /* Now that OBJF has been relocated, we can compute the GOT value
+     and stash it away.  */
 }
 
 /* When gdb starts up the inferior, it nurses it along (through the
@@ -1022,8 +1022,9 @@ show_dsbt_debug (struct ui_file *file, int from_tty,
 
 struct target_so_ops dsbt_so_ops;
 
+void _initialize_dsbt_solib ();
 void
-_initialize_dsbt_solib (void)
+_initialize_dsbt_solib ()
 {
   dsbt_so_ops.relocate_section_addresses = dsbt_relocate_section_addresses;
   dsbt_so_ops.free_so = dsbt_free_so;
This page took 0.026781 seconds and 4 git commands to generate.