This is the mail archive of the gdb-patches@sources.redhat.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]

[PATCH] som_solib_add_solib_objfile


This is an hpux-specific patch.

About a year ago, gdb moved from fixed section names (text, data, bss)
to arbitary section names.  At that time, syms_from_objfile changed
its interface from "one address to relocate every section" to "table of
specific section offsets".  The hpux shared library reader was changed
to use the new interface, but did so in a broken way.

This patch changes som_solib_add_solib_objfile to do section relocation
properly.  This fixes the ability of gdb to call shared library functions
in the inferior, including the implicit "malloc" calls that gdb uses
when calling any function with string parameters.

Testing: I've tested this patch extensively with hpux 10.20 on a different
branch of gdb.  I've never tested it on hpux 11.00.  I haven't tested
it with FSF CVS gdb; the last time I built FSF CVS gdb, it could not
run inferior programs at all.

Because of the lack of testing, I'm submitting this patch to the hpux
maintainer, rather than asking for approval to commit it myself (but
I'll do that if that's what he wants).

Michael

===

2001-02-12  Michael Chastain  <chastain@redhat.com>

	* gdb/somsolib.c (som_solib_add_solib_objfile): Do not use
	section relocation feature of syms_from_objfile.  Do my own
	section relocation, offsetting each section of the som by
	either text_addr - text_link_addr or data_start.

===

Index: gdb/somsolib.c
===================================================================
RCS file: /cvs/src/src/gdb/somsolib.c,v
retrieving revision 1.7
diff -c -3 -p -r1.7 somsolib.c
*** gdb/somsolib.c	2000/12/15 01:01:49	1.7
--- gdb/somsolib.c	2001/02/15 04:50:43
***************
*** 1,5 ****
  /* Handle HP SOM shared libraries for GDB, the GNU Debugger.
!    Copyright 1993, 1996, 1999 Free Software Foundation, Inc.
  
     This file is part of GDB.
  
--- 1,5 ----
  /* Handle HP SOM shared libraries for GDB, the GNU Debugger.
!    Copyright 1993, 1996, 1999, 2001 Free Software Foundation, Inc.
  
     This file is part of GDB.
  
*************** som_solib_add_solib_objfile (struct so_l
*** 283,296 ****
  			     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.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.
     */
    so->objfile->flags |= OBJF_SHARED;
--- 283,312 ----
  			     CORE_ADDR text_addr)
  {
    obj_private_data_t *obj_private;
!   struct obj_section *s;
  
!   so->objfile = symbol_file_add (name, from_tty, NULL, 0, OBJF_SHARED);
    so->abfd = so->objfile->obfd;
  
+   /* syms_from_objfile has bizarre section offset code,
+      so I do my own right here.  */
+   for (s = so->objfile->sections; s < so->objfile->sections_end; s++)
+     {
+       flagword aflag = bfd_get_section_flags(so->abfd, s->the_bfd_section);
+       if (aflag & SEC_CODE)
+ 	{
+ 	  s->addr    += so->som_solib.text_addr - so->som_solib.text_link_addr;
+ 	  s->endaddr += so->som_solib.text_addr - so->som_solib.text_link_addr;
+ 	}
+       else if (aflag & SEC_DATA)
+ 	{
+ 	  s->addr    += so->som_solib.data_start;
+ 	  s->endaddr += so->som_solib.data_start;
+ 	}
+       else
+ 	;
+     }
+    
    /* Mark this as a shared library and save private data.
     */
    so->objfile->flags |= OBJF_SHARED;


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