Subject: Splitting bfd/aout-target.h ...
To: <>
From: Andrew Cagney <cagney@highland.com.au>
List: tech-ports
Date: 10/17/1994 11:15:25
[Follow-ups set to gnu.util.bug]

Hello,

The file `bfd/aout-target.h' contains generic code that can be used to
construct aout backends.

This file really consists of three parts:


	proto		Generic routines that can be overridden by
			the specific aout target.

	backend		A vector defining aout-backend specific stuff for
			a target.  It is constructed from
			the generic routines (found in the proto)
			and routines defined by the specific aout
			target.

	vec		The normal bfd target description
			Again constructed from `proto' and
			`backend'.


If building a simple a.out target, all three parts are used.  If
however, a more complex target is being developed (eg bi-endian) then
while the `proto' part is used once, the `backend' and `vec' may be
used multiple times.

As, at present, the aout-target.h file is monolithic, it isn't easy to
construct these more complex backends.  Most targets (see mipsbsd.h)
have reverted to copying the aout-backend.h code instead of
`including' a generic copy of it.

Further to this, splitting the file into three parts should greatly
simplify the maintenance of changes such as modifications to the
aout_backend structure (as was seen in bfd released in 4.13).

To simplify this (at the cost of complicating slightly how an aout
target is constructed) can I suggest that the aout-target.h file be
split three way's, vis:


	bfd/aout-proto.h
	bfd/aout-backend.h
	bfd/aout-vec.h


each part containing just the code relevant to that section.


For instance, to construct a simple a.out target the code would have
the form:


	...
	basic defines like `endianness'
	...
	#include <basic-stuff>
	...
	define things to override `proto' eg `fix_internal_header'
	...
	#include "aout-proto.h"
	#include "aout-backend.h"
	#include "aout-vec.h"


In this case there is no clear advantage, for backward compatibility
it may be useful to also retain the file `aout-target.h'.

However,when things get more complex for instance in a bi-endian
target:


	#include "aout-proto.h"
	...
	define stuff to override parts of `backend'
	...
	#include "aout-backend.h"
	...
	#define `big-endian-stuff'
	#include "aout-vec.h"
	...
	#define `little-endian-stuff'
	#include "aout-vec.h"


Comments?  If your interested in the details, I have some working
examples.


				Andrew