[PATCH] bfd: tweak SET_ARCH_MACH of aout-cris.c

Gunther Nikl gnikl@justmail.de
Thu May 7 19:32:46 GMT 2020


Hans-Peter Nilsson <hp@bitrange.com> wrote:
> On Wed, 6 May 2020, Gunther Nikl wrote:
> > BTW, I didn't realize until recently that aoutx.h can be used
> > outside of aout32.c/aout64.c. However I was surprised to see that
> > aout-cris.c does include aout32.c directly. I guess that was a
> > deliberate decision?
> 
> I honestly can't remember.  Doesn't it match the pattern of
> other aout-*.c files?  ...hm, not many around.  Oh wait: I think
> something was sufficiently different that I couldn't use
> aout32.c, perhaps the reloc format.

Oh, that much I understood. I meant that aout-cris.c does

  #include "aout32.c"

when I expected

  #include "aoutx.h"

Since I was grepping for the header the result list did not include
aout-cris.c.

A last question if you don't mind: there is a comment in set_sizes in
front of line setting the relocation entry size. Since you had to add
a case of bfd_arch_cris to "NAME (aout, machine_type)" adding such a
case to "NAME (aout, set_arch_mach)" to use the generic set_sizes does
not sound that bad. At least for me the machine_type function is also
about target-specific things.

> > Anyway including aoutx.h in my custom backend avoided ugly changes
> > to aoutx.h itself. That was a surprising lesson.
> 
> I think it's actually meant to be used that way, directly or
> via aout32.h/aout64.h.  At least it says so in a comment.

I am not sure that this was the envisioned usage for aoutx.h. I always
thought an a.out backend had to use the exported functions from aoutXX.o
and with the header aout64.c could simply use the same implementation.
However I missed all the fancy #defines in aoutx.h which only make
sense if aoutx.h is used in other files besides aoutXX.c.

Regards,
Gunther


More information about the Binutils mailing list