OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [coff-solib.c] - Diff between revs 105 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 105 Rev 1765
/* Handle COFF SVR3 shared libraries for GDB, the GNU Debugger.
/* Handle COFF SVR3 shared libraries for GDB, the GNU Debugger.
   Copyright 1993 Free Software Foundation, Inc.
   Copyright 1993 Free Software Foundation, Inc.
 
 
   This file is part of GDB.
   This file is part of GDB.
 
 
   This program is free software; you can redistribute it and/or modify
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   (at your option) any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */
   Boston, MA 02111-1307, USA.  */
 
 
 
 
#include "defs.h"
#include "defs.h"
 
 
#include "frame.h"
#include "frame.h"
#include "bfd.h"
#include "bfd.h"
#include "gdbcore.h"
#include "gdbcore.h"
#include "symtab.h"
#include "symtab.h"
 
 
/*
/*
 
 
   GLOBAL FUNCTION
   GLOBAL FUNCTION
 
 
   coff_solib_add -- add a shared library files to the symtab list.  We
   coff_solib_add -- add a shared library files to the symtab list.  We
   examine the `.lib' section of the exec file and determine the names of
   examine the `.lib' section of the exec file and determine the names of
   the shared libraries.
   the shared libraries.
 
 
   This function is responsible for discovering those names and
   This function is responsible for discovering those names and
   addresses, and saving sufficient information about them to allow
   addresses, and saving sufficient information about them to allow
   their symbols to be read at a later time.
   their symbols to be read at a later time.
 
 
   SYNOPSIS
   SYNOPSIS
 
 
   void coff_solib_add (char *arg_string, int from_tty,
   void coff_solib_add (char *arg_string, int from_tty,
   struct target_ops *target)
   struct target_ops *target)
 
 
   DESCRIPTION
   DESCRIPTION
 
 
 */
 */
 
 
void
void
coff_solib_add (arg_string, from_tty, target)
coff_solib_add (arg_string, from_tty, target)
     char *arg_string;
     char *arg_string;
     int from_tty;
     int from_tty;
     struct target_ops *target;
     struct target_ops *target;
{
{
  asection *libsect;
  asection *libsect;
 
 
  libsect = bfd_get_section_by_name (exec_bfd, ".lib");
  libsect = bfd_get_section_by_name (exec_bfd, ".lib");
 
 
  if (libsect)
  if (libsect)
    {
    {
      int libsize;
      int libsize;
      unsigned char *lib;
      unsigned char *lib;
      struct libent
      struct libent
        {
        {
          bfd_byte len[4];
          bfd_byte len[4];
          bfd_byte nameoffset[4];
          bfd_byte nameoffset[4];
        };
        };
 
 
      libsize = bfd_section_size (exec_bfd, libsect);
      libsize = bfd_section_size (exec_bfd, libsect);
 
 
      lib = (unsigned char *) alloca (libsize);
      lib = (unsigned char *) alloca (libsize);
 
 
      bfd_get_section_contents (exec_bfd, libsect, lib, 0, libsize);
      bfd_get_section_contents (exec_bfd, libsect, lib, 0, libsize);
 
 
      while (libsize > 0)
      while (libsize > 0)
        {
        {
          struct libent *ent;
          struct libent *ent;
          struct objfile *objfile;
          struct objfile *objfile;
          int len, nameoffset;
          int len, nameoffset;
          char *filename;
          char *filename;
 
 
          ent = (struct libent *) lib;
          ent = (struct libent *) lib;
 
 
          len = bfd_get_32 (exec_bfd, ent->len);
          len = bfd_get_32 (exec_bfd, ent->len);
 
 
          nameoffset = bfd_get_32 (exec_bfd, ent->nameoffset);
          nameoffset = bfd_get_32 (exec_bfd, ent->nameoffset);
 
 
          if (len <= 0)
          if (len <= 0)
            break;
            break;
 
 
          filename = (char *) ent + nameoffset * 4;
          filename = (char *) ent + nameoffset * 4;
 
 
          objfile = symbol_file_add (filename, from_tty,
          objfile = symbol_file_add (filename, from_tty,
                                     NULL,      /* no offsets */
                                     NULL,      /* no offsets */
                                     0,          /* not mainline */
                                     0,          /* not mainline */
                                     OBJF_SHARED);      /* flags */
                                     OBJF_SHARED);      /* flags */
 
 
          libsize -= len * 4;
          libsize -= len * 4;
          lib += len * 4;
          lib += len * 4;
        }
        }
 
 
      /* Getting new symbols may change our opinion about what is
      /* Getting new symbols may change our opinion about what is
         frameless.  */
         frameless.  */
      reinit_frame_cache ();
      reinit_frame_cache ();
    }
    }
}
}
 
 
/*
/*
 
 
   GLOBAL FUNCTION
   GLOBAL FUNCTION
 
 
   coff_solib_create_inferior_hook -- shared library startup support
   coff_solib_create_inferior_hook -- shared library startup support
 
 
   SYNOPSIS
   SYNOPSIS
 
 
   void coff_solib_create_inferior_hook()
   void coff_solib_create_inferior_hook()
 
 
   DESCRIPTION
   DESCRIPTION
 
 
   When gdb starts up the inferior, the kernel maps in the shared
   When gdb starts up the inferior, the kernel maps in the shared
   libraries.  We get here with the target stopped at it's first
   libraries.  We get here with the target stopped at it's first
   instruction, and the libraries already mapped.  At this      point, this
   instruction, and the libraries already mapped.  At this      point, this
   function gets called via expansion of the macro
   function gets called via expansion of the macro
   SOLIB_CREATE_INFERIOR_HOOK.
   SOLIB_CREATE_INFERIOR_HOOK.
 */
 */
 
 
void
void
coff_solib_create_inferior_hook ()
coff_solib_create_inferior_hook ()
{
{
  coff_solib_add ((char *) 0, 0, (struct target_ops *) 0);
  coff_solib_add ((char *) 0, 0, (struct target_ops *) 0);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.