175fd0b74Schristos Preliminary Notes on Porting BFD 275fd0b74Schristos -------------------------------- 375fd0b74Schristos 475fd0b74SchristosThe 'host' is the system a tool runs *on*. 575fd0b74SchristosThe 'target' is the system a tool runs *for*, i.e. 675fd0b74Schristosa tool can read/write the binaries of the target. 775fd0b74Schristos 875fd0b74SchristosPorting to a new host 975fd0b74Schristos--------------------- 1075fd0b74SchristosPick a name for your host. Call that <host>. 1175fd0b74Schristos(<host> might be sun4, ...) 1275fd0b74SchristosCreate a file hosts/<host>.mh. 1375fd0b74Schristos 1475fd0b74SchristosPorting to a new target 1575fd0b74Schristos----------------------- 1675fd0b74SchristosPick a name for your target. Call that <target>. 1775fd0b74SchristosCall the name for your CPU architecture <cpu>. 1875fd0b74SchristosYou need to create <target>.c and config/<target>.mt, 1975fd0b74Schristosand add a case for it to a case statements in bfd/configure.host and 2075fd0b74Schristosbfd/config.bfd, which associates each canonical host type with a BFD 2175fd0b74Schristoshost type (used as the base of the makefile fragment names), and to the 2275fd0b74Schristostable in bfd/configure.ac which associates each target vector with 2375fd0b74Schristosthe .o files it uses. 2475fd0b74Schristos 2575fd0b74Schristosconfig/<target>.mt is a Makefile fragment. 2675fd0b74SchristosThe following is usually enough: 2775fd0b74SchristosDEFAULT_VECTOR=<target>_vec 2875fd0b74SchristosSELECT_ARCHITECTURES=bfd_<cpu>_arch 2975fd0b74Schristos 3075fd0b74SchristosSee the list of cpu types in archures.c, or "ls cpu-*.c". 3175fd0b74SchristosIf your architecture is new, you need to add it to the tables 3275fd0b74Schristosin bfd/archures.c, opcodes/configure.ac, and binutils/objdump.c. 3375fd0b74Schristos 3475fd0b74SchristosFor more information about .mt and .mh files, see config/README. 3575fd0b74Schristos 3675fd0b74SchristosThe file <target>.c is the hard part. It implements the 3775fd0b74Schristosbfd_target <target>_vec, which includes pointers to 3875fd0b74Schristosfunctions that do the actual <target>-specific methods. 3975fd0b74Schristos 4075fd0b74SchristosPorting to a <target> that uses the a.out binary format 4175fd0b74Schristos------------------------------------------------------- 4275fd0b74Schristos 4375fd0b74SchristosIn this case, the include file aout-target.h probaby does most 4475fd0b74Schristosof what you need. The program gen-aout generates <target>.c for 4575fd0b74Schristosyou automatically for many a.out systems. Do: 4675fd0b74Schristos make gen-aout 4775fd0b74Schristos ./gen-aout <target> > <target>.c 4875fd0b74Schristos(This only works if you are building on the target ("native"). 4975fd0b74SchristosIf you must make a cross-port from scratch, copy the most 5075fd0b74Schristossimilar existing file that includes aout-target.h, and fix what is wrong.) 5175fd0b74Schristos 5275fd0b74SchristosCheck the parameters in <target>.c, and fix anything that is wrong. 5375fd0b74Schristos(Also let us know about it; perhaps we can improve gen-aout.c.) 5475fd0b74Schristos 5575fd0b74SchristosTARGET_IS_BIG_ENDIAN_P 5675fd0b74Schristos Should be defined if <target> is big-endian. 5775fd0b74Schristos 5875fd0b74SchristosN_HEADER_IN_TEXT(x) 5975fd0b74Schristos See discussion in ../include/aout/aout64.h. 6075fd0b74Schristos 6175fd0b74SchristosBYTES_IN_WORD 6275fd0b74Schristos Number of bytes per word. (Usually 4 but can be 8.) 6375fd0b74Schristos 6475fd0b74SchristosARCH 6575fd0b74Schristos Number of bits per word. (Usually 32, but can be 64.) 6675fd0b74Schristos 6775fd0b74SchristosENTRY_CAN_BE_ZERO 6875fd0b74Schristos Define if the extry point (start address of an 6975fd0b74Schristos executable program) can be 0x0. 7075fd0b74Schristos 7175fd0b74SchristosTEXT_START_ADDR 7275fd0b74Schristos The address of the start of the text segemnt in 7375fd0b74Schristos virtual memory. Normally, the same as the entry point. 7475fd0b74Schristos 7575fd0b74SchristosTARGET_PAGE_SIZE 7675fd0b74Schristos 7775fd0b74SchristosSEGMENT_SIZE 7875fd0b74Schristos Usually, the same as the TARGET_PAGE_SIZE. 7975fd0b74Schristos Alignment needed for the data segment. 8075fd0b74Schristos 8175fd0b74SchristosTARGETNAME 8275fd0b74Schristos The name of the target, for run-time lookups. 8375fd0b74Schristos Usually "a.out-<target>" 8475fd0b74Schristos 85*e992f068SchristosCopyright (C) 2012-2022 Free Software Foundation, Inc. 8675fd0b74Schristos 8775fd0b74SchristosCopying and distribution of this file, with or without modification, 8875fd0b74Schristosare permitted in any medium without royalty provided the copyright 8975fd0b74Schristosnotice and this notice are preserved. 90