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]

Re: [PATCH RFA] solib.c



This looks good.

I have only one request: the code which scans an array of
section_table entries and fills in a struct section_addr_info is
hardly specific to shared libraries.  Could you turn it into a
function, put it in symfile.c, and just call it from solib.c?  I guess
you'll need a corresponding cleanup function to free the names.

If that works out, go ahead and commit the patch.  If turns out not to
be a good idea, let me know.


> The changes below are motivated by the desire to have correct section
> addresses stored in the obj_section structs (for shared objects) found
> via the object_files list.
> 
> More information regarding this issue may be found at
> 
>     http://sourceware.cygnus.com/ml/gdb/2000-q1/msg00681.html.
> 
> There was also a patch appended to the above message.  I hereby
> withdraw that patch from consideration.
> 
> Note that MAX_SECTIONS has been increased to 30 (from 12).  The reason
> for this is that 12 was much too small.  So how did I arrive at 30?  I
> counted the number of special sections documented in my (now rather
> old) System V ABI book and counted 24.  I added on six more for good
> measure (to accomodate architecture specific sections.)
> 
> 	* solib.c (symbol_add_stub): Make symbol_file_add() aware of
> 	all section addresses, not just .text.
> 	* symtab.h (MAX_SECTIONS): Increase to 30.
> 
> Index: solib.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/solib.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 solib.c
> --- solib.c	2000/03/15 16:55:07	1.3
> +++ solib.c	2000/03/16 19:34:40
> @@ -1182,12 +1182,37 @@ symbol_add_stub (arg)
>  
>    {
>      struct section_addr_info section_addrs;
> +    struct section_table *stp;
> +    struct cleanup *old_chain;
> +    int oidx;
>  
>      memset (&section_addrs, 0, sizeof (section_addrs));
>      section_addrs.text_addr = text_addr;
>  
> +    old_chain = make_cleanup (null_cleanup, 0);
> +
> +    for (stp = so->sections, oidx = 0; stp != so->sections_end; stp++)
> +      {
> +	if (strcmp (stp->the_bfd_section->name, ".data") == 0)
> +	  section_addrs.data_addr = stp->addr;
> +	else if (strcmp (stp->the_bfd_section->name, ".bss") == 0)
> +	  section_addrs.bss_addr = stp->addr;
> +
> +	if (stp->the_bfd_section->flags & (SEC_ALLOC | SEC_LOAD)
> +	         &&  oidx < MAX_SECTIONS)
> +	  {
> +	    section_addrs.other[oidx].addr = stp->addr;
> +	    section_addrs.other[oidx].name = 
> +	      xstrdup (stp->the_bfd_section->name);
> +	    make_cleanup (free, section_addrs.other[oidx].name);
> +	    section_addrs.other[oidx].sectindex = stp->the_bfd_section->index;
> +	    oidx++;
> +	  }
> +      }
> +
>      so->objfile = symbol_file_add (so->so_name, so->from_tty,
>  				   &section_addrs, 0, OBJF_SHARED);
> +    do_cleanups (old_chain);
>    }
>  
>    return (1);
> Index: symtab.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/symtab.h,v
> retrieving revision 1.3
> diff -u -p -r1.3 symtab.h
> --- symtab.h	2000/03/14 19:58:02	1.3
> +++ symtab.h	2000/03/16 19:34:44
> @@ -842,7 +842,7 @@ struct section_offsets
>     can keep track of the section names until we read the file and
>     can map them to bfd sections. */
>   
> -#define MAX_SECTIONS 12
> +#define MAX_SECTIONS 30
>  struct section_addr_info 
>  {
>    /* Sections whose names are always known to gdb. */
> 
> 

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