(root)/
glibc-2.38/
sysdeps/
unix/
sysv/
linux/
sparc/
a.out.h
       1  #ifndef __A_OUT_GNU_H__
       2  #define __A_OUT_GNU_H__
       3  
       4  #include <bits/a.out.h>
       5  
       6  #define __GNU_EXEC_MACROS__
       7  
       8  struct exec
       9  {
      10    unsigned char a_dynamic:1;	/* A __DYNAMIC is in this image.  */
      11    unsigned char a_toolversion:7;
      12    unsigned char a_machtype;
      13    unsigned short a_info;
      14    unsigned int a_text;		/* Length of text, in bytes.  */
      15    unsigned int a_data;		/* Length of data, in bytes.  */
      16    unsigned int a_bss;		/* Length of bss, in bytes.  */
      17    unsigned int a_syms;		/* Length of symbol table, in bytes.  */
      18    unsigned int a_entry;		/* Where program begins.  */
      19    unsigned int a_trsize;
      20    unsigned int a_drsize;
      21  };
      22  
      23  enum machine_type
      24  {
      25    M_OLDSUN2 = 0,
      26    M_68010 = 1,
      27    M_68020 = 2,
      28    M_SPARC = 3,
      29    M_386 = 100,
      30    M_MIPS1 = 151,
      31    M_MIPS2 = 152
      32  };
      33  
      34  #define N_MAGIC(exec)	((exec).a_info & 0xffff)
      35  #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
      36  #define N_FLAGS(exec)	(((exec).a_info >> 24) & 0xff)
      37  #define N_SET_INFO(exec, magic, type, flags) \
      38    ((exec).a_info = ((magic) & 0xffff)					\
      39     | (((int)(type) & 0xff) << 16)					\
      40     | (((flags) & 0xff) << 24))
      41  #define N_SET_MAGIC(exec, magic) \
      42    ((exec).a_info = ((exec).a_info & 0xffff0000) | ((magic) & 0xffff))
      43  #define N_SET_MACHTYPE(exec, machtype) \
      44    ((exec).a_info =							\
      45     ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
      46  #define N_SET_FLAGS(exec, flags) \
      47    ((exec).a_info =							\
      48     ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
      49  
      50  /* Code indicating object file or impure executable.  */
      51  #define OMAGIC 0407
      52  /* Code indicating pure executable.  */
      53  #define NMAGIC 0410
      54  /* Code indicating demand-paged executable.  */
      55  #define ZMAGIC 0413
      56  /* This indicates a demand-paged executable with the header in the text.
      57     The first page is unmapped to help trap NULL pointer references.  */
      58  #define QMAGIC 0314
      59  /* Code indicating core file.  */
      60  #define CMAGIC 0421
      61  
      62  #define N_TRSIZE(a)	((a).a_trsize)
      63  #define N_DRSIZE(a)	((a).a_drsize)
      64  #define N_SYMSIZE(a)	((a).a_syms)
      65  #define N_BADMAG(x) \
      66    (N_MAGIC(x) != OMAGIC	&& N_MAGIC(x) != NMAGIC				\
      67     && N_MAGIC(x) != ZMAGIC && N_MAGIC(x) != QMAGIC)
      68  #define _N_HDROFF(x)	(1024 - sizeof (struct exec))
      69  #define N_TXTOFF(x) \
      70    (N_MAGIC(x) == ZMAGIC ? 0 : sizeof (struct exec))
      71  #define N_DATOFF(x)	(N_TXTOFF(x) + (x).a_text)
      72  #define N_TRELOFF(x)	(N_DATOFF(x) + (x).a_data)
      73  #define N_DRELOFF(x)	(N_TRELOFF(x) + N_TRSIZE(x))
      74  #define N_SYMOFF(x) \
      75    (N_TXTOFF(x) + (x).a_text + (x).a_data + (x).a_trsize + (x).a_drsize)
      76  #define N_STROFF(x)	(N_SYMOFF(x) + N_SYMSIZE(x))
      77  
      78  #define SPARC_PGSIZE	0x2000
      79  
      80  /* Address of text segment in memory after it is loaded.  */
      81  #define N_TXTADDR(x) \
      82   (unsigned long)(((N_MAGIC(x) == ZMAGIC) && ((x).a_entry < SPARC_PGSIZE)) \
      83  		 ? 0 : SPARC_PGSIZE)
      84  
      85  /* Address of data segment in memory after it is loaded.  */
      86  #define SEGMENT_SIZE	SPARC_PGSIZE
      87  
      88  #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
      89  #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
      90  
      91  #define N_DATADDR(x) \
      92    (N_MAGIC(x)==OMAGIC							\
      93     ? (N_TXTADDR(x) + (x).a_text)					\
      94     : (unsigned long)(_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
      95  #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
      96  
      97  #if !defined (N_NLIST_DECLARED)
      98  struct nlist
      99  {
     100    union
     101      {
     102        char *n_name;
     103        struct nlist *n_next;
     104        long n_strx;
     105      } n_un;
     106    unsigned char n_type;
     107    char n_other;
     108    short n_desc;
     109    unsigned long n_value;
     110  };
     111  #endif /* no N_NLIST_DECLARED.  */
     112  
     113  #define N_UNDF	0
     114  #define N_ABS	2
     115  #define N_TEXT	4
     116  #define N_DATA	6
     117  #define N_BSS	8
     118  #define N_FN	15
     119  #define N_EXT	1
     120  #define N_TYPE	036
     121  #define N_STAB	0340
     122  #define N_INDR	0xa
     123  #define	N_SETA	0x14	/* Absolute set element symbol.  */
     124  #define	N_SETT	0x16	/* Text set element symbol.  */
     125  #define	N_SETD	0x18	/* Data set element symbol.  */
     126  #define	N_SETB	0x1A	/* Bss set element symbol.  */
     127  #define N_SETV	0x1C	/* Pointer to set vector in data area.  */
     128  
     129  #if !defined (N_RELOCATION_INFO_DECLARED)
     130  enum reloc_type
     131  {
     132    RELOC_8,
     133    RELOC_16,
     134    RELOC_32,
     135    RELOC_DISP8,
     136    RELOC_DISP16,
     137    RELOC_DISP32,
     138    RELOC_WDISP30,
     139    RELOC_WDISP22,
     140    RELOC_HI22,
     141    RELOC_22,
     142    RELOC_13,
     143    RELOC_LO10,
     144    RELOC_SFA_BASE,
     145    RELOC_SFA_OFF13,
     146    RELOC_BASE10,
     147    RELOC_BASE13,
     148    RELOC_BASE22,
     149    RELOC_PC10,
     150    RELOC_PC22,
     151    RELOC_JMP_TBL,
     152    RELOC_SEGOFF16,
     153    RELOC_GLOB_DAT,
     154    RELOC_JMP_SLOT,
     155    RELOC_RELATIVE
     156  };
     157  
     158  /* This structure describes a single relocation to be performed.
     159     The text-relocation section of the file is a vector of these structures,
     160     all of which apply to the text section.
     161     Likewise, the data-relocation section applies to the data section.  */
     162  
     163  struct relocation_info
     164  {
     165    unsigned int r_address;
     166    unsigned int r_index:24;
     167    unsigned int r_extern:1;
     168    int r_pad:2;
     169    enum reloc_type r_type:5;
     170    int r_addend;
     171  };
     172  #endif /* no N_RELOCATION_INFO_DECLARED.  */
     173  
     174  #endif /* __A_OUT_GNU_H__ */