1 | /* a_out.h,v 1.5 2004/09/14 22:27:31 bird Exp */
|
---|
2 | /** @file
|
---|
3 | * GNU
|
---|
4 | * @changed For emx by Eberhard Mattes -- Sep 1998
|
---|
5 | */
|
---|
6 |
|
---|
7 | #ifndef __A_OUT_GNU_H__
|
---|
8 | #define __A_OUT_GNU_H__
|
---|
9 | #define __GNU_EXEC_MACROS__
|
---|
10 | #ifndef __STRUCT_EXEC_OVERRIDE__
|
---|
11 | struct exec
|
---|
12 | {
|
---|
13 | unsigned long a_info; /* Use macros N_MAGIC, etc for access */
|
---|
14 | unsigned a_text; /* length of text, in bytes */
|
---|
15 | unsigned a_data; /* length of data, in bytes */
|
---|
16 | unsigned a_bss; /* length of uninitialized data area for file, in bytes */
|
---|
17 | unsigned a_syms; /* length of symbol table data in file, in bytes */
|
---|
18 | unsigned a_entry; /* start address */
|
---|
19 | unsigned a_trsize; /* length of relocation info for text, in bytes */
|
---|
20 | unsigned a_drsize; /* length of relocation info for data, in bytes */
|
---|
21 | };
|
---|
22 | #endif /* __STRUCT_EXEC_OVERRIDE__ */
|
---|
23 | /* these go in the N_MACHTYPE field */
|
---|
24 | enum machine_type {
|
---|
25 | M_OLDSUN2 = 0,
|
---|
26 | M_68010 = 1,
|
---|
27 | M_68020 = 2,
|
---|
28 | M_SPARC = 3,
|
---|
29 | /* skip a bunch so we don't run into any of sun's numbers */
|
---|
30 | M_386 = 100
|
---|
31 | };
|
---|
32 | #define N_MAGIC(exec) ((exec).a_info & 0xffff)
|
---|
33 | #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
|
---|
34 | #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
|
---|
35 | #define N_SET_INFO(exec, magic, type, flags) \
|
---|
36 | ((exec).a_info = ((magic) & 0xffff) \
|
---|
37 | | (((int)(type) & 0xff) << 16) \
|
---|
38 | | (((flags) & 0xff) << 24))
|
---|
39 | #define N_SET_MAGIC(exec, magic) \
|
---|
40 | ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
|
---|
41 | #define N_SET_MACHTYPE(exec, machtype) \
|
---|
42 | ((exec).a_info = \
|
---|
43 | ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
|
---|
44 | #define N_SET_FLAGS(exec, flags) \
|
---|
45 | ((exec).a_info = \
|
---|
46 | ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
|
---|
47 | /* Code indicating object file or impure executable. */
|
---|
48 | #define OMAGIC 0407
|
---|
49 | /* Code indicating pure executable. */
|
---|
50 | #define NMAGIC 0410
|
---|
51 | /* Code indicating demand-paged executable. */
|
---|
52 | #define ZMAGIC 0413
|
---|
53 | #define N_BADMAG(x) \
|
---|
54 | (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
|
---|
55 | && N_MAGIC(x) != ZMAGIC)
|
---|
56 | #define _N_BADMAG(x) \
|
---|
57 | (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
|
---|
58 | && N_MAGIC(x) != ZMAGIC)
|
---|
59 | #define _N_HDROFF(x) (1024 - sizeof (struct exec))
|
---|
60 | #define N_TXTOFF(x) \
|
---|
61 | (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))
|
---|
62 | #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
|
---|
63 | #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
|
---|
64 | #define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
|
---|
65 | #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
|
---|
66 | #define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
|
---|
67 | /* Address of text segment in memory after it is loaded. */
|
---|
68 | #define N_TXTADDR(x) SEGMENT_SIZE /* emx */
|
---|
69 |
|
---|
70 | /* Address of data segment in memory after it is loaded.
|
---|
71 | Note that it is up to you to define SEGMENT_SIZE
|
---|
72 | on machines not listed here. */
|
---|
73 | #ifdef vax
|
---|
74 | #define SEGMENT_SIZE page_size
|
---|
75 | #endif
|
---|
76 | #ifdef is68k
|
---|
77 | #define SEGMENT_SIZE 0x20000
|
---|
78 | #endif
|
---|
79 |
|
---|
80 | #define SEGMENT_SIZE 0x10000 /* emx */
|
---|
81 |
|
---|
82 | #ifndef N_DATADDR
|
---|
83 | #define N_DATADDR(x) \
|
---|
84 | (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \
|
---|
85 | : (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
|
---|
86 | #endif
|
---|
87 | /* Address of bss segment in memory after it is loaded. */
|
---|
88 | #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
|
---|
89 | |
---|
90 |
|
---|
91 | struct nlist {
|
---|
92 | union {
|
---|
93 | char *n_name;
|
---|
94 | struct nlist *n_next;
|
---|
95 | long n_strx;
|
---|
96 | } n_un;
|
---|
97 | unsigned char n_type;
|
---|
98 | char n_other;
|
---|
99 | short n_desc;
|
---|
100 | unsigned long n_value;
|
---|
101 | };
|
---|
102 | #define N_UNDF 0
|
---|
103 | #define N_ABS 2
|
---|
104 | #define N_TEXT 4
|
---|
105 | #define N_DATA 6
|
---|
106 | #define N_BSS 8
|
---|
107 | #define N_FN 15
|
---|
108 | #define N_EXT 1
|
---|
109 | #define N_TYPE 036
|
---|
110 | #define N_STAB 0340
|
---|
111 | /* The following type indicates the definition of a symbol as being
|
---|
112 | an indirect reference to another symbol. The other symbol
|
---|
113 | appears as an undefined reference, immediately following this symbol.
|
---|
114 | Indirection is asymmetrical. The other symbol's value will be used
|
---|
115 | to satisfy requests for the indirect symbol, but not vice versa.
|
---|
116 | If the other symbol does not have a definition, libraries will
|
---|
117 | be searched to find a definition. */
|
---|
118 | #define N_INDR 0xa
|
---|
119 | /* The following symbols refer to set elements.
|
---|
120 | All the N_SET[ATDB] symbols with the same name form one set.
|
---|
121 | Space is allocated for the set in the text section, and each set
|
---|
122 | element's value is stored into one word of the space.
|
---|
123 | The first word of the space is the length of the set (number of elements).
|
---|
124 | The address of the set is made into an N_SETV symbol
|
---|
125 | whose name is the same as the name of the set.
|
---|
126 | This symbol acts like a N_DATA global symbol
|
---|
127 | in that it can satisfy undefined external references. */
|
---|
128 |
|
---|
129 | /* These appear as input to LD, in a .o file. */
|
---|
130 | #define N_SETA 0x14 /* Absolute set element symbol */
|
---|
131 | #define N_SETT 0x16 /* Text set element symbol */
|
---|
132 | #define N_SETD 0x18 /* Data set element symbol */
|
---|
133 | #define N_SETB 0x1A /* Bss set element symbol */
|
---|
134 | /* This is output from LD. */
|
---|
135 | #define N_SETV 0x1C /* Pointer to set vector in data area. */
|
---|
136 | /* Copied from aout64.h of BFD */
|
---|
137 | #define N_WEAKU 0x0d /* Weak undefined symbol. */
|
---|
138 | #define N_WEAKA 0x0e /* Weak absolute symbol. */
|
---|
139 | #define N_WEAKT 0x0f /* Weak text symbol. */
|
---|
140 | #define N_WEAKD 0x10 /* Weak data symbol. */
|
---|
141 | #define N_WEAKB 0x11 /* Weak bss symbol. */
|
---|
142 | /* emx */
|
---|
143 | #define N_IMP1 0x68 /* Import reference symbol */
|
---|
144 | #define N_IMP2 0x6a /* Import definition symbol */
|
---|
145 | #define N_EXP 0x6c /* Export definition symbol */
|
---|
146 | |
---|
147 |
|
---|
148 | /* This structure describes a single relocation to be performed.
|
---|
149 | The text-relocation section of the file is a vector of these structures,
|
---|
150 | all of which apply to the text section.
|
---|
151 | Likewise, the data-relocation section applies to the data section. */
|
---|
152 | struct relocation_info
|
---|
153 | {
|
---|
154 | /* Address (within segment) to be relocated. */
|
---|
155 | int r_address;
|
---|
156 | /* The meaning of r_symbolnum depends on r_extern. */
|
---|
157 | unsigned int r_symbolnum:24;
|
---|
158 | /* Nonzero means value is a pc-relative offset
|
---|
159 | and it should be relocated for changes in its own address
|
---|
160 | as well as for changes in the symbol or section specified. */
|
---|
161 | unsigned int r_pcrel:1;
|
---|
162 | /* Length (as exponent of 2) of the field to be relocated.
|
---|
163 | Thus, a value of 2 indicates 1<<2 bytes. */
|
---|
164 | unsigned int r_length:2;
|
---|
165 | /* 1 => relocate with value of symbol.
|
---|
166 | r_symbolnum is the index of the symbol
|
---|
167 | in file's the symbol table.
|
---|
168 | 0 => relocate with the address of a segment.
|
---|
169 | r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
|
---|
170 | (the N_EXT bit may be set also, but signifies nothing). */
|
---|
171 | unsigned int r_extern:1;
|
---|
172 | /* Four bits that aren't used, but when writing an object file
|
---|
173 | it is desirable to clear them. */
|
---|
174 | unsigned int r_pad:4;
|
---|
175 | };
|
---|
176 |
|
---|
177 | #endif /* __A_OUT_GNU_H__ */
|
---|