This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: macro usage in bfd
Alan Modra <amodra@bigpond.net.au> writes:
> On Tue, May 25, 2004 at 10:15:52PM -0400, Ian Lance Taylor wrote:
> > "H. J. Lu" <hjl@lucon.org> writes:
> > > How about changing sec->name to bfd_get_section_name (bfd, sec)?
> > I think that would be a good idea.
> con (specific):
> o More typing.
> o Not more readable. Longer lines, resulting in more line wraps.
> o No extra info conveyed by using the macro. In some cases similar
> bfd macros convey *less* info, eg. bfd_get_section_alignment, which
> I recently replaced with sec->alignment_power in merge.c. The latter
> hints that it is a power of 2 value, not a byte alignment.
> o The bfd param is unused, and in some places unavailable. People
> write sec->owner just to satisfy the macro, but sec->owner is NULL in
> some cases. Such code possibly won't work if we ever need to use
> the bfd in the macro.
I agree here. It should probably just take a section argument.
> o Abstraction isn't alway appropriate in library code (as distinct from
> user code). eg. bfd_set_section_vma sets lma too, behind your back.
> Another example is the mess we have with bfd_section_size,
> bfd_get_section_size_before_reloc, bfd_get_section_size_after_reloc.
Reasonable--user code should use bfd_get_section_name, but for BFD
code it doesn't matter much.
Ian