Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _UAPI__A_OUT_GNU_H__
0003 #define _UAPI__A_OUT_GNU_H__
0004 
0005 #define __GNU_EXEC_MACROS__
0006 
0007 #ifndef __STRUCT_EXEC_OVERRIDE__
0008 
0009 #include <asm/a.out.h>
0010 
0011 #endif /* __STRUCT_EXEC_OVERRIDE__ */
0012 
0013 #ifndef __ASSEMBLY__
0014 
0015 /* these go in the N_MACHTYPE field */
0016 enum machine_type {
0017 #if defined (M_OLDSUN2)
0018   M__OLDSUN2 = M_OLDSUN2,
0019 #else
0020   M_OLDSUN2 = 0,
0021 #endif
0022 #if defined (M_68010)
0023   M__68010 = M_68010,
0024 #else
0025   M_68010 = 1,
0026 #endif
0027 #if defined (M_68020)
0028   M__68020 = M_68020,
0029 #else
0030   M_68020 = 2,
0031 #endif
0032 #if defined (M_SPARC)
0033   M__SPARC = M_SPARC,
0034 #else
0035   M_SPARC = 3,
0036 #endif
0037   /* skip a bunch so we don't run into any of sun's numbers */
0038   M_386 = 100,
0039   M_MIPS1 = 151,    /* MIPS R3000/R3000 binary */
0040   M_MIPS2 = 152     /* MIPS R6000/R4000 binary */
0041 };
0042 
0043 #if !defined (N_MAGIC)
0044 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
0045 #endif
0046 #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
0047 #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
0048 #define N_SET_INFO(exec, magic, type, flags) \
0049     ((exec).a_info = ((magic) & 0xffff) \
0050      | (((int)(type) & 0xff) << 16) \
0051      | (((flags) & 0xff) << 24))
0052 #define N_SET_MAGIC(exec, magic) \
0053     ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
0054 
0055 #define N_SET_MACHTYPE(exec, machtype) \
0056     ((exec).a_info = \
0057      ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
0058 
0059 #define N_SET_FLAGS(exec, flags) \
0060     ((exec).a_info = \
0061      ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
0062 
0063 /* Code indicating object file or impure executable.  */
0064 #define OMAGIC 0407
0065 /* Code indicating pure executable.  */
0066 #define NMAGIC 0410
0067 /* Code indicating demand-paged executable.  */
0068 #define ZMAGIC 0413
0069 /* This indicates a demand-paged executable with the header in the text. 
0070    The first page is unmapped to help trap NULL pointer references */
0071 #define QMAGIC 0314
0072 
0073 /* Code indicating core file.  */
0074 #define CMAGIC 0421
0075 
0076 #if !defined (N_BADMAG)
0077 #define N_BADMAG(x)   (N_MAGIC(x) != OMAGIC     \
0078             && N_MAGIC(x) != NMAGIC     \
0079             && N_MAGIC(x) != ZMAGIC \
0080                 && N_MAGIC(x) != QMAGIC)
0081 #endif
0082 
0083 #define _N_HDROFF(x) (1024 - sizeof (struct exec))
0084 
0085 #if !defined (N_TXTOFF)
0086 #define N_TXTOFF(x) \
0087  (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
0088   (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
0089 #endif
0090 
0091 #if !defined (N_DATOFF)
0092 #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
0093 #endif
0094 
0095 #if !defined (N_TRELOFF)
0096 #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
0097 #endif
0098 
0099 #if !defined (N_DRELOFF)
0100 #define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
0101 #endif
0102 
0103 #if !defined (N_SYMOFF)
0104 #define N_SYMOFF(x) (N_DRELOFF(x) + N_DRSIZE(x))
0105 #endif
0106 
0107 #if !defined (N_STROFF)
0108 #define N_STROFF(x) (N_SYMOFF(x) + N_SYMSIZE(x))
0109 #endif
0110 
0111 /* Address of text segment in memory after it is loaded.  */
0112 #if !defined (N_TXTADDR)
0113 #define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)
0114 #endif
0115 
0116 /* Address of data segment in memory after it is loaded. */
0117 #ifndef __KERNEL__
0118 #include <unistd.h>
0119 #endif
0120 #if defined(__i386__) || defined(__mc68000__)
0121 #define SEGMENT_SIZE    1024
0122 #else
0123 #ifndef SEGMENT_SIZE
0124 #ifndef __KERNEL__
0125 #define SEGMENT_SIZE   getpagesize()
0126 #endif
0127 #endif
0128 #endif
0129 
0130 #define _N_SEGMENT_ROUND(x) ALIGN(x, SEGMENT_SIZE)
0131 
0132 #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
0133 
0134 #ifndef N_DATADDR
0135 #define N_DATADDR(x) \
0136     (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
0137      : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
0138 #endif
0139 
0140 /* Address of bss segment in memory after it is loaded.  */
0141 #if !defined (N_BSSADDR)
0142 #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
0143 #endif
0144 
0145 #if !defined (N_NLIST_DECLARED)
0146 struct nlist {
0147   union {
0148     char *n_name;
0149     struct nlist *n_next;
0150     long n_strx;
0151   } n_un;
0152   unsigned char n_type;
0153   char n_other;
0154   short n_desc;
0155   unsigned long n_value;
0156 };
0157 #endif /* no N_NLIST_DECLARED.  */
0158 
0159 #if !defined (N_UNDF)
0160 #define N_UNDF 0
0161 #endif
0162 #if !defined (N_ABS)
0163 #define N_ABS 2
0164 #endif
0165 #if !defined (N_TEXT)
0166 #define N_TEXT 4
0167 #endif
0168 #if !defined (N_DATA)
0169 #define N_DATA 6
0170 #endif
0171 #if !defined (N_BSS)
0172 #define N_BSS 8
0173 #endif
0174 #if !defined (N_FN)
0175 #define N_FN 15
0176 #endif
0177 
0178 #if !defined (N_EXT)
0179 #define N_EXT 1
0180 #endif
0181 #if !defined (N_TYPE)
0182 #define N_TYPE 036
0183 #endif
0184 #if !defined (N_STAB)
0185 #define N_STAB 0340
0186 #endif
0187 
0188 /* The following type indicates the definition of a symbol as being
0189    an indirect reference to another symbol.  The other symbol
0190    appears as an undefined reference, immediately following this symbol.
0191 
0192    Indirection is asymmetrical.  The other symbol's value will be used
0193    to satisfy requests for the indirect symbol, but not vice versa.
0194    If the other symbol does not have a definition, libraries will
0195    be searched to find a definition.  */
0196 #define N_INDR 0xa
0197 
0198 /* The following symbols refer to set elements.
0199    All the N_SET[ATDB] symbols with the same name form one set.
0200    Space is allocated for the set in the text section, and each set
0201    element's value is stored into one word of the space.
0202    The first word of the space is the length of the set (number of elements).
0203 
0204    The address of the set is made into an N_SETV symbol
0205    whose name is the same as the name of the set.
0206    This symbol acts like a N_DATA global symbol
0207    in that it can satisfy undefined external references.  */
0208 
0209 /* These appear as input to LD, in a .o file.  */
0210 #define N_SETA  0x14        /* Absolute set element symbol */
0211 #define N_SETT  0x16        /* Text set element symbol */
0212 #define N_SETD  0x18        /* Data set element symbol */
0213 #define N_SETB  0x1A        /* Bss set element symbol */
0214 
0215 /* This is output from LD.  */
0216 #define N_SETV  0x1C        /* Pointer to set vector in data area.  */
0217 
0218 #if !defined (N_RELOCATION_INFO_DECLARED)
0219 /* This structure describes a single relocation to be performed.
0220    The text-relocation section of the file is a vector of these structures,
0221    all of which apply to the text section.
0222    Likewise, the data-relocation section applies to the data section.  */
0223 
0224 struct relocation_info
0225 {
0226   /* Address (within segment) to be relocated.  */
0227   int r_address;
0228   /* The meaning of r_symbolnum depends on r_extern.  */
0229   unsigned int r_symbolnum:24;
0230   /* Nonzero means value is a pc-relative offset
0231      and it should be relocated for changes in its own address
0232      as well as for changes in the symbol or section specified.  */
0233   unsigned int r_pcrel:1;
0234   /* Length (as exponent of 2) of the field to be relocated.
0235      Thus, a value of 2 indicates 1<<2 bytes.  */
0236   unsigned int r_length:2;
0237   /* 1 => relocate with value of symbol.
0238           r_symbolnum is the index of the symbol
0239       in file's the symbol table.
0240      0 => relocate with the address of a segment.
0241           r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
0242       (the N_EXT bit may be set also, but signifies nothing).  */
0243   unsigned int r_extern:1;
0244   /* Four bits that aren't used, but when writing an object file
0245      it is desirable to clear them.  */
0246   unsigned int r_pad:4;
0247 };
0248 #endif /* no N_RELOCATION_INFO_DECLARED.  */
0249 
0250 #endif /*__ASSEMBLY__ */
0251 #endif /* _UAPI__A_OUT_GNU_H__ */