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