00001 #ifndef __A_OUT_GNU_H__
00002 #define __A_OUT_GNU_H__
00003
00004 #define __GNU_EXEC_MACROS__
00005
00006 #ifndef __STRUCT_EXEC_OVERRIDE__
00007
00008 struct exec
00009 {
00010 unsigned long a_info;
00011 unsigned a_text;
00012 unsigned a_data;
00013 unsigned a_bss;
00014 unsigned a_syms;
00015 unsigned a_entry;
00016 unsigned a_trsize;
00017 unsigned a_drsize;
00018 };
00019
00020 #endif // __STRUCT_EXEC_OVERRIDE__
00021
00022
00023 enum machine_type {
00024 #if defined (M_OLDSUN2)
00025 M__OLDSUN2 = M_OLDSUN2,
00026 #else
00027 M_OLDSUN2 = 0,
00028 #endif
00029 #if defined (M_68010)
00030 M__68010 = M_68010,
00031 #else
00032 M_68010 = 1,
00033 #endif
00034 #if defined (M_68020)
00035 M__68020 = M_68020,
00036 #else
00037 M_68020 = 2,
00038 #endif
00039 #if defined (M_SPARC)
00040 M__SPARC = M_SPARC,
00041 #else
00042 M_SPARC = 3,
00043 #endif
00044
00045 M_386 = 100,
00046 };
00047
00048 #if !defined (N_MAGIC)
00049 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
00050 #endif
00051 #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
00052 #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
00053 #define N_SET_INFO(exec, magic, type, flags) \
00054 ((exec).a_info = ((magic) & 0xffff) \
00055 | (((int)(type) & 0xff) << 16) \
00056 | (((flags) & 0xff) << 24))
00057 #define N_SET_MAGIC(exec, magic) \
00058 ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
00059
00060 #define N_SET_MACHTYPE(exec, machtype) \
00061 ((exec).a_info = \
00062 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
00063
00064 #define N_SET_FLAGS(exec, flags) \
00065 ((exec).a_info = \
00066 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
00067
00068
00069 #define OMAGIC 0407
00070
00071 #define NMAGIC 0410
00072
00073 #define ZMAGIC 0413
00074
00075
00076
00077
00078
00079
00080 #define QMAGIC 0314
00081
00082
00083 #define CMAGIC 0421
00084
00085 #if !defined (N_BADMAG)
00086 #define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
00087 && N_MAGIC(x) != NMAGIC \
00088 && N_MAGIC(x) != ZMAGIC \
00089 && N_MAGIC(x) != QMAGIC)
00090 #endif
00091
00092 #define _N_HDROFF(x) (1024 - sizeof (struct exec))
00093
00094 #if !defined (N_TXTOFF)
00095 #define N_TXTOFF(x) \
00096 (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
00097 (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
00098 #endif
00099
00100 #if !defined (N_DATOFF)
00101 #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
00102 #endif
00103
00104 #if !defined (N_TRELOFF)
00105 #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
00106 #endif
00107
00108 #if !defined (N_DRELOFF)
00109 #define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
00110 #endif
00111
00112 #if !defined (N_SYMOFF)
00113 #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
00114 #endif
00115
00116 #if !defined (N_STROFF)
00117 #define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
00118 #endif
00119
00120
00121 #if !defined (N_TXTADDR)
00122 #define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)
00123 #endif
00124
00125
00126
00127
00128
00129
00130
00131
00132 #if defined(vax) || defined(hp300) || defined(pyr)
00133 #define SEGMENT_SIZE page_size
00134 #endif
00135 #ifdef sony
00136 #define SEGMENT_SIZE 0x2000
00137 #endif // Sony.
00138 #ifdef is68k
00139 #define SEGMENT_SIZE 0x20000
00140 #endif
00141 #if defined(m68k) && defined(PORTAR)
00142 #define PAGE_SIZE 0x400
00143 #define SEGMENT_SIZE PAGE_SIZE
00144 #endif
00145
00146 #ifdef linux
00147 #include <linux/page.h>
00148 #define SEGMENT_SIZE 1024
00149 #endif
00150
00151 #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
00152
00153 #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
00154
00155 #ifndef N_DATADDR
00156 #define N_DATADDR(x) \
00157 (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
00158 : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
00159 #endif
00160
00161
00162 #if !defined (N_BSSADDR)
00163 #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
00164 #endif
00165
00166 #if !defined (N_NLIST_DECLARED)
00167 struct nlist {
00168 union {
00169 char *n_name;
00170 struct nlist *n_next;
00171 long n_strx;
00172 } n_un;
00173 unsigned char n_type;
00174 char n_other;
00175 short n_desc;
00176 unsigned long n_value;
00177 };
00178 #endif // no N_NLIST_DECLARED.
00179
00180 #if !defined (N_UNDF)
00181 #define N_UNDF 0
00182 #endif
00183 #if !defined (N_ABS)
00184 #define N_ABS 2
00185 #endif
00186 #if !defined (N_TEXT)
00187 #define N_TEXT 4
00188 #endif
00189 #if !defined (N_DATA)
00190 #define N_DATA 6
00191 #endif
00192 #if !defined (N_BSS)
00193 #define N_BSS 8
00194 #endif
00195 #if !defined (N_FN)
00196 #define N_FN 15
00197 #endif
00198
00199 #if !defined (N_EXT)
00200 #define N_EXT 1
00201 #endif
00202 #if !defined (N_TYPE)
00203 #define N_TYPE 036
00204 #endif
00205 #if !defined (N_STAB)
00206 #define N_STAB 0340
00207 #endif
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221 #define N_INDR 0xa
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239 #define N_SETA 0x14
00240 #define N_SETT 0x16
00241 #define N_SETD 0x18
00242 #define N_SETB 0x1A
00243
00244
00245 #define N_SETV 0x1C
00246
00247 #if !defined (N_RELOCATION_INFO_DECLARED)
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257 struct relocation_info
00258 {
00259
00260 int r_address;
00261
00262 unsigned int r_symbolnum:24;
00263
00264
00265
00266
00267
00268
00269
00270 unsigned int r_pcrel:1;
00271
00272
00273
00274
00275
00276
00277 unsigned int r_length:2;
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288 unsigned int r_extern:1;
00289
00290
00291
00292
00293
00294
00295 #ifdef NS32K
00296 unsigned r_bsr:1;
00297 unsigned r_disp:1;
00298 unsigned r_pad:2;
00299 #else
00300 unsigned int r_pad:4;
00301 #endif
00302 };
00303 #endif // no N_RELOCATION_INFO_DECLARED.
00304
00305
00306 #endif // __A_OUT_GNU_H__