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