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 struct exec
00009 {
00010   unsigned char a_dynamic:1;       /* A __DYNAMIC is in this image.  */
00011   unsigned char a_toolversion:7;
00012   unsigned char a_machtype;
00013   unsigned short a_info;
00014   unsigned int a_text;             /* Length of text, in bytes.  */
00015   unsigned int a_data;             /* Length of data, in bytes.  */
00016   unsigned int a_bss;              /* Length of bss, in bytes.  */
00017   unsigned int a_syms;             /* Length of symbol table, in bytes.  */
00018   unsigned int a_entry;            /* Where program begins.  */
00019   unsigned int a_trsize;
00020   unsigned int a_drsize;
00021 };
00022 
00023 enum machine_type
00024 {
00025   M_OLDSUN2 = 0,
00026   M_68010 = 1,
00027   M_68020 = 2,
00028   M_SPARC = 3,
00029   M_386 = 100,
00030   M_MIPS1 = 151,
00031   M_MIPS2 = 152
00032 };
00033 
00034 #define N_MAGIC(exec)       ((exec).a_info & 0xffff)
00035 #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
00036 #define N_FLAGS(exec)       (((exec).a_info >> 24) & 0xff)
00037 #define N_SET_INFO(exec, magic, type, flags) \
00038   ((exec).a_info = ((magic) & 0xffff)                                 \
00039    | (((int)(type) & 0xff) << 16)                              \
00040    | (((flags) & 0xff) << 24))
00041 #define N_SET_MAGIC(exec, magic) \
00042   ((exec).a_info = ((exec).a_info & 0xffff0000) | ((magic) & 0xffff))
00043 #define N_SET_MACHTYPE(exec, machtype) \
00044   ((exec).a_info =                                             \
00045    ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
00046 #define N_SET_FLAGS(exec, flags) \
00047   ((exec).a_info =                                             \
00048    ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
00049 
00050 /* Code indicating object file or impure executable.  */
00051 #define OMAGIC 0407
00052 /* Code indicating pure executable.  */
00053 #define NMAGIC 0410
00054 /* Code indicating demand-paged executable.  */
00055 #define ZMAGIC 0413
00056 /* This indicates a demand-paged executable with the header in the text. 
00057    The first page is unmapped to help trap NULL pointer references.  */
00058 #define QMAGIC 0314
00059 /* Code indicating core file.  */
00060 #define CMAGIC 0421
00061 
00062 #define N_TRSIZE(a)  ((a).a_trsize)
00063 #define N_DRSIZE(a)  ((a).a_drsize)
00064 #define N_SYMSIZE(a) ((a).a_syms)
00065 #define N_BADMAG(x) \
00066   (N_MAGIC(x) != OMAGIC     && N_MAGIC(x) != NMAGIC                          \
00067    && N_MAGIC(x) != ZMAGIC && N_MAGIC(x) != QMAGIC)
00068 #define _N_HDROFF(x) (1024 - sizeof (struct exec))
00069 #define N_TXTOFF(x) \
00070   (N_MAGIC(x) == ZMAGIC ? 0 : sizeof (struct exec))
00071 #define N_DATOFF(x)  (N_TXTOFF(x) + (x).a_text)
00072 #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
00073 #define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
00074 #define N_SYMOFF(x) \
00075   (N_TXTOFF(x) + (x).a_text + (x).a_data + (x).a_trsize + (x).a_drsize)
00076 #define N_STROFF(x)  (N_SYMOFF(x) + N_SYMSIZE(x))
00077 
00078 #define SPARC_PGSIZE 0x2000
00079 
00080 /* Address of text segment in memory after it is loaded.  */
00081 #define N_TXTADDR(x) \
00082  (unsigned long)(((N_MAGIC(x) == ZMAGIC) && ((x).a_entry < SPARC_PGSIZE)) \
00083                ? 0 : SPARC_PGSIZE)
00084 
00085 /* Address of data segment in memory after it is loaded.  */
00086 #define SEGMENT_SIZE SPARC_PGSIZE
00087 
00088 #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
00089 #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
00090 
00091 #define N_DATADDR(x) \
00092   (N_MAGIC(x)==OMAGIC                                                 \
00093    ? (N_TXTADDR(x) + (x).a_text)                               \
00094    : (unsigned long)(_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
00095 #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
00096 
00097 #if !defined (N_NLIST_DECLARED)
00098 struct nlist
00099 {
00100   union
00101     {
00102       char *n_name;
00103       struct nlist *n_next;
00104       long n_strx;
00105     } n_un;
00106   unsigned char n_type;
00107   char n_other;
00108   short n_desc;
00109   unsigned long n_value;
00110 };
00111 #endif /* no N_NLIST_DECLARED.  */
00112 
00113 #define N_UNDF       0
00114 #define N_ABS 2
00115 #define N_TEXT       4
00116 #define N_DATA       6
00117 #define N_BSS 8
00118 #define N_FN  15
00119 #define N_EXT 1
00120 #define N_TYPE       036
00121 #define N_STAB       0340
00122 #define N_INDR       0xa
00123 #define       N_SETA 0x14   /* Absolute set element symbol.  */
00124 #define       N_SETT 0x16   /* Text set element symbol.  */
00125 #define       N_SETD 0x18   /* Data set element symbol.  */
00126 #define       N_SETB 0x1A   /* Bss set element symbol.  */
00127 #define N_SETV       0x1C   /* Pointer to set vector in data area.  */
00128 
00129 #if !defined (N_RELOCATION_INFO_DECLARED)
00130 enum reloc_type
00131 {
00132   RELOC_8,
00133   RELOC_16,
00134   RELOC_32,
00135   RELOC_DISP8,
00136   RELOC_DISP16,
00137   RELOC_DISP32,
00138   RELOC_WDISP30,
00139   RELOC_WDISP22,
00140   RELOC_HI22,
00141   RELOC_22,
00142   RELOC_13,
00143   RELOC_LO10,
00144   RELOC_SFA_BASE,
00145   RELOC_SFA_OFF13,
00146   RELOC_BASE10,
00147   RELOC_BASE13,
00148   RELOC_BASE22,
00149   RELOC_PC10,
00150   RELOC_PC22,
00151   RELOC_JMP_TBL,
00152   RELOC_SEGOFF16,
00153   RELOC_GLOB_DAT,
00154   RELOC_JMP_SLOT,
00155   RELOC_RELATIVE
00156 };
00157 
00158 /* This structure describes a single relocation to be performed.
00159    The text-relocation section of the file is a vector of these structures,
00160    all of which apply to the text section.
00161    Likewise, the data-relocation section applies to the data section.  */
00162 
00163 struct relocation_info
00164 {
00165   unsigned int r_address;
00166   unsigned int r_index:24;
00167   unsigned int r_extern:1;
00168   int r_pad:2;
00169   enum reloc_type r_type:5;
00170   int r_addend;
00171 };
00172 #endif /* no N_RELOCATION_INFO_DECLARED.  */
00173 
00174 #endif /* __A_OUT_GNU_H__ */