exec_bout.h Source File

Back to the index.

exec_bout.h
Go to the documentation of this file.
1 /* Imported into GXmeul 2018-04-21. Some fields renamed and data types changed. */
2 
3 #ifndef EXEC_B_OUT_H
4 #define EXEC_B_OUT_H
5 
6 /*(c****************************************************************************** *
7  * Copyright (c) 1990, 1991, 1992, 1993 Intel Corporation
8  *
9  * Intel hereby grants you permission to copy, modify, and distribute this
10  * software and its documentation. Intel grants this permission provided
11  * that the above copyright notice appears in all copies and that both the
12  * copyright notice and this permission notice appear in supporting
13  * documentation. In addition, Intel grants this permission provided that
14  * you prominently mark as "not part of the original" any modifications
15  * made to this software or documentation, and that the name of Intel
16  * Corporation not be used in advertising or publicity pertaining to
17  * distribution of the software or the documentation without specific,
18  * written prior permission.
19  *
20  * Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
21  * IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
22  * OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
23  * representations regarding the use of, or the results of the use of,
24  * the software and documentation in terms of correctness, accuracy,
25  * reliability, currentness, or otherwise; and you rely on the software,
26  * documentation and results solely at your own risk.
27  *
28  * IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
29  * LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
30  * OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
31  * PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
32  *
33  *****************************************************************************c)*/
34 
35 /*
36  * This file, a modified version of 'a.out.h', describes the 'b.out' format
37  * produced by GNU tools modified to support the i960 processor.
38  *
39  * All i960 development is done in a CROSS-DEVELOPMENT environment. I.e.,
40  * object code is generated on, and executed under the direction of a symbolic
41  * debugger running on, a host system. We do not want to be subject to the
42  * vagaries of which host it is or whether it supports COFF or a.out format,
43  * or anything else. We DO want to:
44  *
45  * o always generate the same format object files, regardless of host.
46  *
47  * o provide support for additional linker features that the normal
48  * a.out.h header can't accommodate.
49  *
50  * As for byte-ordering, the following rules apply:
51  *
52  * o Text and data contents (which are actually downloaded to the target)
53  * is always in i960 (little-endian) order.
54  *
55  * o Other binary numbers in the file (in the header, symbols, relocation
56  * directives) are either all big-endian or all little-endian. It used
57  * to be dependent on the host on which the file was created, but we
58  * are moving toward a tool set that accepts either order on input and
59  * always generates little-endian output.
60  *
61  * o The downloader (comm960 or gdb960) copies a b.out file to a tmp file
62  * and converts it into a stripped little-endian COFF file before
63  * shipping it off to the NINDY monitor in the target systems. If you
64  * use a different downloader and want to send a b.out file to NINDY,
65  * you should perform the conversion explicitly -- see the objcopy
66  * utility.
67  */
68 
69 
70 #define BOUT_BMAGIC 0415
71 /* We don't accept the following (see N_BADMAG macro).
72  * They're just here so GNU code will compile.
73  */
74 #define BOUT_OMAGIC 0407 /* old impure format */
75 #define BOUT_NMAGIC 0410 /* read-only text */
76 #define BOUT_ZMAGIC 0413 /* demand load format */
77 
78 /* FILE HEADER
79  * All 'lengths' are given as a number of bytes.
80  * All 'alignments' are for relinkable files only; an alignment of
81  * 'n' indicates the corresponding segment must begin at an
82  * address that is a multiple of (2**n).
83  */
84 struct bout_exec {
85  /* Standard stuff */
86  uint32_t a_magic; /* Identifies this as a b.out file */
87  uint32_t a_text; /* Length of text */
88  uint32_t a_data; /* Length of data */
89  uint32_t a_bss; /* Length of runtime uninitialized data area */
90  uint32_t a_syms; /* Length of symbol table */
91  uint32_t a_entry; /* Runtime start address */
92  uint32_t a_trsize; /* Length of text relocation info */
93  uint32_t a_drsize; /* Length of data relocation info */
94 
95  /* Added for i960 */
96  uint32_t a_tload; /* Text runtime load address */
97  uint32_t a_dload; /* Data runtime load address */
98  uint8_t a_talign; /* Alignment of text segment */
99  uint8_t a_dalign; /* Alignment of data segment */
100  uint8_t a_balign; /* Alignment of bss segment */
101  uint8_t a_ccinfo; /* See below */
102 };
103 
104 /* The field a_ccinfo contains the magic value N_CCINFO iff cc_info data
105  * (for 2-pass compiler optimization) is appended to the end of the object file.
106  *
107  * Since cc_info data is removed when a file is stripped, we can assume that
108  * its presence implies the presence of a string table in the file, with the
109  * cc_info block immediately following.
110  *
111  * The format/meaning of the cc_data block are known only to the compiler (and,
112  * to a lesser extent, the linker) except for the first 4 bytes, which contain
113  * the length of the block (including those 4 bytes). This length is stored in
114  * a machine-independent format, and can be retrieved with the CI_U32_FM_BUF
115  * macro in cc_info.h .
116  */
117 
118 #define N_MAGIC(x) ((x).a_magic)
119 #define N_BADMAG(x) (((x).a_magic)!=BOUT_BMAGIC)
120 #define N_TXTOFF(x) ( sizeof(struct exec) )
121 #define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
122 #define N_TROFF(x) ( N_DATOFF(x) + (x).a_data )
123 #define N_DROFF(x) ( N_TROFF(x) + (x).a_trsize )
124 #define N_SYMOFF(x) ( N_DROFF(x) + (x).a_drsize )
125 #define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
126 #define N_CCINFO ( 0x17 )
127 #define N_HAS_CCINFO(x) (((x).a_ccinfo)==N_CCINFO)
128 
129 /* A single entry in the symbol table
130  */
131 struct nlist {
132  union {
133  char *n_name;
134  struct nlist *n_next;
135  long n_strx; /* Index into string table */
136  } n_un;
137  unsigned char n_type; /* See below */
138  char n_other; /* Used in i960 support -- see below */
139  short n_desc;
140  unsigned long n_value;
141 };
142 
143 
144 /* Legal values of n_type
145  */
146 #define N_UNDF 0 /* Undefined symbol */
147 #define N_ABS 2 /* Absolute symbol */
148 #define N_TEXT 4 /* Text symbol */
149 #define N_DATA 6 /* Data symbol */
150 #define N_BSS 8 /* BSS symbol */
151 #define N_FN 31 /* Filename symbol */
152 
153 #define N_EXT 1 /* External symbol (OR'd in with one of above) */
154 #define N_TYPE 036 /* Mask for all the type bits */
155 #define N_STAB 0340 /* Mask for all bits used for SDB entries */
156 
157 /* MEANING OF 'n_other'
158  *
159  * If n_other is 0, it means the symbol is an ordinary aout symbol.
160  *
161  * If non-zero, the 'n_other' fields indicates either a leaf procedure or
162  * a system procedure, as follows:
163  *
164  * 1 <= n_other < N_BALNAME :
165  * The symbol is the entry point to a system procedure.
166  * 'n_value' is the address of the entry, as for any other
167  * procedure. The system procedure number (which can be used in
168  * a 'calls' instruction) is (n_other-1). These entries come from
169  * '.sysproc' directives.
170  *
171  * n_other == N_CALLNAME
172  * the symbol is the 'call' entry point to a leaf procedure.
173  * The *next* symbol in the symbol table must be the corresponding
174  * 'bal' entry point to the procedure (see following). These
175  * entries come from '.leafproc' directives in which two different
176  * symbols are specified (the first one is represented here).
177  *
178  *
179  * n_other == N_BALNAME
180  * the symbol is the 'bal' entry point to a leaf procedure.
181  * These entries result from '.leafproc' directives in which only
182  * one symbol is specified, or in which the same symbol is
183  * specified twice.
184  *
185  * Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry,
186  * but not every N_BALNAME entry must have an N_CALLNAME entry.
187  */
188 #define N_ORDINARY ((unsigned) 0)
189 
190 #define N_BALNAME ((unsigned) 0xfe)
191 #define N_CALLNAME ((unsigned) 0xff)
192 
193 #define MASK( V ) ((sizeof(V) == 1) ? 0x000000ff :\
194  ((sizeof(V) == 2) ? 0x0000ffff :\
195  0x0000ffff))
196 
197 /* Get unsigned bits: */
198 #define GET_UBITS( V ) ((unsigned) (V & MASK( V )))
199 
200 #define IS_ORDINARY(x) (GET_UBITS(x) == N_ORDINARY)
201 #define IS_CALLNAME(x) (GET_UBITS(x) == N_CALLNAME)
202 #define IS_BALNAME(x) (GET_UBITS(x) == N_BALNAME)
203 #define IS_SYSPROCIDX(x) (GET_UBITS(x) > N_ORDINARY &&\
204  GET_UBITS(x) < N_BALNAME)
205 
206 /*
207  * Note that the following data structure won't compile using a 16-bit
208  * compiler (MSC7, for example). But is not needed for the target client
209  * (mondb). So just ifdef the structure out of existence...
210  */
211 #ifndef CC_16BIT
213  int r_address; /* File address of item to be relocated */
214  unsigned
215  r_symbolnum:24,/* Index of symbol on which relocation is based,
216  * if r_extern is set. Otherwise set to
217  * either N_TEXT, N_DATA, or N_BSS to
218  * indicate section on which relocation is
219  * based.
220  */
221  r_pcrel:1, /* 1 => relocate PC-relative; else absolute
222  * On i960, pc-relative implies 24-bit
223  * address, absolute implies 32-bit.
224  */
225  r_length:2, /* Number of bytes to relocate:
226  * 0 => 1 byte
227  * 1 => 2 bytes
228  * 2 => 4 bytes -- only value used for i960
229  */
230  r_extern:1,
231  r_bsr:1, /* Something for the GNU NS32K assembler */
232  r_disp:1, /* Something for the GNU NS32K assembler */
233  r_callj:1, /* 1 if relocation target is an i960 'callj' */
234  r_calljx:1; /* 1 if relocation target is an i960 'calljx' */
235 };
236 #endif
237 
238 #endif // EXEC_B_OUT_H
239 
unsigned char n_type
Definition: exec_bout.h:137
short n_desc
Definition: exec_bout.h:139
uint32_t a_text
Definition: exec_bout.h:87
uint32_t a_entry
Definition: exec_bout.h:91
uint32_t a_magic
Definition: exec_bout.h:86
unsigned r_symbolnum
Definition: exec_bout.h:215
uint32_t a_syms
Definition: exec_bout.h:90
uint32_t a_tload
Definition: exec_bout.h:96
char n_other
Definition: exec_bout.h:138
long n_strx
Definition: exec_bout.h:135
uint32_t a_dload
Definition: exec_bout.h:97
char * n_name
Definition: exec_bout.h:133
uint8_t a_talign
Definition: exec_bout.h:98
uint32_t a_bss
Definition: exec_bout.h:89
uint32_t a_trsize
Definition: exec_bout.h:92
uint32_t a_drsize
Definition: exec_bout.h:93
uint8_t a_ccinfo
Definition: exec_bout.h:101
uint32_t a_data
Definition: exec_bout.h:88
struct nlist * n_next
Definition: exec_bout.h:134
union nlist::@15 n_un
unsigned long n_value
Definition: exec_bout.h:140
uint8_t a_balign
Definition: exec_bout.h:100
uint8_t a_dalign
Definition: exec_bout.h:99

Generated on Sun Sep 30 2018 16:05:18 for GXemul by doxygen 1.8.13