Subject: bfd&aout `fix-header' call-backs ...
To: <>
From: Andrew Cagney <cagney@highland.com.au>
List: tech-ports
Date: 10/17/1994 11:36:54
[Followups to gnu.utils.bug]

Hello,


(Background) For NetBSD executables, the magic number is stored in
`network byte order'.  By doing this, NetBSD is able to reconize
executables for any of its suported platforms regardless of the
endianness of the host.

Unfortunatly, to support this in the bfd libraries, a `hack' has been
pulled (the SWAP_MAGIC macro).  I propose that this macro be replaced
by a more generic aout-backend-data callback that would permit
post/pre processing of aout headers.


  /* Callback for fixing the a.out headers
     Some platforms have special processing requirements on a.out headers
     before/after they are written/read.  See NetBSD for an example */
  void (*fix_internal_header)
    PARAMS((bfd *abfd, struct internal_exec *execp,
	    struct external_exec *raw_bytes));
  void (*fix_external_header)
    PARAMS((bfd *abfd, struct internal_exec *execp,
	    struct external_exec *raw_bytes));


`fix_internal_header' is used when reading in NetBSD binaries while
`fix_external_header' is used when writting then (better names are
welcome :-).


If defined (by default aout-backend.h defines them as NULL), these
routines would adjust the outgoing (incomming) data as it is written
(read) by the bfd code.  They would be called last (first) before bfd
gets to do any thing.


Comments?  If interested in further details, I can make available a
simple working example.


					Andrew