Re: [RFA] Remove target_section.bfd

Tom Tromey
2013-07-16T18:13:36Z

>>>>> "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.

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.

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