This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

Re: [RFC] gdb_bfd_count_sections snafu


>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> HOWEVER, objfile->num_sections is computed with bfd_count_sections
Doug> not gdb_bfd_count_sections.

Thanks for finding this.

Doug> This patch does clean up one thing: AFAICT when syms_from_objfile_1
Doug> is passed NULL for both addrs and offsets, there's no point in
Doug> building local_addr to have more than one entry (zero would be fine
Doug> too I think but space needs to be allocated for at least one entry).

Doug>    if (! addrs && ! offsets)
Doug>      {
Doug> -      local_addr
Doug> -	= alloc_section_addr_info (bfd_count_sections (objfile->obfd));
Doug> +      local_addr = alloc_section_addr_info (1);
Doug>        make_cleanup (xfree, local_addr);
Doug>        addrs = local_addr;
Doug>      }

Yeah, I believe we agreed in the original series that at least 1 was
required.  Otherwise it makes alloc_section_addr_info "weird"; and the
downside of the current approach is just allocating a slightly larger
object in some situations.

Doug> Index: solib-target.c
Doug> ===================================================================
Doug> RCS file: /cvs/src/src/gdb/solib-target.c,v
Doug> retrieving revision 1.28
Doug> diff -u -p -r1.28 solib-target.c
Doug> --- solib-target.c	8 Apr 2013 20:04:42 -0000	1.28
Doug> +++ solib-target.c	17 Apr 2013 07:07:07 -0000
Doug> @@ -339,7 +339,7 @@ solib_target_relocate_section_addresses 
Doug>       it any earlier, since we need to open the file first.  */
Doug>    if (so->lm_info->offsets == NULL)
Doug>      {
Doug> -      int num_sections = bfd_count_sections (so->abfd);
Doug> +      int num_sections = gdb_bfd_count_sections (so->abfd);

I'm not certain that this one is needed.
It seems harmless though.

The rest looks good.

I'm going to be off most of next week but I will try to remember to look
into this again when I return.

Tom


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