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 long a_info;     /* Use macros N_MAGIC, etc for access.  */
00011   unsigned int a_text;      /* Length of text, in bytes.  */
00012   unsigned int a_data;      /* Length of data, in bytes.  */
00013   unsigned int a_bss;       /* Length of uninitialized data area for file, in bytes.  */
00014   unsigned int a_syms;      /* Length of symbol table data in file, in bytes.  */
00015   unsigned int a_entry;     /* Start address.  */
00016   unsigned int a_trsize;/* Length of relocation info for text, in bytes.  */
00017   unsigned int a_drsize;/* Length of relocation info for data, in bytes.  */
00018 };
00019 
00020 enum machine_type
00021 {
00022   M_OLDSUN2 = 0,
00023   M_68010 = 1,
00024   M_68020 = 2,
00025   M_SPARC = 3,
00026   M_386 = 100,
00027   M_MIPS1 = 151,
00028   M_MIPS2 = 152
00029 };
00030 
00031 #define N_MAGIC(exec)       ((exec).a_info & 0xffff)
00032 #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
00033 #define N_FLAGS(exec)       (((exec).a_info >> 24) & 0xff)
00034 #define N_SET_INFO(exec, magic, type, flags) \
00035   ((exec).a_info = ((magic) & 0xffff)                                 \
00036    | (((int)(type) & 0xff) << 16)                              \
00037    | (((flags) & 0xff) << 24))
00038 #define N_SET_MAGIC(exec, magic) \
00039   ((exec).a_info = ((exec).a_info & 0xffff0000) | ((magic) & 0xffff))
00040 #define N_SET_MACHTYPE(exec, machtype) \
00041   ((exec).a_info =                                             \
00042    ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
00043 #define N_SET_FLAGS(exec, flags) \
00044   ((exec).a_info =                                             \
00045    ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
00046 
00047 /* Code indicating object file or impure executable.  */
00048 #define OMAGIC 0407
00049 /* Code indicating pure executable.  */
00050 #define NMAGIC 0410
00051 /* Code indicating demand-paged executable.  */
00052 #define ZMAGIC 0413
00053 /* This indicates a demand-paged executable with the header in the text. 
00054    The first page is unmapped to help trap NULL pointer references.  */
00055 #define QMAGIC 0314
00056 /* Code indicating core file.  */
00057 #define CMAGIC 0421
00058 
00059 #define N_TRSIZE(a)  ((a).a_trsize)
00060 #define N_DRSIZE(a)  ((a).a_drsize)
00061 #define N_SYMSIZE(a) ((a).a_syms)
00062 #define N_BADMAG(x) \
00063   (N_MAGIC(x) != OMAGIC     && N_MAGIC(x) != NMAGIC                          \
00064    && N_MAGIC(x) != ZMAGIC && N_MAGIC(x) != QMAGIC)
00065 #define _N_HDROFF(x) (1024 - sizeof (struct exec))
00066 #define N_TXTOFF(x) \
00067   (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) :     \
00068    (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
00069 #define N_DATOFF(x)  (N_TXTOFF(x) + (x).a_text)
00070 #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
00071 #define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
00072 #define N_SYMOFF(x)  (N_DRELOFF(x) + N_DRSIZE(x))
00073 #define N_STROFF(x)  (N_SYMOFF(x) + N_SYMSIZE(x))
00074 
00075 /* Address of text segment in memory after it is loaded.  */
00076 #define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? 4096 : 0)
00077 
00078 /* Address of data segment in memory after it is loaded.  */
00079 #define SEGMENT_SIZE 1024
00080 
00081 #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
00082 #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
00083 
00084 #define N_DATADDR(x) \
00085   (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x))                      \
00086    : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
00087 #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
00088 
00089 #if !defined (N_NLIST_DECLARED)
00090 struct nlist
00091 {
00092   union
00093     {
00094       char *n_name;
00095       struct nlist *n_next;
00096       long n_strx;
00097     } n_un;
00098   unsigned char n_type;
00099   char n_other;
00100   short n_desc;
00101   unsigned long n_value;
00102 };
00103 #endif /* no N_NLIST_DECLARED.  */
00104 
00105 #define N_UNDF       0
00106 #define N_ABS 2
00107 #define N_TEXT       4
00108 #define N_DATA       6
00109 #define N_BSS 8
00110 #define N_FN  15
00111 #define N_EXT 1
00112 #define N_TYPE       036
00113 #define N_STAB       0340
00114 #define N_INDR       0xa
00115 #define       N_SETA 0x14   /* Absolute set element symbol.  */
00116 #define       N_SETT 0x16   /* Text set element symbol.  */
00117 #define       N_SETD 0x18   /* Data set element symbol.  */
00118 #define       N_SETB 0x1A   /* Bss set element symbol.  */
00119 #define N_SETV       0x1C   /* Pointer to set vector in data area.  */
00120 
00121 #if !defined (N_RELOCATION_INFO_DECLARED)
00122 /* This structure describes a single relocation to be performed.
00123    The text-relocation section of the file is a vector of these structures,
00124    all of which apply to the text section.
00125    Likewise, the data-relocation section applies to the data section.  */
00126 
00127 struct relocation_info
00128 {
00129   int r_address;
00130   unsigned int r_symbolnum:24;
00131   unsigned int r_pcrel:1;
00132   unsigned int r_length:2;
00133   unsigned int r_extern:1;
00134   unsigned int r_pad:4;
00135 };
00136 #endif /* no N_RELOCATION_INFO_DECLARED.  */
00137 
00138 #endif /* __A_OUT_GNU_H__ */