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: [RFA] Remove target_section.bfd


On Tue, Jul 16, 2013 at 11:13 AM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Doug" == Doug Evans <dje@google.com> writes:
>
> Doug> While reviewing the remove-symbol-file patchset I came across
> Doug> target_section.bfd.
> Doug> Unnecessarily storing copies of things can lead to confusion and bugs.
> Doug> This patch isn't intended to be a space savings, simply a cleanup.
>
> I think it is a nice cleanup.  Thanks.
>
> Doug> We already liberally reference bfd_section.owner, so I have no problem
> Doug> with adding more references here.
>
> The only danger is that some BFD sections do not have an owner.  For
> example, this is true of the absolute section, which is shared by all
> BFDs, something I found out the hard way.  Now, I think this is wrong of
> BFD to do, but fixing it seemed hard.

Righto.  I've taken those into account (or at least tried to ...).

[There's a FIXME in bfd for this btw.  Don't know if it'll ever get
implemented.]

> Sometimes it is safe to use the section owner nevertheless; for instance
> if you're sure that an ownerless section will never be used in this
> context.
>
> I don't know whether this applies in this case.  Perhaps not because
> build_section_table uses bfd_map_over_sections, and I think that doesn't
> include the ownerless sections.

I looked at this.

bfd_map_over_sections does this:

void
bfd_map_over_sections (bfd *abfd,
                       void (*operation) (bfd *, asection *, void *),
                       void *user_storage)
{
  asection *sect;
  unsigned int i = 0;

  for (sect = abfd->sections; sect != NULL; i++, sect = sect->next)
    (*operation) (abfd, sect, user_storage);

  if (i != abfd->section_count) /* Debugging */
    abort ();
}

That can't work for "global" sections (abs,com,und, etc.).
And that's the only way the sections we care about here get added in
gdb (AFAICT).

> Doug> [Ideally bfd would provide accessor functions/macros for struct
> Doug> bfd_section, but none exist at all, and I'm not inclined to add all of
> Doug> them just for this patch.]
>
> I went through that same thought process.
>
> Doug> Ok to check in?
>
> I think it is fine; but if you could verify about bfd_map_over_sections,
> that would be good.
>
> Tom


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