This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] gdb_bfd_count_sections snafu
- From: Doug Evans <dje at google dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Fri, 3 May 2013 23:20:59 -0700
- Subject: Re: [RFC] gdb_bfd_count_sections snafu
- References: <yjt2ehe9r31a dot fsf at ruffy2 dot mtv dot corp dot google dot com> <87bo9180ru dot fsf at fleche dot redhat dot com>
On Fri, Apr 26, 2013 at 2:01 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "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
I committed the patch.