Back to index

glibc  2.9
a.out.h
Go to the documentation of this file.
00001 #ifndef __A_OUT_GNU_H__
00002 #define __A_OUT_GNU_H__
00003 
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007 
00008 #define __GNU_EXEC_MACROS__
00009 
00010 #ifndef __STRUCT_EXEC_OVERRIDE__
00011 
00012 struct exec
00013 {
00014   unsigned long a_info;            /* Use macros N_MAGIC, etc for access */
00015   unsigned a_text;          /* size of text, in bytes */
00016   unsigned a_data;          /* size of data, in bytes */
00017   unsigned a_bss;           /* size of uninitialized data area, in bytes */
00018   unsigned a_syms;          /* length of symbol table data, in bytes */
00019   unsigned a_entry;         /* start address */
00020   unsigned a_trsize;        /* size of reloc info for text, in bytes */
00021   unsigned a_drsize;        /* size of reloc info for data, in bytes */
00022 
00023 #if defined (sequent) && defined (i386)
00024   struct gdtbl
00025     {                       /* Global Descriptor Table */
00026       unsigned g_code[2];
00027       unsigned g_data[2];
00028       unsigned g_desc[2];
00029     } a_gdtbl;
00030    unsigned a_shdata;              /* size of initialized shared data */
00031    unsigned a_shbss;        /* size of uninitialized shared data */
00032    unsigned a_shdrsize;            /* size of shared data relocation */
00033    unsigned a_bootstrap[11];       /* bootstrap for standalone */
00034    unsigned a_reserved[3];  /* reserved for future use */
00035    unsigned a_version;             /* object version */
00036 #endif /* Sequent Symmetry, Dynix 3.x */
00037 };
00038 
00039 #endif /* __STRUCT_EXEC_OVERRIDE__ */
00040 
00041 /* these go in the N_MACHTYPE field */
00042 enum machine_type {
00043 #if defined (M_OLDSUN2)
00044   M__OLDSUN2 = M_OLDSUN2,
00045 #else
00046   M_OLDSUN2 = 0,
00047 #endif
00048 #if defined (M_68010)
00049   M__68010 = M_68010,
00050 #else
00051   M_68010 = 1,
00052 #endif
00053 #if defined (M_68020)
00054   M__68020 = M_68020,
00055 #else
00056   M_68020 = 2,
00057 #endif
00058 #if defined (M_SPARC)
00059   M__SPARC = M_SPARC,
00060 #else
00061   M_SPARC = 3,
00062 #endif
00063   /* skip a bunch so we don't run into any of sun's numbers */
00064   M_386 = 100
00065 };
00066 
00067 #if defined (sequent) && defined (i386)
00068 
00069 /* Dynix 3 wants the magic number to be the whole first longword.  */
00070 
00071 #define N_MAGIC(exec)              ((exec).a_info)
00072 #define N_MACHTYPE(exec)    0
00073 #define N_FLAGS(exec)              0
00074 #define N_SET_INFO(exec, magic, type, flags) N_SET_MAGIC ((exec), (magic))
00075 #define N_SET_MAGIC(exec, magic)   ((exec).a_info = (magic))
00076 #define N_SET_MACHTYPE(exec, machtype)    ((void) 0)
00077 #define N_SET_FLAGS(exec, flags)   ((void) 0)
00078 #define       OMAGIC        0x12eb /* impure format - for .o's */
00079 #define       ZMAGIC        0x22eb /* demand load format - zero at zero */
00080 #define NMAGIC              you lose /* syntax error -- no pure format */
00081 #define N_BADMAG(x)  (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != ZMAGIC)
00082 #define N_ADDRADJ(x) (N_MAGIC(x) == ZMAGIC ? SEGMENT_SIZE : 0)
00083 #define N_DATOFF(x)  (N_TXTOFF(x) + (x).a_text - N_ADDRADJ(x))
00084 #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data + (x).a_shdata)
00085 #define N_SYMOFF(x)  (N_DRELOFF(x) + (x).a_drsize + (x).a_shdrsize)
00086 #define N_TXTADDR(x) SEGMENT_SIZE
00087 #define N_COMM              0x0a   
00088 #define N_FN         0x0c
00089 /* Note that the Dynix binutils believe that N_SET[TDB] are
00090    N_SH{DATA,BSS,COMM} -- be wary when mixing GNU & Dynix objects.  */
00091 #define PAGE_SIZE    4096
00092 #define SEGMENT_SIZE PAGE_SIZE
00093 
00094 #else /* !(sequent && i386) */
00095 
00096 #if !defined (N_MAGIC)
00097 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
00098 #endif
00099 #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
00100 #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
00101 #define N_SET_INFO(exec, magic, type, flags) \
00102        ((exec).a_info = ((magic) & 0xffff) \
00103         | (((int)(type) & 0xff) << 16) \
00104         | (((flags) & 0xff) << 24))
00105 #define N_SET_MAGIC(exec, magic) \
00106        ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
00107 
00108 #define N_SET_MACHTYPE(exec, machtype) \
00109        ((exec).a_info = \
00110         ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
00111 
00112 #define N_SET_FLAGS(exec, flags) \
00113        ((exec).a_info = \
00114         ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
00115 
00116 #endif /* sequent && i386 */
00117 
00118 #ifndef OMAGIC
00119 /* Code indicating object file or impure executable.  */
00120 #define OMAGIC 0407
00121 /* Code indicating pure executable.  */
00122 #define NMAGIC 0410
00123 /* Code indicating demand-paged executable.  */
00124 #define ZMAGIC 0413
00125 #endif /* not OMAGIC */
00126 
00127 #if !defined (N_BADMAG)
00128 #define N_BADMAG(x)                              \
00129  (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC          \
00130   && N_MAGIC(x) != ZMAGIC)
00131 #endif
00132 
00133 #define _N_BADMAG(x)                             \
00134  (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC          \
00135   && N_MAGIC(x) != ZMAGIC)
00136 
00137 #ifndef       sparc
00138 #define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec))
00139 #else
00140 #define _N_HDROFF(x) (- sizeof (struct exec))
00141 #endif
00142 
00143 #if !defined (N_TXTOFF)
00144 #define N_TXTOFF(x) \
00145  (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))
00146 #endif
00147 
00148 #if !defined (N_DATOFF)
00149 #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
00150 #endif
00151 
00152 #if !defined (N_TRELOFF)
00153 #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
00154 #endif
00155 
00156 #if !defined (N_DRELOFF)
00157 #define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
00158 #endif
00159 
00160 #if !defined (N_SYMOFF)
00161 #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
00162 #endif
00163 
00164 #if !defined (N_STROFF)
00165 #define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
00166 #endif
00167 
00168 /* Address of text segment in memory after it is loaded.  */
00169 #if !defined (N_TXTADDR)
00170 #define N_TXTADDR(x) 0
00171 #endif
00172 
00173 /* Address of data segment in memory after it is loaded.
00174    Note that it is up to you to define SEGMENT_SIZE
00175    on machines not listed here.  */
00176 #if    defined (hp300) || defined (mips)
00177 #define       PAGE_SIZE     4096
00178 #endif
00179 #if    defined (sparc) || defined (NeXT)
00180 #define       PAGE_SIZE     0x2000
00181 #endif
00182 #if    defined (sony) || (defined (sun) && defined (mc68000))
00183 #define       SEGMENT_SIZE  0x2000
00184 #endif /* Sony or 68k Sun.  */
00185 #ifdef is68k
00186 #define SEGMENT_SIZE 0x20000
00187 #endif
00188 #if defined(m68k) && defined(PORTAR)
00189 #define PAGE_SIZE 0x400
00190 #endif
00191 #if defined(i386) && !defined(sequent)
00192 /* For COFF encapsulation.  */
00193 #define SEGMENT_SIZE 0x400000
00194 #endif
00195 #ifndef       SEGMENT_SIZE
00196 /* This used to be first in this paragraph and under:
00197    if (defined(vax) || defined(hp300) || defined(pyr) || defined(sparc) \
00198      || (defined(m68k) && defined(PORTAR)) \
00199      || defined (NeXT) || defined (mips)) */
00200 #define SEGMENT_SIZE PAGE_SIZE
00201 #endif
00202 #ifndef       PAGE_SIZE
00203 /* This value is for i386-minix, but that has no predefine.
00204    Making it default will only cause confusion on machines
00205    which have no proper value defined.  */
00206 #define       PAGE_SIZE 16
00207 #endif
00208 
00209 #define       PAGSIZ PAGE_SIZE
00210 #define       SEGSIZ SEGMENT_SIZE
00211 
00212 #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
00213 
00214 #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
00215 
00216 #ifndef N_DATADDR
00217 #define N_DATADDR(x) \
00218     (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
00219      : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
00220 #endif
00221 
00222 /* Address of bss segment in memory after it is loaded.  */
00223 #if !defined (N_BSSADDR)
00224 #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
00225 #endif
00226 
00227 #if !defined (N_NLIST_DECLARED)
00228 struct nlist {
00229   union {
00230     char *n_name;
00231     struct nlist *n_next;
00232     long n_strx;
00233   } n_un;
00234   unsigned char n_type;
00235   char n_other;
00236   short n_desc;
00237   unsigned long n_value;
00238 };
00239 #endif /* no N_NLIST_DECLARED.  */
00240 
00241 #if !defined (N_UNDF)
00242 #define N_UNDF 0
00243 #endif
00244 #if !defined (N_ABS)
00245 #define N_ABS 2
00246 #endif
00247 #if !defined (N_TEXT)
00248 #define N_TEXT 4
00249 #endif
00250 #if !defined (N_DATA)
00251 #define N_DATA 6
00252 #endif
00253 #if !defined (N_BSS)
00254 #define N_BSS 8
00255 #endif
00256 #if !defined (N_COMM)
00257 #define N_COMM 18
00258 #endif
00259 #if !defined (N_FN)
00260 #define N_FN 15
00261 #endif
00262 
00263 #if !defined (N_EXT)
00264 #define N_EXT 1
00265 #endif
00266 #if !defined (N_TYPE)
00267 #define N_TYPE 036
00268 #endif
00269 #if !defined (N_STAB)
00270 #define N_STAB 0340
00271 #endif
00272 
00273 /* The following type indicates the definition of a symbol as being
00274    an indirect reference to another symbol.  The other symbol
00275    appears as an undefined reference, immediately following this symbol.
00276 
00277    Indirection is asymmetrical.  The other symbol's value will be used
00278    to satisfy requests for the indirect symbol, but not vice versa.
00279    If the other symbol does not have a definition, libraries will
00280    be searched to find a definition.  */
00281 #define N_INDR 0xa
00282 
00283 /* The following symbols refer to set elements.
00284    All the N_SET[ATDB] symbols with the same name form one set.
00285    Space is allocated for the set in the text section, and each set
00286    element's value is stored into one word of the space.
00287    The first word of the space is the length of the set (number of elements).
00288 
00289    The address of the set is made into an N_SETV symbol
00290    whose name is the same as the name of the set.
00291    This symbol acts like a N_DATA global symbol
00292    in that it can satisfy undefined external references.  */
00293 
00294 /* These appear as input to LD, in a .o file.  */
00295 #define       N_SETA 0x14          /* Absolute set element symbol */
00296 #define       N_SETT 0x16          /* Text set element symbol */
00297 #define       N_SETD 0x18          /* Data set element symbol */
00298 #define       N_SETB 0x1A          /* Bss set element symbol */
00299 
00300 /* This is output from LD.  */
00301 #define N_SETV       0x1C          /* Pointer to set vector in data area.  */
00302 
00303 #if !defined (N_RELOCATION_INFO_DECLARED)
00304 /* This structure describes a single relocation to be performed.
00305    The text-relocation section of the file is a vector of these structures,
00306    all of which apply to the text section.
00307    Likewise, the data-relocation section applies to the data section.  */
00308 
00309 struct relocation_info
00310 {
00311   /* Address (within segment) to be relocated.  */
00312   int r_address;
00313   /* The meaning of r_symbolnum depends on r_extern.  */
00314   unsigned int r_symbolnum:24;
00315   /* Nonzero means value is a pc-relative offset
00316      and it should be relocated for changes in its own address
00317      as well as for changes in the symbol or section specified.  */
00318   unsigned int r_pcrel:1;
00319   /* Length (as exponent of 2) of the field to be relocated.
00320      Thus, a value of 2 indicates 1<<2 bytes.  */
00321   unsigned int r_length:2;
00322   /* 1 => relocate with value of symbol.
00323           r_symbolnum is the index of the symbol
00324          in file's the symbol table.
00325      0 => relocate with the address of a segment.
00326           r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
00327          (the N_EXT bit may be set also, but signifies nothing).  */
00328   unsigned int r_extern:1;
00329   /* Four bits that aren't used, but when writing an object file
00330      it is desirable to clear them.  */
00331   unsigned int r_pad:4;
00332 };
00333 #endif /* no N_RELOCATION_INFO_DECLARED.  */
00334 
00335 #ifdef __cplusplus
00336 }
00337 #endif
00338 
00339 #endif /* __A_OUT_GNU_H__ */