Update for merge of main BFD and GDB's BFD. Remove "_struct" suffix
[external/binutils.git] / include / bout.h
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).
5  *
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:
11  *
12  *      o always generate the same format object files, regardless of host.
13  *
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).
18  *
19  * As for byte-ordering, the following rules apply:
20  *
21  *      o Text and data that is actually downloaded to the target is always
22  *        in i80960 (little-endian) order.
23  *
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.  <==
31  *
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.
36  */
37
38
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.
42  */
43 #define OMAGIC  0407            /* old impure format */
44 #define NMAGIC  0410            /* read-only text */
45 #define ZMAGIC  0413            /* demand load format */
46
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).
52  */
53 struct exec {
54         /* Standard stuff */
55         unsigned long a_magic;  /* Identifies this as a b.out file      */
56         unsigned long a_text;   /* Length of text                       */
57         unsigned long a_data;   /* Length of data                       */
58         unsigned long a_bss;    /* Length of runtime uninitialized data area */
59         unsigned long a_syms;   /* Length of symbol table               */
60         unsigned long a_entry;  /* Runtime start address                */
61         unsigned long a_trsize; /* Length of text relocation info       */
62         unsigned long a_drsize; /* Length of data relocation info       */
63
64         /* Added for i960 */
65         unsigned long a_tload;  /* Text runtime load address            */
66         unsigned long a_dload;  /* Data runtime load address            */
67         unsigned char a_talign; /* Alignment of text segment            */
68         unsigned char a_dalign; /* Alignment of data segment            */
69         unsigned char a_balign; /* Alignment of bss segment             */
70         unsigned char unused;   /* (Just to make struct size a multiple of 4) */
71 };
72
73 #define N_BADMAG(x)     (((x).a_magic)!=BMAGIC)
74 #define N_TXTOFF(x)     ( sizeof(struct exec) )
75 #define N_DATOFF(x)     ( N_TXTOFF(x) + (x).a_text )
76 #define N_TROFF(x)      ( N_DATOFF(x) + (x).a_data )
77 #define N_DROFF(x)      ( N_TROFF(x) + (x).a_trsize )
78 #define N_SYMOFF(x)     ( N_DROFF(x) + (x).a_drsize )
79 #define N_STROFF(x)     ( N_SYMOFF(x) + (x).a_syms )
80
81 /* A single entry in the symbol table
82  */
83 struct nlist {
84         union {
85                 char    *n_name;
86                 struct nlist *n_next;
87                 long    n_strx;         /* Index into string table      */
88         } n_un;
89         unsigned char n_type;   /* See below                            */
90         char    n_other;        /* Used in i80960 support -- see below  */
91         short   n_desc;
92         unsigned long n_value;
93 };
94
95
96 /* Legal values of n_type
97  */
98 #define N_UNDF  0       /* Undefined symbol     */
99 #define N_ABS   2       /* Absolute symbol      */
100 #define N_TEXT  4       /* Text symbol          */
101 #define N_DATA  6       /* Data symbol          */
102 #define N_BSS   8       /* BSS symbol           */
103 #define N_FN    31      /* Filename symbol      */
104
105 #define N_EXT   1       /* External symbol (OR'd in with one of above)  */
106 #define N_TYPE  036     /* Mask for all the type bits                   */
107 #define N_STAB  0340    /* Mask for all bits used for SDB entries       */
108
109 /* MEANING OF 'n_other'
110  *
111  * If non-zero, the 'n_other' fields indicates either a leaf procedure or
112  * a system procedure, as follows:
113  *
114  *      1 <= n_other <= 32 :
115  *              The symbol is the entry point to a system procedure.
116  *              'n_value' is the address of the entry, as for any other
117  *              procedure.  The system procedure number (which can be used in
118  *              a 'calls' instruction) is (n_other-1).  These entries come from
119  *              '.sysproc' directives.
120  *
121  *      n_other == N_CALLNAME
122  *              the symbol is the 'call' entry point to a leaf procedure.
123  *              The *next* symbol in the symbol table must be the corresponding
124  *              'bal' entry point to the procedure (see following).  These
125  *              entries come from '.leafproc' directives in which two different
126  *              symbols are specified (the first one is represented here).
127  *      
128  *
129  *      n_other == N_BALNAME
130  *              the symbol is the 'bal' entry point to a leaf procedure.
131  *              These entries result from '.leafproc' directives in which only
132  *              one symbol is specified, or in which the same symbol is
133  *              specified twice.
134  *
135  * Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry,
136  * but not every N_BALNAME entry must have an N_CALLNAME entry.
137  */
138 #define N_CALLNAME      (-1)
139 #define N_BALNAME       (-2)
140 #define IS_CALLNAME(x)  (N_CALLNAME == (int)(x))
141 #define IS_BALNAME(x)   (N_BALNAME == (int)(x))
142 #define IS_OTHER(x)     ((x)>0 && (x) <=32)
143
144 struct relocation_info {
145         int      r_address;     /* File address of item to be relocated */
146         unsigned
147                 r_symbolnum:24,/* Index of symbol on which relocation is based,
148                                 *       if r_extern is set.  Otherwise set to
149                                 *       either N_TEXT, N_DATA, or N_BSS to
150                                 *       indicate section on which relocation is
151                                 *       based.
152                                 */
153                 r_pcrel:1,      /* 1 => relocate PC-relative; else absolute
154                                  *      On i960, pc-relative implies 24-bit
155                                  *      address, absolute implies 32-bit.
156                                  */
157                 r_length:2,     /* Number of bytes to relocate:
158                                  *      0 => 1 byte
159                                  *      1 => 2 bytes
160                                  *      2 => 4 bytes -- only value used for i960
161                                  */
162                 r_extern:1,
163                 r_bsr:1,        /* Something for the GNU NS32K assembler */
164                 r_disp:1,       /* Something for the GNU NS32K assembler */
165                 r_callj:1,      /* 1 if relocation target is an i960 'callj' */
166                 nuthin:1;       /* Unused                               */
167 };