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 #include <bits/a.out.h>
00005 
00006 #define __GNU_EXEC_MACROS__
00007 
00008 /*
00009  * OSF/1 ECOFF header structs.  ECOFF files consist of:
00010  *      - a file header (struct filehdr),
00011  *      - an a.out header (struct aouthdr),
00012  *      - one or more section headers (struct scnhdr).
00013  *        The filhdr's "f_nscns" field contains the
00014  *        number of section headers.
00015  */
00016 
00017 struct filehdr
00018 {
00019   /* OSF/1 "file" header */
00020   unsigned short f_magic, f_nscns;
00021   unsigned int   f_timdat;
00022   unsigned long  f_symptr;
00023   unsigned int   f_nsyms;
00024   unsigned short f_opthdr, f_flags;
00025 };
00026 
00027 struct aouthdr
00028 {
00029   unsigned long info;              /* After that it looks quite normal..  */
00030   unsigned long tsize;
00031   unsigned long dsize;
00032   unsigned long bsize;
00033   unsigned long entry;
00034   unsigned long text_start; /* With a few additions that actually make sense.  */
00035   unsigned long data_start;
00036   unsigned long bss_start;
00037   unsigned int  gprmask, fprmask; /* Bitmask of general & floating point regs used in binary.  */
00038   unsigned long gpvalue;
00039 };
00040 
00041 struct scnhdr
00042 {
00043   char           s_name[8];
00044   unsigned long  s_paddr;
00045   unsigned long  s_vaddr;
00046   unsigned long  s_size;
00047   unsigned long  s_scnptr;
00048   unsigned long  s_relptr;
00049   unsigned long  s_lnnoptr;
00050   unsigned short s_nreloc;
00051   unsigned short s_nlnno;
00052   unsigned int   s_flags;
00053 };
00054 
00055 struct exec
00056 {
00057   /* OSF/1 "file" header */
00058   struct filehdr fh;
00059   struct aouthdr ah;
00060 };
00061 
00062 #define a_info              ah.info
00063 #define a_text              ah.tsize
00064 #define a_data              ah.dsize
00065 #define a_bss        ah.bsize
00066 #define a_entry             ah.entry
00067 #define a_textstart  ah.text_start
00068 #define a_datastart  ah.data_start
00069 #define a_bssstart   ah.bss_start
00070 #define a_gprmask    ah.gprmask
00071 #define a_fprmask    ah.fprmask
00072 #define a_gpvalue    ah.gpvalue
00073 
00074 
00075 #define AOUTHSZ             sizeof(struct aouthdr)
00076 #define SCNHSZ              sizeof(struct scnhdr)
00077 #define SCNROUND     16
00078 
00079 enum machine_type
00080 {
00081   M_OLDSUN2 = 0,
00082   M_68010 = 1,
00083   M_68020 = 2,
00084   M_SPARC = 3,
00085   M_386 = 100,
00086   M_MIPS1 = 151,
00087   M_MIPS2 = 152
00088 };
00089 
00090 #define N_MAGIC(exec)       ((exec).a_info & 0xffff)
00091 #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
00092 #define N_FLAGS(exec)       (((exec).a_info >> 24) & 0xff)
00093 #define N_SET_INFO(exec, magic, type, flags) \
00094   ((exec).a_info = ((magic) & 0xffff)                                 \
00095    | (((int)(type) & 0xff) << 16)                              \
00096    | (((flags) & 0xff) << 24))
00097 #define N_SET_MAGIC(exec, magic) \
00098   ((exec).a_info = ((exec).a_info & 0xffff0000) | ((magic) & 0xffff))
00099 #define N_SET_MACHTYPE(exec, machtype) \
00100   ((exec).a_info =                                             \
00101    ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
00102 #define N_SET_FLAGS(exec, flags) \
00103   ((exec).a_info =                                             \
00104    ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
00105 
00106 /* Code indicating object file or impure executable.  */
00107 #define OMAGIC 0407
00108 /* Code indicating pure executable.  */
00109 #define NMAGIC 0410
00110 /* Code indicating demand-paged executable.  */
00111 #define ZMAGIC 0413
00112 /* This indicates a demand-paged executable with the header in the text.
00113    The first page is unmapped to help trap NULL pointer references.  */
00114 #define QMAGIC 0314
00115 /* Code indicating core file.  */
00116 #define CMAGIC 0421
00117 
00118 #define N_TRSIZE(x)  0
00119 #define N_DRSIZE(x)  0
00120 #define N_SYMSIZE(x) 0
00121 #define N_BADMAG(x) \
00122   (N_MAGIC(x) != OMAGIC     && N_MAGIC(x) != NMAGIC                          \
00123    && N_MAGIC(x) != ZMAGIC && N_MAGIC(x) != QMAGIC)
00124 #define _N_HDROFF(x) (1024 - sizeof (struct exec))
00125 #define N_TXTOFF(x) \
00126   ((long) N_MAGIC(x) == ZMAGIC ? 0 :                                  \
00127    (sizeof (struct exec) + (x).fh.f_nscns * SCNHSZ + SCNROUND - 1)    \
00128    & ~(SCNROUND - 1))
00129 
00130 #define N_DATOFF(x)  (N_TXTOFF(x) + (x).a_text)
00131 #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
00132 #define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
00133 #define N_SYMOFF(x)  (N_DRELOFF(x) + N_DRSIZE(x))
00134 #define N_STROFF(x)  (N_SYMOFF(x) + N_SYMSIZE(x))
00135 
00136 /* Address of text segment in memory after it is loaded.  */
00137 #define N_TXTADDR(x) ((x).a_textstart)
00138 
00139 /* Address of data segment in memory after it is loaded.  */
00140 #define SEGMENT_SIZE 1024
00141 
00142 #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
00143 #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
00144 
00145 #define N_DATADDR(x) ((x).a_datastart)
00146 #define N_BSSADDR(x) ((x).a_bssstart)
00147 
00148 #if !defined (N_NLIST_DECLARED)
00149 struct nlist
00150 {
00151   union
00152     {
00153       char *n_name;
00154       struct nlist *n_next;
00155       long n_strx;
00156     } n_un;
00157   unsigned char n_type;
00158   char n_other;
00159   short n_desc;
00160   unsigned long n_value;
00161 };
00162 #endif /* no N_NLIST_DECLARED.  */
00163 
00164 #define N_UNDF       0
00165 #define N_ABS 2
00166 #define N_TEXT       4
00167 #define N_DATA       6
00168 #define N_BSS 8
00169 #define N_FN  15
00170 #define N_EXT 1
00171 #define N_TYPE       036
00172 #define N_STAB       0340
00173 #define N_INDR       0xa
00174 #define       N_SETA 0x14   /* Absolute set element symbol.  */
00175 #define       N_SETT 0x16   /* Text set element symbol.  */
00176 #define       N_SETD 0x18   /* Data set element symbol.  */
00177 #define       N_SETB 0x1A   /* Bss set element symbol.  */
00178 #define N_SETV       0x1C   /* Pointer to set vector in data area.  */
00179 
00180 #if !defined (N_RELOCATION_INFO_DECLARED)
00181 /* This structure describes a single relocation to be performed.
00182    The text-relocation section of the file is a vector of these structures,
00183    all of which apply to the text section.
00184    Likewise, the data-relocation section applies to the data section.  */
00185 
00186 struct relocation_info
00187 {
00188   int r_address;
00189   unsigned int r_symbolnum:24;
00190   unsigned int r_pcrel:1;
00191   unsigned int r_length:2;
00192   unsigned int r_extern:1;
00193   unsigned int r_pad:4;
00194 };
00195 #endif /* no N_RELOCATION_INFO_DECLARED.  */
00196 
00197 #endif /* __A_OUT_GNU_H__ */