make target selection fully configurable

This commit is contained in:
David MacKenzie 1993-08-07 22:38:22 +00:00
parent 379dd96582
commit 5f9a2245d8
6 changed files with 270 additions and 114 deletions

View File

@ -1,3 +1,34 @@
Sat Aug 7 09:14:21 1993 David J. Mackenzie (djm@thepub.cygnus.com)
* PORTING, TODO, config/README: Update to reflect below changes.
* configure.in: Replace MINIMIZE and --with-minimal-bfd with
--with-bfd-targets="target1,target2,..." and the special target
"all" to get the previous default behavior.
Figure out which architecture and backend .o files are needed from
DEFAULT_VECTOR, SELECT_VECS, and SELECT_ARCHITECTURES as set in
the .mt files. Define TDEFAULTS based on them, also.
* Makefile.in: Remove references to MINIMIZE.
* archures.c, targets.c: Ditto.
* config/*.mt: Define DEFAULT_VECTOR, SELECT_VECS, and
SELECT_ARCHITECTURES as variables rather than as -D arguments to
TDEFAULTS.
* config/a29k-coff.mt,alphaosf.mt, i386-sco.mt, i960-bout.mt,
i960-coff.mt (TDEFAULTS): Don't put the default vector in
SELECT_VECS manually; it's automatic now.
* config/i386-sco.mt (TDEFAULTS): Don't put &sco_core_vec in
SELECT_VECS manually; -DSCO_CORE does it automatically now.
* config/h8300-coff.mt,h8500-coff.mt,sh-coff.mt,st2000.mt,z8k-coff.mt
(TDEFAULTS): Don't define BFD; not used.
* config/hppaosf.mh (HDEFINES): Don't define SELECT_ARCHITECTURES;
this is a host, not a target.
Sat Aug 7 05:28:03 1993 Fred Fish (fnf@deneb.cygnus.com)
* elfcode.h (elf_object_p): Add comment about what this function
@ -23,7 +54,7 @@ Fri Aug 6 12:00:03 1993 David J. Mackenzie (djm@thepub.cygnus.com)
* config/i386isc.mh (ALLOCA),
* config/go32.mh (EXTRALIBS): Don't define; not used.
* config/solaris2.mh (HDEFINES): Renamed from H_DEFINES.
* config/alphaosf.mt (TDEFINES): alphaosf.mt: Set it, not HDEFINES.
* config/alphaosf.mt (TDEFINES): Set it, not HDEFINES.
* config/z8k-coff.mt (CC): Don't define. It's a target, not a host.
* config/.Sanitize (Things-to-keep): Add README.

View File

@ -107,9 +107,6 @@ OPTIONAL_BACKENDS = trad-core.o sco-core.o aix386-core.o hpux-core.o
# These are defined by configure.in:
# WORDSIZE=32
# BFD_BACKENDS = $(BFD32_BACKENDS)
# Change this (to MINIMIZE=1) to save space in executables.
# Currently, all this does is control the target_vector in targets.c.
# MINIMIZE=0
all:
@ -177,9 +174,8 @@ install-info: force
# Various kinds of .o files to put in libbfd.a:
# BFD_LIBS Generic routines, always needed.
# BFD_BACKENDS Routines the target needs if it is the configured target.
# BFD_MACHINES Architecture-specific routines in cpu-*.o.
# Always set to ALL_MACHINES for now.
# BFD_BACKENDS Routines the configured targets need.
# BFD_MACHINES Architecture-specific routines the configured targets need.
# HDEPFILES Routines the host needs, regardless of target.
# TDEPFILES Routines the target needs, regardless of host.
OFILES = $(BFD_LIBS) $(BFD_BACKENDS) $(BFD_MACHINES) $(HDEPFILES) $(TDEPFILES)
@ -206,10 +202,10 @@ $(TARGETLIB): $(OFILES) ofiles
targets.o: targets.c Makefile
$(CC) -c $(CFLAGS) $(HDEFINES) $(TDEFINES) $(CSEARCH) $(CSWITCHES) -DMINIMIZE=$(MINIMIZE) $(TDEFAULTS) $<
$(CC) -c $(CFLAGS) $(HDEFINES) $(TDEFINES) $(CSEARCH) $(CSWITCHES) $(TDEFAULTS) $<
archures.o: archures.c Makefile
$(CC) -c $(CFLAGS) $(HDEFINES) $(TDEFINES) $(CSEARCH) $(CSWITCHES) -DMINIMIZE=$(MINIMIZE) $(TDEFAULTS) $<
$(CC) -c $(CFLAGS) $(HDEFINES) $(TDEFINES) $(CSEARCH) $(CSWITCHES) $(TDEFAULTS) $<
subdir_do: force
@for i in $(DODIRS); do \

73
bfd/PORTING Normal file
View File

@ -0,0 +1,73 @@
Preliminary Notes on Porting BFD
--------------------------------
The 'host' is the system a tool runs *on*.
The 'target' is the system a tool runs *for*, i.e.
a tool can read/write the binaries of the target.
Porting to a new host
---------------------
Pick a name for your host. Call that <host>.
(<host> might be sun4, ...)
Create a file hosts/h-<host>.
Porting to a new target
-----------------------
Pick a name for your target. Call that <target>.
You need to create <target>.c and config/mt-<target>.
config/mt-<target> is a Makefile fragment.
The following is usually enough:
DEFAULT_VECTOR=<target>_vec
SELECT_ARCHITECTURES=bfd_<cpu>_arch
See the list of cpu types in archures.c, or "ls cpu-*.c".
The file <target>.c is the hard part. It implements the
bfd_target <target>_vec, which includes pointers to
functions that do the actual <target>-specific methods.
Porting to a <target> that uses the a.out binary format
-------------------------------------------------------
In this case, the include file aout-target.h probaby does most
of what you need. The program gen-aout generates <target>.c for
you automatically for many a.out systems. Do:
make gen-aout
./gen-aout <target> > <target>.c
(This only works if you are building on the target ("native").
If you must make a cross-port from scratch, copy the most
similar existing file that includes aout-target.h, and fix what is wrong.)
Check the parameters in <target>.c, and fix anything that is wrong.
(Also let us know about it; perhaps we can improve gen-aout.c.)
TARGET_IS_BIG_ENDIAN_P
Should be defined if <target> is big-endian.
N_HEADER_IN_TEXT(x)
See discussion in ../include/aout/aout32.h.
BYTES_IN_WORD
Number of bytes per word. (Usually 4 but can be 8.)
ARCH
Number of bits per word. (Usually 32, but can be 64.)
ENTRY_CAN_BE_ZERO
Define if the extry point (start address of an
executable program) can be 0x0.
TEXT_START_ADDR
The address of the start of the text segemnt in
virtual memory. Normally, the same as the entry point.
PAGE_SIZE
SEGMENT_SIZE
Usually, the same as the PAGE_SIZE.
Alignment needed for the data segment.
TARGETNAME
The name of the target, for run-time lookups.
Usually "a.out-<target>"

View File

@ -1,41 +1,25 @@
Things that still need to be handled: -*- Text -*-
Things that still need to be done: -*- Text -*-
o - A source of space lossage is that all the target-dependent
code is in a single bfd_target structure. Hence all the code
for *writing* object files is still pulled into all the applications
that only care about *reading* (gdb, nm, objdump), while gas
has to carry along all the unneded baggage for reading objects.
And so one. This would be a much more substantial change,
and the payoff would be less (essentially none if bfd is
used as a shared library).
o - The storage needed by BFD data structures is also larger than strictly
needed. This may be difficult to do much about.
o - change the memory usage to reflect the message which follows the
page break.
o - implement bfd_abort, which should close the bfd but not alter the
filesystem.
o - update the bfd doc; write a how-to-write-a-backend doc.
o - change reloc handling as per Steve's suggestion.
(more details please.....)
Changing the way bfd uses memory. The new convention is simple:
o - bfd will never write into user-supplied memory, nor attempt to
free it.
o - closing a bfd may reclaim all bfd-allocated memory associated
with that bfd.
- - bfd_target_list will be the one exception; you must reclaim the
returned vector yourself.
o - update the bfd doc; write a how-to-write-a-backend doc, take out
the stupid quips and fill in all the blanks.
Interface implications are minor (get_symcount_upper_bound will go
away; bfd_cannicalize_symtab will allocate its own memory, etc).
o - upgrade the reloc handling as per Steve's suggestion.
Certain operations consume a lot of memory; for them manual
reclaimation is available:
o - bfd_canonicalize_symtab will return a pointer to a
null-terminated vector of symbols. Subsequent calls may or may
not return the same pointer.
bfd_canonicalize_relocs will do the same; returning a pointer to
an array of arelocs. Calling this function will read symbols in
too.
o - bfd_reclaim_relocs will free the memory used by these relocs.
the symbols will be untouched.
bfd_reclaim_symtab (ne bfd_reclaim_symbol_table) will free the
memory allocated by canonialize_symtab.
Since relocations point to symbols, any relocations obtained by a
call to bfd_canonicalize_relocs will be reclaimed as well.
o - if you don't call the reclaim_ functions, the memory will be
reclaimed at bfd_close time.

View File

@ -31,6 +31,11 @@ fi
# per-target:
if [ "x$target" = "xall" ]; then
echo "*** 'all' can not be the default target" 1>&2
exit 1
fi
# WHEN ADDING ENTRIES TO THIS MATRIX:
# Make sure that the left side always has two dashes. Otherwise you
# can get spurious matches. Even for unambiguous cases, do this as a
@ -60,6 +65,7 @@ case "${target}" in
i[34]86-*-elf) bfd_target=i386-elf ;;
i[34]86-*-netware*) bfd_target=i386-nlm ;;
i[34]86-*-linux*) bfd_target=i386-linux ;;
i[34]86-*-lynx*) bfd_target=i386-lynx ;;
i[34]86-none-*) bfd_target=i386-coff ;;
i960-*-vxworks) bfd_target=i960-bout ;;
i960-*-aout) bfd_target=i960-bout ;;
@ -89,7 +95,10 @@ case "${target}" in
sparc-*-solaris2*) bfd_target=sparc-elf ;;
sparc-*-sysv4*) bfd_target=sparc-elf ;;
# start-sanitize-v9
sparc64-*-aout*) bfd_target=sparc-aout ; target64=true ;;
# Don't set target64=true for sparc64-*-aout*. Keep it using the 32bit stuff
# so we continue to have something that works (until the 64 bit support is
# rock solid).
sparc64-*-aout*) bfd_target=sparc-aout ;;
sparc64-*-elf*) bfd_target=sparc64-elf ; target64=true ;;
# end-sanitize-v9
sparc*-*-*) bfd_target=sparc-aout ;;
@ -119,17 +128,32 @@ case "${target}" in
*-tandem-*) bfd_target=st2000 ;;
esac
if [ ! -f ${srcdir}/config/${bfd_target}.mt ] ; then
if [ -n "${bfd_target}" ] ; then
echo '***' No file ${srcdir}/config/${bfd_target}.mt 1>&2
fi
echo '***' BFD does not support target ${target} 1>&2
echo '***' Look in bfd/configure.in for supported targets 1>&2
exit 1
fi
target_makefile_frag=config/${bfd_target}.mt
[ -z "$bfd_target" ] && bfd_target="$target" # For error message.
# We don't do any links based on the target system, just very minor makefile
all_targets=false
for targ in $bfd_target `echo $with_bfd_targets | sed 's/,/ /g'`
do
if [ "x$targ" = "xall" ]; then
all_targets=true
else
if [ ! -f ${srcdir}/config/${targ}.mt ] ; then
if [ -n "${targ}" ] ; then
echo '***' No file ${srcdir}/config/${targ}.mt 1>&2
fi
echo '***' BFD does not support target ${targ} 1>&2
echo '***' Look in bfd/configure.in for supported targets 1>&2
exit 1
fi
if [ "x$bfd_target" = "x$targ" ]; then
target_makefile_frag=${srcdir}/config/${targ}.mt
else
target_extra_frags="$target_extra_frags ${srcdir}/config/${targ}.mt"
fi
fi
done
# We don't do any links based on the target system, just minor makefile
# config.
# post-target:
@ -137,16 +161,6 @@ target_makefile_frag=config/${bfd_target}.mt
rm -f Makefile.tmp Makefile.2
mv Makefile Makefile.tmp
case ${with_minimal_bfd} in
yes) echo MINIMIZE=1 > Makefile.2 ;;
no | "") echo MINIMIZE=0 > Makefile.2 ;;
*)
echo "*** bad value \"${with_minimal_bfd}\" for minimal-bfd flag; ignored" 1>&2
with_minimal_bfd=no
echo MINIMIZE=0 > Makefile.2
;;
esac
case ${with_64_bit_bfd} in
yes) want64=true ;;
no | "") want64=false ;;
@ -166,19 +180,108 @@ case ${host64}-${target64}-${want64} in
;;
esac
if [ x${with_minimal_bfd} = xyes ] \
&& grep -s TARGET_BACKENDS ${srcdir}/${target_makefile_frag} ; then
echo 'BFD_BACKENDS = $(TARGET_BACKENDS)' >> Makefile.2
else
echo 'BFD_BACKENDS = $(ALL_BACKENDS)' >> Makefile.2
fi
# The default vector in the primary target.
DEFAULT_VECTOR=`sed -n '
s/DEFAULT_VECTOR[ ]*=[ ]*\([^ ]*\)/\1/p
' $target_makefile_frag`
if [ x${with_minimal_bfd} = xyes ] \
&& grep -s TARGET_CPUS ${srcdir}/${target_makefile_frag} ; then
echo 'BFD_MACHINES = $(TARGET_CPUS)' >> Makefile.2
else
if [ x${all_targets} = xfalse ]; then
allfrags="$target_makefile_frag $target_extra_frags"
# The default and selected vectors in all the configured targets.
SELECT_VECS=`sed -n '
s/DEFAULT_VECTOR[ ]*=[ ]*\([^ ]*\)/\1/p
s/SELECT_VECS[ ]*=[ ]*\([^ ]*\)/\1/p
' $allfrags | sort -u`
# The architectures in all the configured targets.
SELECT_ARCHITECTURES=`sed -n '
s/SELECT_ARCHITECTURES[ ]*=[ ]*//p
' $allfrags | sort -u`
# Target backend .o files.
tb=
for vec in $SELECT_VECS
do
case "$vec" in
a29kcoff_big_vec) tb="$tb coff-a29k.o" ;;
a_out_adobe_vec) tb="$tb aout-adobe.o" ;;
aout_mips_little_vec) tb="$tb mipsbsd.o" ;;
b_out_vec_big_host) tb="$tb bout.o" ;;
b_out_vec_little_host) tb="$tb bout.o" ;;
bfd_elf32_hppa_vec) tb="$tb elf32-hppa.o elf32.o elf.o" ;;
bfd_elf32_i386_vec) tb="$tb elf32-i386.o elf32.o elf.o" ;;
bfd_elf32_i860_vec) tb="$tb elf32-i860.o elf32.o elf.o" ;;
bfd_elf32_m68k_vec) tb="$tb elf32-m68k.o elf32.o elf.o" ;;
bfd_elf32_sparc_vec) tb="$tb elf32-sparc.o elf32.o elf.o" ;;
# start-sanitize-v9
bfd_elf64_sparc_vec) tb="$tb elf64-sparc.o elf64.o elf.o" ;;
# end-sanitize-v9
bfd_nlm32_i386_vec) tb="$tb nlm32-i386.o" ;;
ecoff_big_vec) tb="$tb coff-mips.o" ;;
ecoff_little_vec) tb="$tb coff-mips.o" ;;
ecoffalpha_little_vec) tb="$tb coff-alpha.o" ;;
h8300coff_vec) tb="$tb coff-h8300.o" ;;
h8500coff_vec) tb="$tb coff-h8500.o" ;;
host_aout_vec) tb="$tb host-aout.o" ;;
hp300bsd_vec) tb="$tb hp300bsd.o" ;;
hp300hpux_vec) tb="$tb hp300hpux.o" ;;
hppa_vec) tb="$tb hppa.o" ;;
i386aout_vec) tb="$tb i386aout.o" ;;
i386bsd_vec) tb="$tb i386bsd.o" ;;
i386coff_vec) tb="$tb coff-i386.o" ;;
i386linux_vec) tb="$tb i386linux.o" ;;
i386lynx_vec) tb="$tb i386lynx.o" ;;
icoff_big_vec) tb="$tb coff-i960.o" ;;
icoff_little_vec) tb="$tb coff-i960.o" ;;
ieee_vec) tb="$tb ieee.o" ;;
m68kcoff_vec) tb="$tb coff-m68k.o" ;;
m68kcoffun_vec) tb="$tb coff-u68k.o" ;;
m88kbcs_vec) tb="$tb coff-m88k.o" ;;
newsos3_vec) tb="$tb newsos3.o" ;;
rs6000coff_vec) tb="$tb coff-rs6000.o" ;;
shcoff_vec) tb="$tb coff-sh.o" ;;
srec_vec) tb="$tb srec.o" ;;
sunos_big_vec) tb="$tb sunos.o aout32.o stab-syms.o" ;;
symbolsrec_vec) tb="$tb srec.o" ;;
we32kcoff_vec) tb="$tb coff-we32k.o" ;;
z8kcoff_vec) tb="$tb coff-z8k.o" ;;
"") ;;
*) echo "*** unknown target vector $vec in $f" 1>&2; exit 1 ;;
esac
done
# Target architecture .o files.
ta=`echo $SELECT_ARCHITECTURES | sed -e s/bfd_/cpu-/g -e s/_arch/.o/g`
# Weed out duplicate .o files.
tb=`echo $tb | tr -s ' ' '\012' | sort -u | tr '\012' ' '`
ta=`echo $ta | tr -s ' ' '\012' | sort -u | tr '\012' ' '`
echo "BFD_BACKENDS = $tb" >> Makefile.2
echo "BFD_MACHINES = $ta" >> Makefile.2
# Only set these if they will be nonempty, for the clever echo.
test -n "$SELECT_VECS" &&
selvecs=`echo $SELECT_VECS | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
test -n "SELECT_ARCHITECTURES" &&
selarchs=`echo $SELECT_ARCHITECTURES | sed -e 's/ \(.\)/,\1/g'`
else # all_targets is true
echo 'BFD_BACKENDS = $(ALL_BACKENDS)' >> Makefile.2
echo 'BFD_MACHINES = $(ALL_MACHINES)' >> Makefile.2
fi
fi # all_targets is true
test -n "$DEFAULT_VECTOR" && defvec="$DEFAULT_VECTOR"
echo "TDEFAULTS = \
${defvec+-DDEFAULT_VECTOR=$defvec} \
${selvecs+-DSELECT_VECS='$selvecs'} \
${selarchs+-DSELECT_ARCHITECTURES='$selarchs'}" \
>> Makefile.2
cat Makefile.tmp >> Makefile.2
rm -f Makefile.tmp

View File

@ -318,31 +318,6 @@ in this structure.
*/
/* The default is to define a target_vector containing all the targets.
By setting MINIMIZE=1 on the "make" command line, the user can change this
to a vector containing just DEFAULT_VECTOR and any required
traditional-core-file handler. (This is to save space in the executables.)
The config files can also override the default large vector by giving an
explicit SELECT_VECS macro. */
#if MINIMIZE && defined(DEFAULT_VECTOR) && !defined(SELECT_VECS)
#ifdef TRAD_CORE
#define SELECT_VECS &DEFAULT_VECTOR,&trad_core_vec
#endif
#ifdef SCO_CORE
#define SELECT_VECS &DEFAULT_VECTOR,&sco_core_vec
#endif
#ifdef AIX386_CORE
#define SELECT_VECS &DEFAULT_VECTOR,&aix386_core_vec
#endif
#ifdef HPUX_CORE
#define SELECT_VECS &DEFAULT_VECTOR,&hpux_core_vec
#endif
#ifndef SELECT_VECS
#define SELECT_VECS &DEFAULT_VECTOR
#endif
#endif
/* All known xvecs. They are listed a second time below, since
we can't intermix extern's and initializers. */
extern bfd_target i386lynx_vec;
@ -397,14 +372,7 @@ extern bfd_target we32kcoff_vec;
extern bfd_target shcoff_vec;
extern bfd_target hp300hpux_vec;
extern bfd_target hp300bsd_vec;
#if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD)
extern bfd_target hppa_vec;
#endif
#ifdef DEFAULT_VECTOR
extern bfd_target DEFAULT_VECTOR;
#endif
bfd_target *target_vector[] = {
@ -414,10 +382,6 @@ bfd_target *target_vector[] = {
#else /* not SELECT_VECS */
#ifdef DEFAULT_VECTOR
&DEFAULT_VECTOR,
#endif
&i386coff_vec,
&i386aout_vec,
&i386lynx_vec,
@ -431,7 +395,7 @@ bfd_target *target_vector[] = {
anymore. If you want to test the stuff yourself, go ahead...
steve@cygnus.com
Worse, since there is no magic number for archives, there
can annoying target mis-matches. */
can be annoying target mis-matches. */
&oasys_vec,
#endif
&sunos_big_vec,
@ -443,7 +407,9 @@ bfd_target *target_vector[] = {
&m88kbcs_vec,
&srec_vec,
&symbolsrec_vec,
/* &tekhex_vec,*/
#if 0
&tekhex_vec,
#endif
&icoff_little_vec,
&icoff_big_vec,
&bfd_elf32_sparc_vec,
@ -478,6 +444,10 @@ bfd_target *target_vector[] = {
&hp300bsd_vec,
&we32kcoff_vec,
#endif /* not SELECT_VECS */
/* Add any required traditional-core-file-handler. */
#ifdef TRAD_CORE
&trad_core_vec,
#endif
@ -491,8 +461,7 @@ bfd_target *target_vector[] = {
&hpux_core_vec,
#endif
#endif /* not SELECT_VECS */
NULL, /* end of list marker */
NULL /* end of list marker */
};
/* default_vector[0] contains either the address of the default vector,
@ -502,7 +471,7 @@ bfd_target *default_vector[] = {
#ifdef DEFAULT_VECTOR
&DEFAULT_VECTOR,
#endif
0,
NULL
};