2001-02-20 Kazu Hirata <kazu@hxi.com>
[binutils.git] / include / bout.h
blob8fc28cc3d6d7f2e7f38350b851990c35b68c4932
1 /*
2 * This file is a modified version of 'a.out.h'. It is to be used in all
3 * GNU tools modified to support the i80960 (or tools that operate on
4 * object files created by such tools).
6 * All i80960 development is done in a CROSS-DEVELOPMENT environment. I.e.,
7 * object code is generated on, and executed under the direction of a symbolic
8 * debugger running on, a host system. We do not want to be subject to the
9 * vagaries of which host it is or whether it supports COFF or a.out format,
10 * or anything else. We DO want to:
12 * o always generate the same format object files, regardless of host.
14 * o have an 'a.out' header that we can modify for our own purposes
15 * (the 80960 is typically an embedded processor and may require
16 * enhanced linker support that the normal a.out.h header can't
17 * accommodate).
19 * As for byte-ordering, the following rules apply:
21 * o Text and data that is actually downloaded to the target is always
22 * in i80960 (little-endian) order.
24 * o All other numbers (in the header, symbols, relocation directives)
25 * are in host byte-order: object files CANNOT be lifted from a
26 * little-end host and used on a big-endian (or vice versa) without
27 * modification.
28 * ==> THIS IS NO LONGER TRUE USING BFD. WE CAN GENERATE ANY BYTE ORDER
29 * FOR THE HEADER, AND READ ANY BYTE ORDER. PREFERENCE WOULD BE TO
30 * USE LITTLE-ENDIAN BYTE ORDER THROUGHOUT, REGARDLESS OF HOST. <==
32 * o The downloader ('comm960') takes care to generate a pseudo-header
33 * with correct (i80960) byte-ordering before shipping text and data
34 * off to the NINDY monitor in the target systems. Symbols and
35 * relocation info are never sent to the target.
39 #define BMAGIC 0415
40 /* We don't accept the following (see N_BADMAG macro).
41 * They're just here so GNU code will compile.
43 #define OMAGIC 0407 /* old impure format */
44 #define NMAGIC 0410 /* read-only text */
45 #define ZMAGIC 0413 /* demand load format */
47 /* FILE HEADER
48 * All 'lengths' are given as a number of bytes.
49 * All 'alignments' are for relinkable files only; an alignment of
50 * 'n' indicates the corresponding segment must begin at an
51 * address that is a multiple of (2**n).
53 struct external_exec {
54 /* Standard stuff */
55 unsigned char e_info[4]; /* Identifies this as a b.out file */
56 unsigned char e_text[4]; /* Length of text */
57 unsigned char e_data[4]; /* Length of data */
58 unsigned char e_bss[4]; /* Length of uninitialized data area */
59 unsigned char e_syms[4]; /* Length of symbol table */
60 unsigned char e_entry[4]; /* Runtime start address */
61 unsigned char e_trsize[4]; /* Length of text relocation info */
62 unsigned char e_drsize[4]; /* Length of data relocation info */
64 /* Added for i960 */
65 unsigned char e_tload[4]; /* Text runtime load address */
66 unsigned char e_dload[4]; /* Data runtime load address */
67 unsigned char e_talign[1]; /* Alignment of text segment */
68 unsigned char e_dalign[1]; /* Alignment of data segment */
69 unsigned char e_balign[1]; /* Alignment of bss segment */
70 unsigned char e_relaxable[1]; /* Assembled with enough info to allow linker to relax */
73 #define EXEC_BYTES_SIZE (sizeof (struct external_exec))
75 /* These macros use the a_xxx field names, since they operate on the exec
76 structure after it's been byte-swapped and realigned on the host machine. */
77 #define N_BADMAG(x) (((x).a_info)!=BMAGIC)
78 #define N_TXTOFF(x) EXEC_BYTES_SIZE
79 #define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
80 #define N_TROFF(x) ( N_DATOFF(x) + (x).a_data )
81 #define N_TRELOFF N_TROFF
82 #define N_DROFF(x) ( N_TROFF(x) + (x).a_trsize )
83 #define N_DRELOFF N_DROFF
84 #define N_SYMOFF(x) ( N_DROFF(x) + (x).a_drsize )
85 #define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
86 #define N_DATADDR(x) ( (x).a_dload )
88 /* Address of text segment in memory after it is loaded. */
89 #if !defined (N_TXTADDR)
90 #define N_TXTADDR(x) 0
91 #endif
93 /* A single entry in the symbol table
95 struct nlist {
96 union {
97 char *n_name;
98 struct nlist *n_next;
99 long n_strx; /* Index into string table */
100 } n_un;
101 unsigned char n_type; /* See below */
102 char n_other; /* Used in i80960 support -- see below */
103 short n_desc;
104 unsigned long n_value;
108 /* Legal values of n_type
110 #define N_UNDF 0 /* Undefined symbol */
111 #define N_ABS 2 /* Absolute symbol */
112 #define N_TEXT 4 /* Text symbol */
113 #define N_DATA 6 /* Data symbol */
114 #define N_BSS 8 /* BSS symbol */
115 #define N_FN 31 /* Filename symbol */
117 #define N_EXT 1 /* External symbol (OR'd in with one of above) */
118 #define N_TYPE 036 /* Mask for all the type bits */
119 #define N_STAB 0340 /* Mask for all bits used for SDB entries */
121 /* MEANING OF 'n_other'
123 * If non-zero, the 'n_other' fields indicates either a leaf procedure or
124 * a system procedure, as follows:
126 * 1 <= n_other <= 32 :
127 * The symbol is the entry point to a system procedure.
128 * 'n_value' is the address of the entry, as for any other
129 * procedure. The system procedure number (which can be used in
130 * a 'calls' instruction) is (n_other-1). These entries come from
131 * '.sysproc' directives.
133 * n_other == N_CALLNAME
134 * the symbol is the 'call' entry point to a leaf procedure.
135 * The *next* symbol in the symbol table must be the corresponding
136 * 'bal' entry point to the procedure (see following). These
137 * entries come from '.leafproc' directives in which two different
138 * symbols are specified (the first one is represented here).
141 * n_other == N_BALNAME
142 * the symbol is the 'bal' entry point to a leaf procedure.
143 * These entries result from '.leafproc' directives in which only
144 * one symbol is specified, or in which the same symbol is
145 * specified twice.
147 * Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry,
148 * but not every N_BALNAME entry must have an N_CALLNAME entry.
150 #define N_CALLNAME ((char)-1)
151 #define N_BALNAME ((char)-2)
152 #define IS_CALLNAME(x) (N_CALLNAME == (x))
153 #define IS_BALNAME(x) (N_BALNAME == (x))
154 #define IS_OTHER(x) ((x)>0 && (x) <=32)
156 #define b_out_relocation_info relocation_info
157 struct relocation_info {
158 int r_address; /* File address of item to be relocated */
159 unsigned
160 #define r_index r_symbolnum
161 r_symbolnum:24,/* Index of symbol on which relocation is based,
162 * if r_extern is set. Otherwise set to
163 * either N_TEXT, N_DATA, or N_BSS to
164 * indicate section on which relocation is
165 * based.
167 r_pcrel:1, /* 1 => relocate PC-relative; else absolute
168 * On i960, pc-relative implies 24-bit
169 * address, absolute implies 32-bit.
171 r_length:2, /* Number of bytes to relocate:
172 * 0 => 1 byte
173 * 1 => 2 bytes -- used for 13 bit pcrel
174 * 2 => 4 bytes
176 r_extern:1,
177 r_bsr:1, /* Something for the GNU NS32K assembler */
178 r_disp:1, /* Something for the GNU NS32K assembler */
179 r_callj:1, /* 1 if relocation target is an i960 'callj' */
180 r_relaxable:1; /* 1 if enough info is left to relax
181 the data */