a.out.h

Go to the documentation of this file.
00001 /* The <a.out> header file describes the format of executable files. */
00002 
00003 #ifndef _AOUT_H
00004 #define _AOUT_H
00005 
00006 struct  exec {                  /* a.out header */
00007   unsigned char a_magic[2];     /* magic number */
00008   unsigned char a_flags;        /* flags, see below */
00009   unsigned char a_cpu;          /* cpu id */
00010   unsigned char a_hdrlen;       /* length of header */
00011   unsigned char a_unused;       /* reserved for future use */
00012   unsigned short a_version;     /* version stamp (not used at present) */
00013   long          a_text;         /* size of text segement in bytes */
00014   long          a_data;         /* size of data segment in bytes */
00015   long          a_bss;          /* size of bss segment in bytes */
00016   long          a_entry;        /* entry point */
00017   long          a_total;        /* total memory allocated */
00018   long          a_syms;         /* size of symbol table */
00019 
00020   /* SHORT FORM ENDS HERE */
00021   long          a_trsize;       /* text relocation size */
00022   long          a_drsize;       /* data relocation size */
00023   long          a_tbase;        /* text relocation base */
00024   long          a_dbase;        /* data relocation base */
00025 };
00026 
00027 #define A_MAGIC0      (unsigned char) 0x01
00028 #define A_MAGIC1      (unsigned char) 0x03
00029 #define BADMAG(X)     ((X).a_magic[0] != A_MAGIC0 ||(X).a_magic[1] != A_MAGIC1)
00030 
00031 /* CPU Id of TARGET machine (byte order coded in low order two bits) */
00032 #define A_NONE  0x00    /* unknown */
00033 #define A_I8086 0x04    /* intel i8086/8088 */
00034 #define A_M68K  0x0B    /* motorola m68000 */
00035 #define A_NS16K 0x0C    /* national semiconductor 16032 */
00036 #define A_I80386 0x10   /* intel i80386 */
00037 #define A_SPARC 0x17    /* Sun SPARC */
00038 
00039 #define A_BLR(cputype)  ((cputype&0x01)!=0) /* TRUE if bytes left-to-right */
00040 #define A_WLR(cputype)  ((cputype&0x02)!=0) /* TRUE if words left-to-right */
00041 
00042 /* Flags. */
00043 #define A_UZP   0x01    /* unmapped zero page (pages) */
00044 #define A_PAL   0x02    /* page aligned executable */
00045 #define A_NSYM  0x04    /* new style symbol table */
00046 #define A_IMG   0x08    /* image instead of executable (e.g. root FS) */
00047 #define A_EXEC  0x10    /* executable */
00048 #define A_SEP   0x20    /* separate I/D */
00049 #define A_PURE  0x40    /* pure text */         /* not used */
00050 #define A_TOVLY 0x80    /* text overlay */      /* not used */
00051 
00052 /* Offsets of various things. */
00053 #define A_MINHDR        32
00054 #define A_TEXTPOS(X)    ((long)(X).a_hdrlen)
00055 #define A_DATAPOS(X)    (A_TEXTPOS(X) + (X).a_text)
00056 #define A_HASRELS(X)    ((X).a_hdrlen > (unsigned char) A_MINHDR)
00057 #define A_HASEXT(X)     ((X).a_hdrlen > (unsigned char) (A_MINHDR +  8))
00058 #define A_HASLNS(X)     ((X).a_hdrlen > (unsigned char) (A_MINHDR + 16))
00059 #define A_HASTOFF(X)    ((X).a_hdrlen > (unsigned char) (A_MINHDR + 24))
00060 #define A_TRELPOS(X)    (A_DATAPOS(X) + (X).a_data)
00061 #define A_DRELPOS(X)    (A_TRELPOS(X) + (X).a_trsize)
00062 #define A_SYMPOS(X)     (A_TRELPOS(X) + (A_HASRELS(X) ? \
00063                         ((X).a_trsize + (X).a_drsize) : 0))
00064 
00065 struct reloc {
00066   long r_vaddr;                 /* virtual address of reference */
00067   unsigned short r_symndx;      /* internal segnum or extern symbol num */
00068   unsigned short r_type;        /* relocation type */
00069 };
00070 
00071 /* r_tyep values: */
00072 #define R_ABBS          0
00073 #define R_RELLBYTE      2
00074 #define R_PCRBYTE       3
00075 #define R_RELWORD       4
00076 #define R_PCRWORD       5
00077 #define R_RELLONG       6
00078 #define R_PCRLONG       7
00079 #define R_REL3BYTE      8
00080 #define R_KBRANCHE      9
00081 
00082 /* r_symndx for internal segments */
00083 #define S_ABS           ((unsigned short)-1)
00084 #define S_TEXT          ((unsigned short)-2)
00085 #define S_DATA          ((unsigned short)-3)
00086 #define S_BSS           ((unsigned short)-4)
00087 
00088 struct nlist {                  /* symbol table entry */
00089   char n_name[8];               /* symbol name */
00090   long n_value;                 /* value */
00091   unsigned char n_sclass;       /* storage class */
00092   unsigned char n_numaux;       /* number of auxiliary entries (not used) */
00093   unsigned short n_type;        /* language base and derived type (not used) */
00094 };
00095 
00096 /* Low bits of storage class (section). */
00097 #define N_SECT            07    /* section mask */
00098 #define N_UNDF            00    /* undefined */
00099 #define N_ABS             01    /* absolute */
00100 #define N_TEXT            02    /* text */
00101 #define N_DATA            03    /* data */
00102 #define N_BSS             04    /* bss */
00103 #define N_COMM            05    /* (common) */
00104 
00105 /* High bits of storage class. */
00106 #define N_CLASS         0370    /* storage class mask */
00107 #define C_NULL
00108 #define C_EXT           0020    /* external symbol */
00109 #define C_STAT          0030    /* static */
00110 
00111 /* Function prototypes. */
00112 #ifndef _ANSI_H
00113 #include <ansi.h>
00114 #endif
00115 
00116 _PROTOTYPE( int nlist, (char *_file, struct nlist *_nl)                 );
00117 
00118 #endif /* _AOUT_H */

Generated on Fri Apr 14 22:56:59 2006 for minix by  doxygen 1.4.6