133965Sjdp Preliminary Notes on Porting BFD 233965Sjdp -------------------------------- 333965Sjdp 433965SjdpThe 'host' is the system a tool runs *on*. 533965SjdpThe 'target' is the system a tool runs *for*, i.e. 633965Sjdpa tool can read/write the binaries of the target. 733965Sjdp 833965SjdpPorting to a new host 933965Sjdp--------------------- 1033965SjdpPick a name for your host. Call that <host>. 1133965Sjdp(<host> might be sun4, ...) 1233965SjdpCreate a file hosts/<host>.mh. 1333965Sjdp 1433965SjdpPorting to a new target 1533965Sjdp----------------------- 1633965SjdpPick a name for your target. Call that <target>. 1733965SjdpCall the name for your CPU architecture <cpu>. 1833965SjdpYou need to create <target>.c and config/<target>.mt, 1933965Sjdpand add a case for it to a case statements in bfd/configure.host and 2033965Sjdpbfd/config.bfd, which associates each canonical host type with a BFD 2133965Sjdphost type (used as the base of the makefile fragment names), and to the 2233965Sjdptable in bfd/configure.in which associates each target vector with 2333965Sjdpthe .o files it uses. 2433965Sjdp 2533965Sjdpconfig/<target>.mt is a Makefile fragment. 2633965SjdpThe following is usually enough: 2733965SjdpDEFAULT_VECTOR=<target>_vec 2833965SjdpSELECT_ARCHITECTURES=bfd_<cpu>_arch 2933965Sjdp 3033965SjdpSee the list of cpu types in archures.c, or "ls cpu-*.c". 3133965SjdpIf your architecture is new, you need to add it to the tables 3233965Sjdpin bfd/archures.c, opcodes/configure.in, and binutils/objdump.c. 3333965Sjdp 3433965SjdpFor more information about .mt and .mh files, see config/README. 3533965Sjdp 3633965SjdpThe file <target>.c is the hard part. It implements the 3733965Sjdpbfd_target <target>_vec, which includes pointers to 3833965Sjdpfunctions that do the actual <target>-specific methods. 3933965Sjdp 4033965SjdpPorting to a <target> that uses the a.out binary format 4133965Sjdp------------------------------------------------------- 4233965Sjdp 4333965SjdpIn this case, the include file aout-target.h probaby does most 4433965Sjdpof what you need. The program gen-aout generates <target>.c for 4533965Sjdpyou automatically for many a.out systems. Do: 4633965Sjdp make gen-aout 4733965Sjdp ./gen-aout <target> > <target>.c 4833965Sjdp(This only works if you are building on the target ("native"). 4933965SjdpIf you must make a cross-port from scratch, copy the most 5033965Sjdpsimilar existing file that includes aout-target.h, and fix what is wrong.) 5133965Sjdp 5233965SjdpCheck the parameters in <target>.c, and fix anything that is wrong. 5333965Sjdp(Also let us know about it; perhaps we can improve gen-aout.c.) 5433965Sjdp 5533965SjdpTARGET_IS_BIG_ENDIAN_P 5633965Sjdp Should be defined if <target> is big-endian. 5733965Sjdp 5833965SjdpN_HEADER_IN_TEXT(x) 5933965Sjdp See discussion in ../include/aout/aout64.h. 6033965Sjdp 6133965SjdpBYTES_IN_WORD 6233965Sjdp Number of bytes per word. (Usually 4 but can be 8.) 6333965Sjdp 6433965SjdpARCH 6533965Sjdp Number of bits per word. (Usually 32, but can be 64.) 6633965Sjdp 6733965SjdpENTRY_CAN_BE_ZERO 6833965Sjdp Define if the extry point (start address of an 6933965Sjdp executable program) can be 0x0. 7033965Sjdp 7133965SjdpTEXT_START_ADDR 7233965Sjdp The address of the start of the text segemnt in 7333965Sjdp virtual memory. Normally, the same as the entry point. 7433965Sjdp 7533965SjdpTARGET_PAGE_SIZE 7633965Sjdp 7733965SjdpSEGMENT_SIZE 7833965Sjdp Usually, the same as the TARGET_PAGE_SIZE. 7933965Sjdp Alignment needed for the data segment. 8033965Sjdp 8133965SjdpTARGETNAME 8233965Sjdp The name of the target, for run-time lookups. 8333965Sjdp Usually "a.out-<target>" 84