2000-05-04 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
[deliverable/binutils-gdb.git] / gdb / somsolib.c
index 924fa5252c3e0969df90fb0654384be045e5bc64..fa7ecd09c0a8e6230596cc34c0f440c0596f0e0f 100644 (file)
@@ -287,8 +287,12 @@ som_solib_add_solib_objfile (so, name, from_tty, text_addr)
      CORE_ADDR text_addr;
 {
   obj_private_data_t *obj_private;
+  struct section_addr_info section_addrs;
 
-  so->objfile = symbol_file_add (name, from_tty, text_addr, 0, 0, 0, 0, 1);
+  memset (&section_addrs, 0, sizeof (section_addrs));
+  section_addrs.other[0].name = ".text";
+  section_addrs.other[0].addr = text_addr;
+  so->objfile = symbol_file_add (name, from_tty, &section_addrs, 0, OBJF_SHARED);
   so->abfd = so->objfile->obfd;
 
   /* Mark this as a shared library and save private data.
@@ -351,13 +355,13 @@ som_solib_load_symbols (so, name, from_tty, text_addr, target)
     {
       if (p->the_bfd_section->flags & SEC_CODE)
        {
-         p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT);
-         p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT);
+         p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile));
+         p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile));
        }
       else if (p->the_bfd_section->flags & SEC_DATA)
        {
-         p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA);
-         p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA);
+         p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile));
+         p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile));
        }
     }
 
@@ -375,49 +379,11 @@ som_solib_load_symbols (so, name, from_tty, text_addr, target)
   if (status != 0)
     {
       int old, new;
-      int update_coreops;
-      int update_execops;
-
-      /* We must update the to_sections field in the core_ops structure
-         here, otherwise we dereference a potential dangling pointer
-         for each call to target_read/write_memory within this routine.  */
-      update_coreops = core_ops.to_sections == target->to_sections;
-
-      /* Ditto exec_ops (this was a bug).
-       */
-      update_execops = exec_ops.to_sections == target->to_sections;
 
       new = so->sections_end - so->sections;
-      /* Add sections from the shared library to the core target.  */
-      if (target->to_sections)
-       {
-         old = target->to_sections_end - target->to_sections;
-         target->to_sections = (struct section_table *)
-           xrealloc ((char *) target->to_sections,
-                     ((sizeof (struct section_table)) * (old + new)));
-       }
-      else
-       {
-         old = 0;
-         target->to_sections = (struct section_table *)
-           xmalloc ((sizeof (struct section_table)) * new);
-       }
-      target->to_sections_end = (target->to_sections + old + new);
-
-      /* Update the to_sections field in the core_ops structure
-         if needed, ditto exec_ops.  */
-      if (update_coreops)
-       {
-         core_ops.to_sections = target->to_sections;
-         core_ops.to_sections_end = target->to_sections_end;
-       }
-
-      if (update_execops)
-       {
-         exec_ops.to_sections = target->to_sections;
-         exec_ops.to_sections_end = target->to_sections_end;
-       }
-
+      
+      old = target_resize_to_sections (target, new);
+      
       /* Copy over the old data before it gets clobbered.  */
       memcpy ((char *) (target->to_sections + old),
              so->sections,
@@ -1441,11 +1407,11 @@ som_solib_section_offsets (objfile, offsets)
          asection *private_section;
 
          /* The text offset is easy.  */
-         ANOFFSET (offsets, SECT_OFF_TEXT)
+         ANOFFSET (offsets, SECT_OFF_TEXT (objfile))
            = (so_list->som_solib.text_addr
               - so_list->som_solib.text_link_addr);
-         ANOFFSET (offsets, SECT_OFF_RODATA)
-           = ANOFFSET (offsets, SECT_OFF_TEXT);
+         ANOFFSET (offsets, SECT_OFF_RODATA (objfile))
+           = ANOFFSET (offsets, SECT_OFF_TEXT (objfile));
 
          /* We should look at presumed_dp in the SOM header, but
             that's not easily available.  This should be OK though.  */
@@ -1454,14 +1420,14 @@ som_solib_section_offsets (objfile, offsets)
          if (!private_section)
            {
              warning ("Unable to find $PRIVATE$ in shared library!");
-             ANOFFSET (offsets, SECT_OFF_DATA) = 0;
-             ANOFFSET (offsets, SECT_OFF_BSS) = 0;
+             ANOFFSET (offsets, SECT_OFF_DATA (objfile)) = 0;
+             ANOFFSET (offsets, SECT_OFF_BSS (objfile)) = 0;
              return 1;
            }
-         ANOFFSET (offsets, SECT_OFF_DATA)
+         ANOFFSET (offsets, SECT_OFF_DATA (objfile))
            = (so_list->som_solib.data_start - private_section->vma);
-         ANOFFSET (offsets, SECT_OFF_BSS)
-           = ANOFFSET (offsets, SECT_OFF_DATA);
+         ANOFFSET (offsets, SECT_OFF_BSS (objfile))
+           = ANOFFSET (offsets, SECT_OFF_DATA (objfile));
          return 1;
        }
       so_list = so_list->next;
@@ -1480,7 +1446,7 @@ som_sharedlibrary_info_command (ignore, from_tty)
 
   if (exec_bfd == NULL)
     {
-      printf_unfiltered ("no exec file.\n");
+      printf_unfiltered ("No executable file.\n");
       return;
     }
 
This page took 0.068299 seconds and 4 git commands to generate.