This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

FYI, gdb patch applied


FYI, I just checked in the following patch to give the add-symbol-file
command the ability to handle cases where the text, data, and bss
sections are not contiguous in the address space, and where there are
other sections that need to be explicitly named.

Expect further changes/improvements in this area over the next few
weeks, perhaps with another interface change as well.  I.E. something
other than "-T<section-name> <address>".

-Fred

1999-09-30  Fred Fish  <fnf@cygnus.com>

	* coff-solib.c (coff_solib_add): Adjust call to symbol_file_add.
	* cxux-nat.c (add_shared_symbol_files): Ditto.
	* irix5-nat.c (symbol_add_stub): Ditto.
	* osfsolib.c (symbol_add_stub): Ditto.
	* pa64solib.c (pa64_solib_add_solib_objfile): Ditto.
	* remote-mm.c (mm_load): Ditto.
	* remote-udi.c (udi_load): Ditto.
	* remote-vx.c (vx_add_symbols): Ditto.
	* solib.c (symbol_add_stub): Ditto.
	* somsolib.c (som_solib_add_solib_objfile): Ditto.
	* win32-nat.c (handle_load_dll): Ditto.

	* irix5-nat.c (symbol_add_stub): Add section_addrs, zero it.
	* cxux-nat.c (add_shared_symbol_files): Ditto.
	* osfsolib.c (symbol_add_stub): Ditto.
	* pa64solib.c (pa64_solib_add_solib_objfile): Ditto.
	* solib.c (symbol_add_stub): Ditto.
	* somsolib.c (som_solib_add_solib_objfile): Ditto.
	* symfile.c (symbol_file_command): Ditto.
	* win32-nat.c (handle_load_dll): Ditto.

	* irix5-nat.c (symbol_add_stub): Use section_addrs to pass text addr.
	* cxux-nat.c (add_shared_symbol_files): Ditto.
	* osfsolib.c (symbol_add_stub): Ditto.
	* pa64solib.c (pa64_solib_add_solib_objfile): Ditto.
	* solib.c (symbol_add_stub): Ditto.
	* somsolib.c (som_solib_add_solib_objfile): Ditto.
	* symfile.c (symbol_file_command): Ditto.
	* win32-nat.c (handle_load_dll): Ditto.

	* coff-solib.c (coff_solib_add): Call symbol_file_add with NULL ptr.
	* cxux-nat.c (add_shared_symbol_files): Ditto.
	* remote-udi.c (udi_load): Ditto.
	* remote-vx.c (vx_add_symbols): Ditto.
	* symfile.c (symbol_file_command): Ditto.

	* dstread.c (dst_symfile_offsets): Take "section_addr_info *"
	instead of CORE_ADDR.
	* somread.c (som_symfile_offsets): Ditto.
	* symfile.c (default_symfile_offsets): Ditto.
	* xcoffread.c (xcoff_symfile_offsets): Ditto.

	* symfile.h (default_symfile_offsets): Adjust prototype.
	(syms_from_objfile): Ditto.
	* symtab.h (symbol_file_add): Ditto.

	* rs6000-nat.c (objfile_symbol_add): Call syms_from_objfile with NULL.
	* xcoffsolib.c (solib_add): Ditto.
	* gdb-stabs.h (SECT_OFF_MAX): Increase from 4 to 16.
	* symtab.h (MAX_SECTIONS): Define.
	(struct section_addr_info): New struct for better control over
	changing load addresses of sections.
	* objfiles.h (OBJF_READNOW): Add new flag bit.
	* symfile.h (sym_offsets): Change second param from CORE_ADDR to
	"section_addr_info *".

	* symfile.c (symbol_file_add): Replace scalar arg "CORE_ADDR addr"
	with "struct section_addr_info *addrs".
	(syms_from_objfile): Ditto.
	(add_symbol_file_command): Remove local variables "readnow" and
	"mapped".  Replaced with general "flags" variable.
	(symbol_file_command): Ditto.
	(add_symbol_file_command): Add local variables i, sec_num, argcnt,
	expecting_option, option_index, and opt. Rework option parsing code
	to handle additional options.
	(_initialize_symfile): Adjust add-symbol-file usage to match new
	option handling.
	(symbol_file_add): Remove parameters "mapped" and "readnow",
	replace with general "flags".
	(symbol_file_add): In call to allocate_objfile, replace "mapped"
	with extracted OBJF_MAPPED bit from flags.
	(symbol_file_add): Use OBJF_READNOW bit from flags, instead of
	"readnow" variable.
	(symbol_file_command): Set OBJF_MAPPED and OBJF_READNOW bits
	from parsed options.  Pass flags to symbol_file_add.
	(add_symbol_file_command): Ditto.
	(syms_from_objfile): Add local variables i, sect, lower_sect,
	lower_offset, and local_addr.  Substitute local_addr for addrs
	when addrs is NULL.  Find lowest loadable section to be used as
	starting point for contiguous sections.  Adjust offsets if segments
	are not contiguous.  Call sym_offsets with section_addr_info
	instead of single addr.
	(default_symfile_offsets): Initialize objfile's section_offsets
	with user specified offsets.
	(symbol_file_add): Call syms_from_objfile with offsets.
	(unknown_option_complaint): Add.
	(add_symbol_file_command): Add "section_addrs", zero it with memset.


Index: coff-solib.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/coff-solib.c,v
retrieving revision 2.8
diff -c -p -r2.8 coff-solib.c
*** coff-solib.c	1999/07/07 23:51:03	2.8
--- coff-solib.c	1999/09/30 21:23:20
*************** coff_solib_add (arg_string, from_tty, ta
*** 92,101 ****
  	  filename = (char *) ent + nameoffset * 4;
  
  	  objfile = symbol_file_add (filename, from_tty,
! 				     0,		/* addr */
  				     0,		/* not mainline */
! 				     0,		/* not mapped */
! 				     0,		/* Not readnow */
  				     0,		/* Not user loaded */
  				     1);	/* Is a solib */
  
--- 92,100 ----
  	  filename = (char *) ent + nameoffset * 4;
  
  	  objfile = symbol_file_add (filename, from_tty,
! 				     NULL,	/* no offsets */
  				     0,		/* not mainline */
! 				     0,		/* flags */
  				     0,		/* Not user loaded */
  				     1);	/* Is a solib */
  
Index: cxux-nat.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/cxux-nat.c,v
retrieving revision 2.9
diff -c -p -r2.9 cxux-nat.c
*** cxux-nat.c	1999/07/07 23:51:04	2.9
--- cxux-nat.c	1999/09/30 21:23:20
*************** add_shared_symbol_files ()
*** 368,374 ****
        return;
      }
  
!   objfile = symbol_file_add (LIBC_FILE, 0, 0, 0, 0, 1, 0, 0);
    minsym = lookup_minimal_symbol (LINKS_MAP_POINTER, objfile);
  
    ld_map = (struct link_map *)
--- 368,374 ----
        return;
      }
  
!   objfile = symbol_file_add (LIBC_FILE, 0, NULL, 0, OBJF_READNOW, 0, 0);
    minsym = lookup_minimal_symbol (LINKS_MAP_POINTER, objfile);
  
    ld_map = (struct link_map *)
*************** add_shared_symbol_files ()
*** 384,390 ****
  	  if (target_read_string ((CORE_ADDR) lms.l_name, &path_name,
  				  PATH_MAX, &local_errno))
  	    {
! 	      symbol_file_add (path_name, 1, lms.l_addr, 0, 0, 0, 0, 0);
  	      free (path_name);
  	    }
  	}
--- 384,393 ----
  	  if (target_read_string ((CORE_ADDR) lms.l_name, &path_name,
  				  PATH_MAX, &local_errno))
  	    {
! 	      struct section_addr_info section_addrs;
! 	      memset (&section_addrs, 0, sizeof (section_addrs));
! 	      section_addrs.text_addr = lms.l_addr;
! 	      symbol_file_add (path_name, 1, &section_addrs, 0, 0, 0, 0);
  	      free (path_name);
  	    }
  	}
Index: dstread.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/dstread.c,v
retrieving revision 2.17
diff -c -p -r2.17 dstread.c
*** dstread.c	1999/09/01 00:16:01	2.17
--- dstread.c	1999/09/30 21:23:23
*************** struct section_offsets dst_symfile_faker
*** 1641,1647 ****
  void
  dst_symfile_offsets (objfile, addr)
       struct objfile *objfile;
!      CORE_ADDR addr;
  {
    objfile->num_sections = 1;
    objfile->section_offsets = &dst_symfile_faker;
--- 1641,1647 ----
  void
  dst_symfile_offsets (objfile, addr)
       struct objfile *objfile;
!      struct section_addr_info *addrs;
  {
    objfile->num_sections = 1;
    objfile->section_offsets = &dst_symfile_faker;
Index: gdb-stabs.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/gdb-stabs.h,v
retrieving revision 2.10
diff -c -p -r2.10 gdb-stabs.h
*** gdb-stabs.h	1999/07/07 23:51:07	2.10
--- gdb-stabs.h	1999/09/30 21:23:24
***************
*** 37,43 ****
  #define	SECT_OFF_DATA	1
  #define	SECT_OFF_BSS	2
  #define	SECT_OFF_RODATA	3
! #define	SECT_OFF_MAX	4	/* Count of possible values */
  
  /* The stab_section_info chain remembers info from the ELF symbol table,
     while psymtabs are being built for the other symbol tables in the 
--- 37,43 ----
  #define	SECT_OFF_DATA	1
  #define	SECT_OFF_BSS	2
  #define	SECT_OFF_RODATA	3
! #define	SECT_OFF_MAX	16	/* Count of possible values */
  
  /* The stab_section_info chain remembers info from the ELF symbol table,
     while psymtabs are being built for the other symbol tables in the 
Index: irix5-nat.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/irix5-nat.c,v
retrieving revision 2.37
diff -c -p -r2.37 irix5-nat.c
*** irix5-nat.c	1999/09/29 20:14:50	2.37
--- irix5-nat.c	1999/09/30 21:23:28
*************** symbol_add_stub (arg)
*** 832,838 ****
--- 832,840 ----
  {
    register struct so_list *so = (struct so_list *) arg;		/* catch_errs bogon */
    CORE_ADDR text_addr = 0;
+   struct section_addr_info section_addrs;
  
+   memset (&section_addrs, 0, sizeof (section_addrs));
    if (so->textsection)
      text_addr = so->textsection->addr;
    else if (so->abfd != NULL)
*************** symbol_add_stub (arg)
*** 850,858 ****
  	text_addr = bfd_section_vma (so->abfd, lowest_sect) + LM_OFFSET (so);
      }
  
    so->objfile = symbol_file_add (so->so_name, so->from_tty,
! 				 text_addr,
! 				 0, 0, 0, 0, 0);
    return (1);
  }
  
--- 852,861 ----
  	text_addr = bfd_section_vma (so->abfd, lowest_sect) + LM_OFFSET (so);
      }
  
+   section_addrs.text_addr = text_addr;
    so->objfile = symbol_file_add (so->so_name, so->from_tty,
! 				 &section_addrs,
! 				 0, 0, 0, 0);
    return (1);
  }
  
Index: objfiles.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/objfiles.h,v
retrieving revision 2.40
diff -c -p -r2.40 objfiles.h
*** objfiles.h	1999/08/13 21:00:43	2.40
--- objfiles.h	1999/09/30 21:23:30
*************** struct objfile
*** 435,440 ****
--- 435,444 ----
  
  #define OBJF_SHARED     (1 << 3)	/* From a shared library */
  
+ /* User requested that this objfile be read in it's entirety. */
+ 
+ #define OBJF_READNOW	(1 << 4)	/* Immediate full read */
+ 
  /* The object file that the main symbol table was loaded from (e.g. the
     argument to the "symbol-file" or "file" command).  */
  
Index: osfsolib.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/osfsolib.c,v
retrieving revision 2.30
diff -c -p -r2.30 osfsolib.c
*** osfsolib.c	1999/09/23 22:46:58	2.30
--- osfsolib.c	1999/09/30 21:23:33
*************** symbol_add_stub (arg)
*** 578,584 ****
--- 578,586 ----
  {
    register struct so_list *so = (struct so_list *) arg;		/* catch_errs bogon */
    CORE_ADDR text_addr = 0;
+   struct section_addr_info section_addrs;
  
+   memset (&section_addrs, 0, sizeof (section_addrs));
    if (so->textsection)
      text_addr = so->textsection->addr;
    else if (so->abfd != NULL)
*************** symbol_add_stub (arg)
*** 596,604 ****
  	text_addr = bfd_section_vma (so->abfd, lowest_sect) + LM_OFFSET (so);
      }
  
    so->objfile = symbol_file_add (so->so_name, so->from_tty,
! 				 text_addr,
! 				 0, 0, 0, 0, 1);
    return (1);
  }
  
--- 598,607 ----
  	text_addr = bfd_section_vma (so->abfd, lowest_sect) + LM_OFFSET (so);
      }
  
+   section_addrs.text_addr = text_addr;
    so->objfile = symbol_file_add (so->so_name, so->from_tty,
! 				 &section_addrs,
! 				 0, 0, 0, 1);
    return (1);
  }
  
Index: pa64solib.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/pa64solib.c,v
retrieving revision 2.8
diff -c -p -r2.8 pa64solib.c
*** pa64solib.c	1999/09/23 22:46:58	2.8
--- pa64solib.c	1999/09/30 21:23:37
*************** pa64_solib_add_solib_objfile (so, name, 
*** 226,232 ****
--- 226,234 ----
    bfd *tmp_bfd;
    asection *sec;
    obj_private_data_t *obj_private;
+   struct section_addr_info section_addrs;
  
+   memset (&section_addrs, 0, sizeof (section_addrs));
    /* We need the BFD so that we can look at its sections.  We open up the
       file temporarily, then close it when we are done.  */
    tmp_bfd = bfd_openr (name, gnutarget);
*************** pa64_solib_add_solib_objfile (so, name, 
*** 270,276 ****
    tmp_bfd = NULL;
  
    /* Now let the generic code load up symbols for this library.  */
!   so->objfile = symbol_file_add (name, from_tty, text_addr, 0, 0, 0, 0, 1);
    so->abfd = so->objfile->obfd;
  
    /* Mark this as a shared library and save private data.  */
--- 272,279 ----
    tmp_bfd = NULL;
  
    /* Now let the generic code load up symbols for this library.  */
!   section_addrs.text_addr = text_addr;
!   so->objfile = symbol_file_add (name, from_tty, &section_addrs, 0, 0, 0, 1);
    so->abfd = so->objfile->obfd;
  
    /* Mark this as a shared library and save private data.  */
Index: remote-udi.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/remote-udi.c,v
retrieving revision 2.75
diff -c -p -r2.75 remote-udi.c
*** remote-udi.c	1999/07/07 23:51:51	2.75
--- remote-udi.c	1999/09/30 21:23:41
*************** udi_load (args, from_tty)
*** 1316,1322 ****
    /* As a convenience, pick up any symbol info that is in the program
       being loaded.  Note that we assume that the program is the``mainline'';
       if this is not always true, then this code will need to be augmented.  */
!   symbol_file_add (strtok (args, " \t"), from_tty, 0, 1, 0, 0, 0, 0);
  
    /* Getting new symbols may change our opinion about what is
       frameless.  */
--- 1316,1322 ----
    /* As a convenience, pick up any symbol info that is in the program
       being loaded.  Note that we assume that the program is the``mainline'';
       if this is not always true, then this code will need to be augmented.  */
!   symbol_file_add (strtok (args, " \t"), from_tty, NULL, 1, 0, 0, 0);
  
    /* Getting new symbols may change our opinion about what is
       frameless.  */
Index: remote-vx.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/remote-vx.c,v
retrieving revision 1.71
diff -c -p -r1.71 remote-vx.c
*** remote-vx.c	1999/09/01 00:16:02	1.71
--- remote-vx.c	1999/09/30 21:23:53
*************** vx_add_symbols (name, from_tty, text_add
*** 701,707 ****
  
    /* It might be nice to suppress the breakpoint_re_set which happens here
       because we are going to do one again after the objfile_relocate.  */
!   objfile = symbol_file_add (name, from_tty, 0, 0, 0, 0, 0, 0);
  
    /* This is a (slightly cheesy) way of superceding the old symbols.  A less
       cheesy way would be to find the objfile with the same name and
--- 701,707 ----
  
    /* It might be nice to suppress the breakpoint_re_set which happens here
       because we are going to do one again after the objfile_relocate.  */
!   objfile = symbol_file_add (name, from_tty, NULL, 0, 0, 0, 0);
  
    /* This is a (slightly cheesy) way of superceding the old symbols.  A less
       cheesy way would be to find the objfile with the same name and
Index: rs6000-nat.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/rs6000-nat.c,v
retrieving revision 2.39
diff -c -p -r2.39 rs6000-nat.c
*** rs6000-nat.c	1999/09/29 20:14:51	2.39
--- rs6000-nat.c	1999/09/30 21:23:55
*************** objfile_symbol_add (arg)
*** 365,371 ****
  {
    struct objfile *obj = (struct objfile *) arg;
  
!   syms_from_objfile (obj, 0, 0, 0);
    new_symfile_objfile (obj, 0, 0);
    return 1;
  }
--- 365,371 ----
  {
    struct objfile *obj = (struct objfile *) arg;
  
!   syms_from_objfile (obj, NULL, 0, 0);
    new_symfile_objfile (obj, 0, 0);
    return 1;
  }
Index: solib.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/solib.c,v
retrieving revision 1.130
diff -c -p -r1.130 solib.c
*** solib.c	1999/09/23 22:46:58	1.130
--- solib.c	1999/09/30 21:24:39
*************** symbol_add_stub (arg)
*** 1083,1089 ****
--- 1083,1091 ----
  {
    register struct so_list *so = (struct so_list *) arg;		/* catch_errs bogon */
    CORE_ADDR text_addr = 0;
+   struct section_addr_info section_addrs;
  
+   memset (&section_addrs, 0, sizeof (section_addrs));
    if (so->textsection)
      text_addr = so->textsection->addr;
    else if (so->abfd != NULL)
*************** symbol_add_stub (arg)
*** 1107,1116 ****
      if (strcmp (so->objfile->name, so->so_name) == 0)
        return 1;
    }
    so->objfile =
      symbol_file_add (so->so_name, so->from_tty,
! 		     text_addr,
! 		     0, 0, 0, 0, 1);
    return (1);
  }
  
--- 1109,1119 ----
      if (strcmp (so->objfile->name, so->so_name) == 0)
        return 1;
    }
+   section_addrs.text_addr = text_addr;
    so->objfile =
      symbol_file_add (so->so_name, so->from_tty,
! 		     &section_addrs,
! 		     0, 0, 0, 1);
    return (1);
  }
  
Index: somread.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/somread.c,v
retrieving revision 2.28
diff -c -p -r2.28 somread.c
*** somread.c	1999/09/01 00:16:03	2.28
--- somread.c	1999/09/30 21:24:44
*************** som_symtab_read PARAMS ((bfd *, struct o
*** 53,59 ****
  			 struct section_offsets *));
  
  static void
! som_symfile_offsets PARAMS ((struct objfile *, CORE_ADDR));
  
  /* FIXME: These should really be in a common header somewhere */
  
--- 53,59 ----
  			 struct section_offsets *));
  
  static void
! som_symfile_offsets PARAMS ((struct objfile *, struct section_addr_info *));
  
  /* FIXME: These should really be in a common header somewhere */
  
*************** som_symfile_init (objfile)
*** 462,468 ****
  static void
  som_symfile_offsets (objfile, addr)
       struct objfile *objfile;
!      CORE_ADDR addr;
  {
    int i;
  
--- 462,468 ----
  static void
  som_symfile_offsets (objfile, addr)
       struct objfile *objfile;
!      struct section_addr_info *addrs;
  {
    int i;
  
*************** som_symfile_offsets (objfile, addr)
*** 471,481 ****
      obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
  
    /* First see if we're a shared library.  If so, get the section
!      offsets from the library, else get them from addr.  */
    if (!som_solib_section_offsets (objfile, objfile->section_offsets))
      {
        for (i = 0; i < SECT_OFF_MAX; i++)
! 	ANOFFSET (objfile->section_offsets, i) = addr;
      }
  }
  
--- 471,481 ----
      obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
  
    /* First see if we're a shared library.  If so, get the section
!      offsets from the library, else get them from addrs.  */
    if (!som_solib_section_offsets (objfile, objfile->section_offsets))
      {
        for (i = 0; i < SECT_OFF_MAX; i++)
! 	ANOFFSET (objfile->section_offsets, i) = addrs -> text_addr;
      }
  }
  
Index: somsolib.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/somsolib.c,v
retrieving revision 2.33
diff -c -p -r2.33 somsolib.c
*** somsolib.c	1999/09/23 22:46:58	2.33
--- somsolib.c	1999/09/30 21:24:50
*************** som_solib_add_solib_objfile (so, name, f
*** 287,294 ****
       CORE_ADDR text_addr;
  {
    obj_private_data_t *obj_private;
  
!   so->objfile = symbol_file_add (name, from_tty, text_addr, 0, 0, 0, 0, 1);
    so->abfd = so->objfile->obfd;
  
    /* Mark this as a shared library and save private data.
--- 287,297 ----
       CORE_ADDR text_addr;
  {
    obj_private_data_t *obj_private;
+   struct section_addr_info section_addrs;
  
!   memset (&section_addrs, 0, sizeof (section_addrs));
!   section_addrs.text_addr = text_addr;
!   so->objfile = symbol_file_add (name, from_tty, &section_addrs, 0, 0, 0, 1);
    so->abfd = so->objfile->obfd;
  
    /* Mark this as a shared library and save private data.
Index: symfile.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/symfile.c,v
retrieving revision 1.195
diff -c -p -r1.195 symfile.c
*** symfile.c	1999/09/01 00:16:03	1.195
--- symfile.c	1999/09/30 21:25:30
*************** struct complaint empty_symtab_complaint 
*** 80,85 ****
--- 80,90 ----
    "Empty symbol table found for `%s'", 0, 0
  };
  
+ struct complaint unknown_option_complaint =
+ {
+   "Unknown option `%s' ignored", 0, 0
+ };
+ 
  /* External variables and functions referenced. */
  
  extern int info_verbose;
*************** find_lowest_section (abfd, sect, obj)
*** 458,466 ****
     for the objectfile OBJFILE and stuffs ADDR into all of the offsets.  */
  
  void
! default_symfile_offsets (objfile, addr)
       struct objfile *objfile;
!      CORE_ADDR addr;
  {
    int i;
  
--- 463,471 ----
     for the objectfile OBJFILE and stuffs ADDR into all of the offsets.  */
  
  void
! default_symfile_offsets (objfile, addrs)
       struct objfile *objfile;
!      struct section_addr_info *addrs;
  {
    int i;
  
*************** default_symfile_offsets (objfile, addr)
*** 469,476 ****
      obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
    memset (objfile->section_offsets, 0, SIZEOF_SECTION_OFFSETS);
  
!   for (i = 0; i < SECT_OFF_MAX; i++)
!     ANOFFSET (objfile->section_offsets, i) = addr;
  }
  
  
--- 474,507 ----
      obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
    memset (objfile->section_offsets, 0, SIZEOF_SECTION_OFFSETS);
  
!   /* If user explicitly specified values for data and bss, set them here. */
!   
!   if (addrs->text_addr)
!     ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT) = addrs->text_addr;
!   if (addrs->data_addr)
!     ANOFFSET (objfile->section_offsets, SECT_OFF_DATA) = addrs->data_addr;
!   if (addrs->bss_addr)
!     ANOFFSET (objfile->section_offsets, SECT_OFF_BSS)  = addrs->bss_addr;
!     
!   /* Now calculate offsets for other sections. */
!   for (i = 0; i < MAX_SECTIONS && addrs->other[i].name; i++)
!     {
!       struct other_sections *osp ;
! 
!       osp = &addrs->other[i] ;
!       if (addrs->other[i].addr == 0)
!   	continue;
! #if 0
!       if (strcmp (".text", osp->name) == 0)
! 	SECT_OFF_TEXT = osp->sectindex ;
!       else if (strcmp (".data", osp->name) == 0)
! 	SECT_OFF_DATA = osp->sectindex ;
!       else if (strcmp (".bss", osp->name) == 0)
! 	SECT_OFF_BSS =  osp->sectindex ;
! #endif
!       /* Record all sections in offsets */
!       ANOFFSET (objfile->section_offsets, osp->sectindex) = osp->addr;
!     }
  }
  
  
*************** default_symfile_offsets (objfile, addr)
*** 489,504 ****
     the symbol reading (and complaints can be more terse about it).  */
  
  void
! syms_from_objfile (objfile, addr, mainline, verbo)
       struct objfile *objfile;
!      CORE_ADDR addr;
       int mainline;
       int verbo;
  {
    struct section_offsets *section_offsets;
!   asection *lowest_sect;
    struct cleanup *old_chain;
  
    init_entry_point_info (objfile);
    find_sym_fns (objfile);
  
--- 520,549 ----
     the symbol reading (and complaints can be more terse about it).  */
  
  void
! syms_from_objfile (objfile, addrs, mainline, verbo)
       struct objfile *objfile;
!      struct section_addr_info *addrs;
       int mainline;
       int verbo;
  {
    struct section_offsets *section_offsets;
!   asection *lower_sect;
!   asection *sect;
!   CORE_ADDR lower_offset;
!   struct section_addr_info local_addr;
    struct cleanup *old_chain;
+   int i;
  
+   /* If ADDRS is NULL, initialize the local section_addr_info struct and
+      point ADDRS to it.  We now establish the convention that an addr of
+      zero means no load address was specified. */
+ 
+   if (addrs == NULL)
+     {
+       memset (&local_addr, 0, sizeof (local_addr));
+       addrs = &local_addr;
+     }
+ 
    init_entry_point_info (objfile);
    find_sym_fns (objfile);
  
*************** syms_from_objfile (objfile, addr, mainli
*** 536,556 ****
       happens for the PA64 port.  */
    if (mainline)
      {
!       addr = 0;			/* No offset from objfile addresses.  */
      }
    else
      {
!       lowest_sect = bfd_get_section_by_name (objfile->obfd, ".text");
!       if (lowest_sect == NULL)
  	bfd_map_over_sections (objfile->obfd, find_lowest_section,
! 			       (PTR) &lowest_sect);
! 
!       if (lowest_sect == NULL)
  	warning ("no loadable sections found in added symbol-file %s",
  		 objfile->name);
! 
!       if (lowest_sect)
! 	addr -= bfd_section_vma (objfile->obfd, lowest_sect);
      }
  
    /* Initialize symbol reading routines for this objfile, allow complaints to
--- 581,687 ----
       happens for the PA64 port.  */
    if (mainline)
      {
!       /* No offset from objfile addresses.  */
!       addrs -> text_addr = 0;
!       addrs -> data_addr = 0;
!       addrs -> bss_addr = 0;
      }
    else
      {
!       /* Find lowest loadable section to be used as starting point for 
!          continguous sections. FIXME!! won't work without call to find
! 	 .text first, but this assumes text is lowest section. */
!       lower_sect = bfd_get_section_by_name (objfile->obfd, ".text");
!       if (lower_sect == NULL)
  	bfd_map_over_sections (objfile->obfd, find_lowest_section,
! 			       (PTR) &lower_sect);
!       if (lower_sect == NULL)
  	warning ("no loadable sections found in added symbol-file %s",
  		 objfile->name);
!       else if ((bfd_get_section_flags (objfile->obfd, lower_sect) & SEC_CODE)
! 	       == 0)
! 	warning ("Lowest section in %s is %s at %s",
! 		 objfile->name,
! 		 bfd_section_name (objfile->obfd, lower_sect),
! 		 paddr (bfd_section_vma (objfile->obfd, lower_sect)));
!       if (lower_sect != NULL)
!  	lower_offset = bfd_section_vma (objfile->obfd, lower_sect);
!       else
!  	lower_offset = 0;
!  
!        /* Calculate offsets for the loadable sections.
!  	 FIXME! Sections must be in order of increasing loadable section
!  	 so that contiguous sections can use the lower-offset!!!
!  
!           Adjust offsets if the segments are not contiguous.
!           If the section is contiguous, its offset should be set to
!  	 the offset of the highest loadable section lower than it
!  	 (the loadable section directly below it in memory).
!  	 this_offset = lower_offset = lower_addr - lower_orig_addr */
! 
!       /* FIXME: These sections will not need special treatment because ALL
! 	 sections are in the other sections table */
!  
!       if (addrs->text_addr != 0)
!  	{
!  	  sect = bfd_get_section_by_name (objfile->obfd, ".text");
!  	  if (sect)
!  	    {
!  	      addrs->text_addr -= bfd_section_vma (objfile->obfd, sect);
!  	      lower_offset = addrs->text_addr;
!  	    }
!  	}
!       else 
!  	/* ??? who's below me? */
! 	addrs->text_addr = lower_offset;
!  
!       if (addrs->data_addr != 0)
! 	{
! 	  sect = bfd_get_section_by_name (objfile->obfd, ".data");
! 	  if (sect)
!  	    {
! 	      addrs->data_addr -= bfd_section_vma (objfile->obfd, sect);
!  	      lower_offset = addrs->data_addr;
!  	    }
! 	}
!       else
! 	addrs->data_addr = lower_offset;
!  
!       if (addrs->bss_addr != 0)
! 	{
! 	  sect = bfd_get_section_by_name (objfile->obfd, ".bss");
! 	  if (sect)
!  	    {
! 	      addrs->bss_addr -= bfd_section_vma (objfile->obfd, sect);
!  	      lower_offset = addrs->bss_addr;
!  	    }
! 	}
!       else
! 	addrs->bss_addr = lower_offset;
!   
!        /* Now calculate offsets for other sections. */
!       for (i=0 ; i < MAX_SECTIONS && addrs->other[i].name; i++)
! 	{
! 	 
!  	  if (addrs->other[i].addr != 0)
!  	    {
!  	      sect=bfd_get_section_by_name(objfile->obfd, addrs->other[i].name);
!  	      if (sect)
!  		{
!  		  addrs->other[i].addr -= bfd_section_vma (objfile->obfd, sect);
!  		  lower_offset = addrs->other[i].addr;
! 		  addrs->other[i].sectindex = sect->index ;
!  		}
!  	      else
! 		{
! 		  warning ("section %s not found in %s", addrs->other[i].name, 
! 			   objfile->name);
! 		  addrs->other[i].addr = 0;
! 		}
!  	    }
!  	  else
!  	    addrs->other[i].addr = lower_offset;
! 	}
      }
  
    /* Initialize symbol reading routines for this objfile, allow complaints to
*************** syms_from_objfile (objfile, addr, mainli
*** 560,566 ****
    (*objfile->sf->sym_init) (objfile);
    clear_complaints (1, verbo);
  
!   (*objfile->sf->sym_offsets) (objfile, addr);
  
  #ifndef IBM6000_TARGET
    /* This is a SVR4/SunOS specific hack, I think.  In any event, it
--- 691,697 ----
    (*objfile->sf->sym_init) (objfile);
    clear_complaints (1, verbo);
  
!   (*objfile->sf->sym_offsets) (objfile, addrs);
  
  #ifndef IBM6000_TARGET
    /* This is a SVR4/SunOS specific hack, I think.  In any event, it
*************** syms_from_objfile (objfile, addr, mainli
*** 581,597 ****
       These should probably all be collapsed into some target
       independent form of shared library support.  FIXME.  */
  
!   if (addr)
      {
        struct obj_section *s;
  
        ALL_OBJFILE_OSECTIONS (objfile, s)
  	{
  	  s->addr -= s->offset;
! 	  s->addr += addr;
  	  s->endaddr -= s->offset;
! 	  s->endaddr += addr;
! 	  s->offset += addr;
  	}
      }
  #endif /* not IBM6000_TARGET */
--- 712,747 ----
       These should probably all be collapsed into some target
       independent form of shared library support.  FIXME.  */
  
!   if (addrs)
      {
        struct obj_section *s;
  
+  	/* Map section offsets in "addr" back to the object's 
+  	   sections by comparing the section names with bfd's 
+  	   section names.  Then adjust the section address by
+  	   the offset. */ /* for gdb/13815 */
+  
        ALL_OBJFILE_OSECTIONS (objfile, s)
  	{
+ 	  CORE_ADDR s_addr = 0;
+ 	  int i;
+ 
+  	  if (strcmp (s->the_bfd_section->name, ".text") == 0)
+  	    s_addr = addrs->text_addr;
+  	  else if (strcmp (s->the_bfd_section->name, ".data") == 0)
+  	    s_addr = addrs->data_addr;
+  	  else if (strcmp (s->the_bfd_section->name, ".bss") == 0)
+  	    s_addr = addrs->bss_addr;
+  	  else 
+  	    for (i = 0; !s_addr && addrs->other[i].name; i++)
+  	      if (strcmp (s->the_bfd_section->name, addrs->other[i].name) == 0)
+  	        s_addr = addrs->other[i].addr; /* end added for gdb/13815 */
+  
  	  s->addr -= s->offset;
! 	  s->addr += s_addr;
  	  s->endaddr -= s->offset;
! 	  s->endaddr += s_addr;
! 	  s->offset += s_addr;
  	}
      }
  #endif /* not IBM6000_TARGET */
*************** new_symfile_objfile (objfile, mainline, 
*** 680,692 ****
     Upon failure, jumps back to command level (never returns). */
  
  struct objfile *
! symbol_file_add (name, from_tty, addr, mainline, mapped, readnow, user_loaded, is_solib)
       char *name;
       int from_tty;
!      CORE_ADDR addr;
       int mainline;
!      int mapped;
!      int readnow;
       int user_loaded;
       int is_solib;
  {
--- 830,841 ----
     Upon failure, jumps back to command level (never returns). */
  
  struct objfile *
! symbol_file_add (name, from_tty, addrs, mainline, flags, user_loaded, is_solib)
       char *name;
       int from_tty;
!      struct section_addr_info *addrs;
       int mainline;
!      int flags;
       int user_loaded;
       int is_solib;
  {
*************** symbol_file_add (name, from_tty, addr, m
*** 705,711 ****
        && !query ("Load new symbol table from \"%s\"? ", name))
      error ("Not confirmed.");
  
!   objfile = allocate_objfile (abfd, mapped, user_loaded, is_solib);
  
    /* If the objfile uses a mapped symbol file, and we have a psymtab for
       it, then skip reading any symbols at this time. */
--- 854,860 ----
        && !query ("Load new symbol table from \"%s\"? ", name))
      error ("Not confirmed.");
  
!   objfile = allocate_objfile (abfd, flags & OBJF_MAPPED, user_loaded, is_solib);
  
    /* If the objfile uses a mapped symbol file, and we have a psymtab for
       it, then skip reading any symbols at this time. */
*************** symbol_file_add (name, from_tty, addr, m
*** 741,747 ****
  	      gdb_flush (gdb_stdout);
  	    }
  	}
!       syms_from_objfile (objfile, addr, mainline, from_tty);
      }
  
    /* We now have at least a partial symbol table.  Check to see if the
--- 890,896 ----
  	      gdb_flush (gdb_stdout);
  	    }
  	}
!       syms_from_objfile (objfile, addrs, mainline, from_tty);
      }
  
    /* We now have at least a partial symbol table.  Check to see if the
*************** symbol_file_add (name, from_tty, addr, m
*** 749,755 ****
       the gdb startup command line or on a per symbol file basis.  Expand
       all partial symbol tables for this objfile if so. */
  
!   if (readnow || readnow_symbol_files)
      {
        if (from_tty || info_verbose)
  	{
--- 898,904 ----
       the gdb startup command line or on a per symbol file basis.  Expand
       all partial symbol tables for this objfile if so. */
  
!   if ((flags & OBJF_READNOW) || readnow_symbol_files)
      {
        if (from_tty || info_verbose)
  	{
*************** symbol_file_command (args, from_tty)
*** 803,810 ****
    char *name = NULL;
    CORE_ADDR text_relocation = 0;	/* text_relocation */
    struct cleanup *cleanups;
!   int mapped = 0;
!   int readnow = 0;
  
    dont_repeat ();
  
--- 952,958 ----
    char *name = NULL;
    CORE_ADDR text_relocation = 0;	/* text_relocation */
    struct cleanup *cleanups;
!   int flags = 0;
  
    dont_repeat ();
  
*************** symbol_file_command (args, from_tty)
*** 845,855 ****
  	{
  	  if (STREQ (*argv, "-mapped"))
  	    {
! 	      mapped = 1;
  	    }
  	  else if (STREQ (*argv, "-readnow"))
  	    {
! 	      readnow = 1;
  	    }
  	  else if (**argv == '-')
  	    {
--- 993,1003 ----
  	{
  	  if (STREQ (*argv, "-mapped"))
  	    {
! 	      flags |= OBJF_MAPPED;
  	    }
  	  else if (STREQ (*argv, "-readnow"))
  	    {
! 	      flags |= OBJF_READNOW;
  	    }
  	  else if (**argv == '-')
  	    {
*************** symbol_file_command (args, from_tty)
*** 875,889 ****
  		return;
  	      else if (text_relocation == (CORE_ADDR) -1)
  		{
! 		  symbol_file_add (name, from_tty, (CORE_ADDR) 0,
! 				   1, mapped, readnow, 1, 0);
  #ifdef HPUXHPPA
  		  RESET_HP_UX_GLOBALS ();
  #endif
  		}
  	      else
! 		symbol_file_add (name, from_tty, (CORE_ADDR) text_relocation,
! 				 0, mapped, readnow, 1, 0);
  
  	      /* Getting new symbols may change our opinion about what is
  	         frameless.  */
--- 1023,1042 ----
  		return;
  	      else if (text_relocation == (CORE_ADDR) -1)
  		{
! 		  symbol_file_add (name, from_tty, NULL,
! 				   1, flags, 1, 0);
  #ifdef HPUXHPPA
  		  RESET_HP_UX_GLOBALS ();
  #endif
  		}
  	      else
! 		{
! 		  struct section_addr_info section_addrs;
! 		  memset (&section_addrs, 0, sizeof (section_addrs));
! 		  section_addrs.text_addr = (CORE_ADDR) text_relocation;
! 		  symbol_file_add (name, from_tty, &section_addrs,
! 				   0, flags, 1, 0);
! 		}
  
  	      /* Getting new symbols may change our opinion about what is
  	         frameless.  */
*************** add_symbol_file_command (args, from_tty)
*** 1233,1241 ****
  {
    char *name = NULL;
    CORE_ADDR text_addr;
    char *arg;
!   int readnow = 0;
!   int mapped = 0;
  
    dont_repeat ();
  
--- 1386,1405 ----
  {
    char *name = NULL;
    CORE_ADDR text_addr;
+   int flags = 0;
    char *arg;
!   int expecting_option = 0;
!   int option_index = 0;
!   int argcnt = 0;
!   int sec_num = 0;
!   int i;
!   struct
!   {
!     enum { OPT_SECTION } type;
!     char *name;
!     char *value;
!   } opt[SECT_OFF_MAX];
!   struct section_addr_info section_addrs;
  
    dont_repeat ();
  
*************** add_symbol_file_command (args, from_tty)
*** 1249,1257 ****
    args = strdup (args);
    make_cleanup (free, args);
  
    /* Pick off any -option args and the file name. */
  
!   while ((*args != '\000') && (name == NULL))
      {
        while (isspace (*args))
  	{
--- 1413,1424 ----
    args = strdup (args);
    make_cleanup (free, args);
  
+   /* Ensure section_addrs is initialized */
+   memset (&section_addrs, 0, sizeof (section_addrs));
+ 
    /* Pick off any -option args and the file name. */
  
!   while (*args != '\000')
      {
        while (isspace (*args))
  	{
*************** add_symbol_file_command (args, from_tty)
*** 1268,1293 ****
  	}
        if (*arg != '-')
  	{
! 	  name = arg;
  	}
        else if (STREQ (arg, "-mapped"))
  	{
! 	  mapped = 1;
  	}
        else if (STREQ (arg, "-readnow"))
- 	{
- 	  readnow = 1;
- 	}
-       else
  	{
! 	  error ("unknown option `%s'", arg);
  	}
      }
  
-   /* After picking off any options and the file name, args should be
-      left pointing at the remainder of the command line, which should
-      be the address expression to evaluate. */
- 
    if (name == NULL)
      {
        error ("add-symbol-file takes a file name");
--- 1435,1500 ----
  	}
        if (*arg != '-')
  	{
! 	  if (expecting_option)
! 	    {
!  	      opt[option_index++].value = arg;
!  	      expecting_option = 0;
!  	    }
!  	  else
!  	    {
! 	      switch (argcnt)
! 		{
!  		case 0:
!  		  name = arg;
!  		  break;
!  		case 1: 
!  		  opt[option_index].type = OPT_SECTION;
!  		  opt[option_index].name = ".text";
!  		  opt[option_index++].value = arg;
!  		  break;
!  		case 2: 
!  		  opt[option_index].type = OPT_SECTION;
!  		  opt[option_index].name = ".data";
!  		  opt[option_index++].value = arg;
!  		  break;
!  		case 3: 
!  		  opt[option_index].type = OPT_SECTION;
!  		  opt[option_index].name = ".bss";
!  		  opt[option_index++].value = arg;
!  		  break;
!  		default:
!  		  warning ("Too many arguments entered; see \"help add-symbol-file\" for command syntax.");
! 		}
! 	      argcnt++;
!  	    }
  	}
        else if (STREQ (arg, "-mapped"))
  	{
! 	  flags |= OBJF_MAPPED;
  	}
        else if (STREQ (arg, "-readnow"))
  	{
! 	  flags |= OBJF_READNOW;
  	}
+       else if (STREQN (arg, "-T", 2))
+  	{
+  	  if (option_index >= SECT_OFF_MAX)
+ 	    {
+ 	      warning ("Number of options exceeds maximum allowed.");
+ 	    }
+  	  else
+  	    {
+  	      expecting_option = 1;
+  	      opt[option_index].type = OPT_SECTION;
+  	      opt[option_index].name = arg + 2;
+  	    }
+  	}
+       else 
+         {
+ 	  error ("Unknown option `%s'", arg);
+         }
      }
  
    if (name == NULL)
      {
        error ("add-symbol-file takes a file name");
*************** add_symbol_file_command (args, from_tty)
*** 1295,1318 ****
    name = tilde_expand (name);
    make_cleanup (free, name);
  
!   if (*args != '\000')
      {
!       text_addr = parse_and_eval_address (args);
      }
    else
      {
!       target_link (name, &text_addr);
        if (text_addr == (CORE_ADDR) -1)
! 	error ("Don't know how to get text start location for this file");
      }
! 
!   /* FIXME-32x64: Assumes text_addr fits in a long.  */
!   if ((from_tty)
!       && (!query ("add symbol table from file \"%s\" at text_addr = %s?\n",
! 		  name, local_hex_string ((unsigned long) text_addr))))
      error ("Not confirmed.");
  
!   symbol_file_add (name, from_tty, text_addr, 0, mapped, readnow,
  		   1,		/* user_loaded */
  		   0);		/* We'll guess it's ! is_solib */
  
--- 1502,1578 ----
    name = tilde_expand (name);
    make_cleanup (free, name);
  
!   if (option_index > 0)
      {
!       /* Print the prompt for the query below.
! 	 We have to split this up into 3 print statements because
! 	 local_hex_string returns a local static string. */
!  
!       printf_filtered ("add symbol table from file \"%s\" at\n", name);
!       for (i = 0; i < option_index; i++)
! 	{
! 	  switch (opt[i].type)
! 	    {
! 	    case OPT_SECTION:
! 	      {
!                 CORE_ADDR addr;
!                 char *val = opt[i].value;
!                 char *sec = opt[i].name;
!  
!                 val = opt[i].value;
!                 if (val[0] == '0' && val[1] == 'x')
!                   addr = strtoul (val+2, NULL, 16);
!                 else
!                   addr = strtoul (val, NULL, 10);
!  
!                 if (strcmp (sec, ".text") == 0)
!                   section_addrs.text_addr = addr;
!                 else if (strcmp (sec, ".data") == 0)
!                   section_addrs.data_addr = addr;
!                 else if (strcmp (sec, ".bss") == 0)
!                   section_addrs.bss_addr = addr;
!                 /* Add the section to the others even if it is a
!                    text data or bss section. This is redundent but
!                    eventually, none will be given special treatment */
! 		{
! 		  section_addrs.other[sec_num].name = strdup (sec);
! 		  make_cleanup (free, section_addrs.other[sec_num].name);
! 		  section_addrs.other[sec_num++].addr = addr;
! 		  printf_filtered ("\t%s_addr = %s\n",
! 				   sec, 
! 				   local_hex_string ((unsigned long)addr));
! 		}
!  
!                 /* The object's sections are initialized when a 
!                    call is made to build_objfile_section_table (objfile).
!                    This happens in reread_symbols. 
!                    At this point, we don't know what file type this is,
!                    so we can't determine what section names are valid.  */
!               }
!               break;
!             default:
!               complain (&unknown_option_complaint, opt[i].name);
! 	    }
! 	}
!       /* Eventually, these hard coded names will be obsolete */
!       /* All the addresses will be on the others section */
      }
    else
      {
!       CORE_ADDR text_addr;
!       target_link (name, &text_addr);  
        if (text_addr == (CORE_ADDR) -1)
! 	error("Don't know how to get text start location for this file");
!       section_addrs.text_addr = text_addr;
!       section_addrs.data_addr = 0;
!       section_addrs.bss_addr = 0;
!       printf_filtered("add symbol table from file \"%s\" at text_addr = %s?\n",
! 		      name, local_hex_string ((unsigned long)text_addr));
      }
!   if (from_tty && (!query ("", 0, 0)))
      error ("Not confirmed.");
  
!   symbol_file_add (name, from_tty, &section_addrs, 0, flags,
  		   1,		/* user_loaded */
  		   0);		/* We'll guess it's ! is_solib */
  
*************** to execute.", &cmdlist);
*** 2978,2986 ****
    c->completer = filename_completer;
  
    c = add_cmd ("add-symbol-file", class_files, add_symbol_file_command,
! 	       "Usage: add-symbol-file FILE ADDR\n\
  Load the symbols from FILE, assuming FILE has been dynamically loaded.\n\
! ADDR is the starting address of the file's text.",
  	       &cmdlist);
    c->completer = filename_completer;
  
--- 3238,3250 ----
    c->completer = filename_completer;
  
    c = add_cmd ("add-symbol-file", class_files, add_symbol_file_command,
! 	       "Usage: add-symbol-file FILE ADDR [DATA_ADDR [BSS_ADDR]]\n\
! or:    add-symbol-file FILE -T<SECT> <SECT_ADDR> -T<SECT> <SECT_ADDR> ...\n\
  Load the symbols from FILE, assuming FILE has been dynamically loaded.\n\
! ADDR is the starting address of the file's text.\n\
! The optional arguments, DATA_ADDR and BSS_ADDR, should be specified\n\
! if the data and bss segments are not contiguous with the text.\n\
! For complicated cases, SECT is a section name to be loaded at SECT_ADDR.",
  	       &cmdlist);
    c->completer = filename_completer;
  
Index: symfile.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/symfile.h,v
retrieving revision 1.66
diff -c -p -r1.66 symfile.h
*** symfile.h	1999/09/01 00:16:03	1.66
--- symfile.h	1999/09/30 21:25:31
*************** struct sym_fns
*** 99,105 ****
         a string, where NULL means the default, and others are parsed in a file
         dependent way. */
  
!     void (*sym_offsets) PARAMS ((struct objfile *, CORE_ADDR));
  
      /* Finds the next struct sym_fns.  They are allocated and initialized
         in whatever module implements the functions pointed to; an 
--- 99,105 ----
         a string, where NULL means the default, and others are parsed in a file
         dependent way. */
  
!     void (*sym_offsets) PARAMS ((struct objfile *, struct section_addr_info *));
  
      /* Finds the next struct sym_fns.  They are allocated and initialized
         in whatever module implements the functions pointed to; an 
*************** struct sym_fns
*** 113,119 ****
     do anything special.  */
  
  extern void
! default_symfile_offsets PARAMS ((struct objfile * objfile, CORE_ADDR addr));
  
  
  extern void
--- 113,119 ----
     do anything special.  */
  
  extern void
! default_symfile_offsets PARAMS ((struct objfile * objfile, struct section_addr_info *));
  
  
  extern void
*************** extern void
*** 158,164 ****
  init_entry_point_info PARAMS ((struct objfile *));
  
  extern void
! syms_from_objfile PARAMS ((struct objfile *, CORE_ADDR, int, int));
  
  extern void
  new_symfile_objfile PARAMS ((struct objfile *, int, int));
--- 158,164 ----
  init_entry_point_info PARAMS ((struct objfile *));
  
  extern void
! syms_from_objfile PARAMS ((struct objfile *, struct section_addr_info *, int, int));
  
  extern void
  new_symfile_objfile PARAMS ((struct objfile *, int, int));
Index: symtab.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/symtab.h,v
retrieving revision 1.142
diff -c -p -r1.142 symtab.h
*** symtab.h	1999/09/14 22:50:39	1.142
--- symtab.h	1999/09/30 21:25:36
*************** struct section_offsets
*** 826,831 ****
--- 826,851 ----
    (sizeof (struct section_offsets) \
     + sizeof (((struct section_offsets *) 0)->offsets) * (SECT_OFF_MAX-1))
  
+ /* Define an array of addresses to accommodate non-contiguous dynamic
+    loading of modules.  This is for use when entering commands, so we
+    can keep track of the section names until we read the file and
+    can map them to bfd sections. */
+  
+ #define MAX_SECTIONS 12
+ struct section_addr_info 
+ {
+   /* Sections whose names are always known to gdb. */
+   CORE_ADDR text_addr;
+   CORE_ADDR data_addr;
+   CORE_ADDR bss_addr;
+   /* Sections whose names are file format dependant. */
+   struct other_sections
+   {
+     CORE_ADDR addr;
+     char *name;
+     int sectindex;
+   } other[MAX_SECTIONS];
+ };
  
  /* Each source file or header is represented by a struct symtab. 
     These objects are chained through the `next' field.  */
*************** extern void
*** 1399,1405 ****
  clear_solib PARAMS ((void));
  
  extern struct objfile *
!   symbol_file_add PARAMS ((char *, int, CORE_ADDR, int, int, int, int, int));
  
  /* source.c */
  
--- 1419,1425 ----
  clear_solib PARAMS ((void));
  
  extern struct objfile *
!   symbol_file_add PARAMS ((char *, int, struct section_addr_info *, int, int, int, int));
  
  /* source.c */
  
Index: win32-nat.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/win32-nat.c,v
retrieving revision 2.30
diff -c -p -r2.30 win32-nat.c
*** win32-nat.c	1999/09/30 02:05:03	2.30
--- win32-nat.c	1999/09/30 21:25:39
*************** handle_load_dll (PTR dummy)
*** 325,331 ****
--- 325,333 ----
    char *p, *dll_name = NULL;
    struct objfile *objfile;
    MEMORY_BASIC_INFORMATION minfo;
+   struct section_addr_info section_addrs;
  
+   memset (&section_addrs, 0, sizeof (section_addrs));
    dll_buf[0] = dll_buf[sizeof (dll_buf) - 1] = '\0';
  
    /* The following code attempts to find the name of the dll by reading the
*************** handle_load_dll (PTR dummy)
*** 417,423 ****
       FIXME: Is this the real reason that we need the 0x1000 ? */
  
    printf_unfiltered ("%x:%s", event->lpBaseOfDll, dll_name);
!   symbol_file_add (dll_name, 0, (int) event->lpBaseOfDll + 0x1000, 0, 0, 0, 0, 1);
    printf_unfiltered ("\n");
  
    return 1;
--- 419,426 ----
       FIXME: Is this the real reason that we need the 0x1000 ? */
  
    printf_unfiltered ("%x:%s", event->lpBaseOfDll, dll_name);
!   section_addrs.text_addr = (int) event->lpBaseOfDll + 0x1000;
!   symbol_file_add (dll_name, 0, &section_addrs, 0, 0, 0, 1);
    printf_unfiltered ("\n");
  
    return 1;
Index: xcoffread.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/xcoffread.c,v
retrieving revision 2.136
diff -c -p -r2.136 xcoffread.c
*** xcoffread.c	1999/09/01 00:16:03	2.136
--- xcoffread.c	1999/09/30 21:27:09
*************** static void
*** 224,230 ****
  xcoff_symfile_finish PARAMS ((struct objfile *));
  
  static void
!   xcoff_symfile_offsets PARAMS ((struct objfile *, CORE_ADDR));
  
  static void
  find_linenos PARAMS ((bfd *, sec_ptr, PTR));
--- 224,230 ----
  xcoff_symfile_finish PARAMS ((struct objfile *));
  
  static void
!   xcoff_symfile_offsets PARAMS ((struct objfile *, struct section_addr_info *addrs));
  
  static void
  find_linenos PARAMS ((bfd *, sec_ptr, PTR));
*************** xcoff_initial_scan (objfile, mainline)
*** 2761,2767 ****
  static void
  xcoff_symfile_offsets (objfile, addr)
       struct objfile *objfile;
!      CORE_ADDR addr;
  {
    int i;
  
--- 2761,2767 ----
  static void
  xcoff_symfile_offsets (objfile, addr)
       struct objfile *objfile;
!      struct section_addr_info *addrs;
  {
    int i;
  
Index: xcoffsolib.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/xcoffsolib.c,v
retrieving revision 2.11
diff -c -p -r2.11 xcoffsolib.c
*** xcoffsolib.c	1999/09/02 02:57:55	2.11
--- xcoffsolib.c	1999/09/30 21:27:12
*************** solib_add (arg_string, from_tty, target)
*** 114,120 ****
  	      continue;
  	    }
  
! 	  syms_from_objfile (obj, 0, 0, 0);
  	  new_symfile_objfile (obj, 0, 0);
  	  vmap_symtab (vp, 0, 0);
  	  printf_unfiltered ("Done.\n");
--- 114,120 ----
  	      continue;
  	    }
  
! 	  syms_from_objfile (obj, NULL, 0, 0);
  	  new_symfile_objfile (obj, 0, 0);
  	  vmap_symtab (vp, 0, 0);
  	  printf_unfiltered ("Done.\n");
Index: doc/ChangeLog
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/doc/ChangeLog,v
retrieving revision 2.340
diff -c -p -r2.340 ChangeLog
*** ChangeLog	1999/09/15 21:27:38	2.340
--- ChangeLog	1999/09/30 21:27:19
***************
*** 1,3 ****
--- 1,8 ----
+ 1999-09-30  Fred Fish  <fnf@cygnus.com>
+ 
+ 	* gdb.texinfo:  Document additional forms of specifying section
+ 	names and addresses for the add-symbol-file command.
+ 
  1999-09-14  Michael Snyder  <msnyder@cleaver.cygnus.com>
  
  	* gdbint.texinfo: Fix typo, add the word "have".
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/doc/gdb.texinfo,v
retrieving revision 2.227
diff -c -p -r2.227 gdb.texinfo
*** gdb.texinfo	1999/09/08 01:14:40	2.227
--- gdb.texinfo	1999/09/30 21:28:29
*************** the program is running.  To do this, use
*** 7756,7767 ****
  @cindex dynamic linking
  @item add-symbol-file @var{filename} @var{address}
  @itemx add-symbol-file @var{filename} @var{address} @r{[} -readnow @r{]} @r{[} -mapped @r{]}
  The @code{add-symbol-file} command reads additional symbol table information
  from the file @var{filename}.  You would use this command when @var{filename}
  has been dynamically loaded (by some other means) into the program that
  is running.  @var{address} should be the memory address at which the
  file has been loaded; @value{GDBN} cannot figure this out for itself.
! You can specify @var{address} as an expression.
  
  The symbol table of the file @var{filename} is added to the symbol table
  originally read with the @code{symbol-file} command.  You can use the
--- 7756,7773 ----
  @cindex dynamic linking
  @item add-symbol-file @var{filename} @var{address}
  @itemx add-symbol-file @var{filename} @var{address} @r{[} -readnow @r{]} @r{[} -mapped @r{]}
+ @itemx add-symbol-file @var{filename} @var{address} @var{data_address} @var{bss_address}
+ @itemx add-symbol-file @var{filename} @r{-T}@var{section} @var{address}
  The @code{add-symbol-file} command reads additional symbol table information
  from the file @var{filename}.  You would use this command when @var{filename}
  has been dynamically loaded (by some other means) into the program that
  is running.  @var{address} should be the memory address at which the
  file has been loaded; @value{GDBN} cannot figure this out for itself.
! You can specify up to three addresses, in which case they are taken to be
! the addresses of the text, data, and bss segments respectively.
! For complicated cases, you can specify an arbitrary number of @r{-T}@var{section} @var{address}
! pairs, to give an explicit section name and base address for that section.
! You can specify any @var{address} as an expression.
  
  The symbol table of the file @var{filename} is added to the symbol table
  originally read with the @code{symbol-file} command.  You can use the


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]