PORTING 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. Preliminary Notes on Porting BFD
  2. --------------------------------
  3. The 'host' is the system a tool runs *on*.
  4. The 'target' is the system a tool runs *for*, i.e.
  5. a tool can read/write the binaries of the target.
  6. Porting to a new host
  7. ---------------------
  8. Pick a name for your host. Call that <host>.
  9. (<host> might be sun4, ...)
  10. Create a file hosts/<host>.mh.
  11. Porting to a new target
  12. -----------------------
  13. Pick a name for your target. Call that <target>.
  14. Call the name for your CPU architecture <cpu>.
  15. You need to create <target>.c and config/<target>.mt,
  16. and add a case for it to a case statements in bfd/configure.host and
  17. bfd/config.bfd, which associates each canonical host type with a BFD
  18. host type (used as the base of the makefile fragment names), and to the
  19. table in bfd/configure.ac which associates each target vector with
  20. the .o files it uses.
  21. config/<target>.mt is a Makefile fragment.
  22. The following is usually enough:
  23. DEFAULT_VECTOR=<target>_vec
  24. SELECT_ARCHITECTURES=bfd_<cpu>_arch
  25. See the list of cpu types in archures.c, or "ls cpu-*.c".
  26. If your architecture is new, you need to add it to the tables
  27. in bfd/archures.c, opcodes/configure.ac, and binutils/objdump.c.
  28. For more information about .mt and .mh files, see config/README.
  29. The file <target>.c is the hard part. It implements the
  30. bfd_target <target>_vec, which includes pointers to
  31. functions that do the actual <target>-specific methods.
  32. Porting to a <target> that uses the a.out binary format
  33. -------------------------------------------------------
  34. In this case, the include file aout-target.h probaby does most
  35. of what you need. The program gen-aout generates <target>.c for
  36. you automatically for many a.out systems. Do:
  37. make gen-aout
  38. ./gen-aout <target> > <target>.c
  39. (This only works if you are building on the target ("native").
  40. If you must make a cross-port from scratch, copy the most
  41. similar existing file that includes aout-target.h, and fix what is wrong.)
  42. Check the parameters in <target>.c, and fix anything that is wrong.
  43. (Also let us know about it; perhaps we can improve gen-aout.c.)
  44. TARGET_IS_BIG_ENDIAN_P
  45. Should be defined if <target> is big-endian.
  46. N_HEADER_IN_TEXT(x)
  47. See discussion in ../include/aout/aout64.h.
  48. BYTES_IN_WORD
  49. Number of bytes per word. (Usually 4 but can be 8.)
  50. ARCH
  51. Number of bits per word. (Usually 32, but can be 64.)
  52. ENTRY_CAN_BE_ZERO
  53. Define if the extry point (start address of an
  54. executable program) can be 0x0.
  55. TEXT_START_ADDR
  56. The address of the start of the text segemnt in
  57. virtual memory. Normally, the same as the entry point.
  58. TARGET_PAGE_SIZE
  59. SEGMENT_SIZE
  60. Usually, the same as the TARGET_PAGE_SIZE.
  61. Alignment needed for the data segment.
  62. TARGETNAME
  63. The name of the target, for run-time lookups.
  64. Usually "a.out-<target>"
  65. Copyright (C) 2012-2022 Free Software Foundation, Inc.
  66. Copying and distribution of this file, with or without modification,
  67. are permitted in any medium without royalty provided the copyright
  68. notice and this notice are preserved.