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