BSD 4_3_Reno release
[unix-history] / usr / include / a.out.h
index 538c822..5de9d9f 100644 (file)
@@ -1,56 +1,91 @@
 /*
 /*
- * Format of an a.out header
- */
-struct exec {  /* a.out header */
-       int             a_magic;        /* magic number */
-       unsigned        a_text;         /* size of text segment */
-       unsigned        a_data;         /* size of initialized data */
-       unsigned        a_bss;          /* size of uninitialized data */
-       unsigned        a_syms;         /* size of symbol table */
-       unsigned        a_entry;        /* entry point */
-       unsigned        a_trsize;       /* size of text relocation */
-       unsigned        a_drsize;       /* size of data relocation */
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)a.out.h     5.3 (Berkeley) 6/24/90
+ */
+
+/*
+ * Definitions of the a.out header
+ * and magic numbers are shared with
+ * the kernel.
+ */
+#include <sys/exec.h>
+
+/*
+ * Macros which take exec structures as arguments and tell whether
+ * the file has a reasonable magic number or offsets to text|symbols|strings.
+ */
+#define        N_BADMAG(x) \
+    (((x).a_magic)!=OMAGIC && ((x).a_magic)!=NMAGIC && ((x).a_magic)!=ZMAGIC)
+
+#if defined(vax) || defined(tahoe)
+#define        N_TXTOFF(x) \
+       ((x).a_magic == ZMAGIC ? 1024 : sizeof (struct exec))
+#endif
+
+#if defined(hp300)
+#define        N_TXTOFF(x) \
+       ((x).a_magic == ZMAGIC ? 4096 : sizeof (struct exec))
+#endif
+
+#define N_SYMOFF(x) \
+       (N_TXTOFF(x) + (x).a_text+(x).a_data + (x).a_trsize+(x).a_drsize)
+
+#define        N_STROFF(x) \
+       (N_SYMOFF(x) + (x).a_syms)
+
+/*
+ * Format of a relocation datum.
+ */
+struct relocation_info {
+       int     r_address;      /* address which is relocated */
+unsigned int   r_symbolnum:24, /* local symbol ordinal */
+               r_pcrel:1,      /* was relocated pc relative already */
+               r_length:2,     /* 0=byte, 1=word, 2=long */
+               r_extern:1,     /* does not include value of sym referenced */
+               :4;             /* nothing, yet */
 };
 
 };
 
-#define        A_MAGIC1        0407            /* normal */
-#define        A_MAGIC2        0410            /* read-only text */
-#define        A_MAGIC3        0411            /* separated I&D */
-#define        A_MAGIC4        0405            /* overlay */
-
-struct nlist { /* symbol table entry */
-       char    n_name[8];      /* symbol name */
-       char    n_type;         /* type flag */
-       char    n_other;
-       short   n_desc;
-       unsigned n_value;       /* value */
+/*
+ * Format of a symbol table entry; this file is included by <a.out.h>
+ * and should be used if you aren't interested the a.out header
+ * or relocation information.
+ */
+struct nlist {
+       union {
+               char    *n_name;        /* for use when in-core */
+               long    n_strx;         /* index into file string table */
+       } n_un;
+unsigned char  n_type;         /* type flag, i.e. N_TEXT etc; see below */
+       char    n_other;        /* unused */
+       short   n_desc;         /* see <stab.h> */
+unsigned long  n_value;        /* value of this symbol (or sdb offset) */
 };
 };
+#define        n_hash  n_desc          /* used internally by ld */
 
 
-       /* values for type flag */
-#define        N_UNDF  0               /* undefined */
-#define        N_ABS   02              /* absolute */
-#define        N_TEXT  04              /* text */
-#define        N_DATA  06              /* data */
-#define        N_BSS   08
-#define        N_TYPE  037
-#define        N_FN    037             /* file name symbol */
-
-#define        N_GSYM  0040            /* global sym: name,,type,0 */
-#define        N_FUN   0044            /* function: name,,linenumber,address */
-#define        N_STSYM 0046            /* static symbol: name,,type,address */
-#define        N_RSYM  0100            /* register sym: name,,register,offset */
-#define        N_SLINE 0104            /* src line: ,,linenumber,address */
-#define        N_SSYM  0140            /* structure elt: name,,type,struct_offset */
-#define        N_SO    0144            /* source file name: name,,,address */
-#define        N_LSYM  0200            /* local sym: name,,type,offset */
-#define        N_SOL   0204            /* #line source filename: name,,,address */
-#define        N_PSYM  0240            /* parameter: name,,type,offset */
-#define        N_LBRAC 0300            /* left bracket: ,,nesting level,address */
-#define        N_RBRAC 0340            /* right bracket: ,,nesting level,address */
-#define        N_LENG  0376            /* second stab entry with length information */
+/*
+ * Simple values for n_type.
+ */
+#define        N_UNDF  0x0             /* undefined */
+#define        N_ABS   0x2             /* absolute */
+#define        N_TEXT  0x4             /* text */
+#define        N_DATA  0x6             /* data */
+#define        N_BSS   0x8             /* bss */
+#define        N_COMM  0x12            /* common (internal to ld) */
+#define        N_FN    0x1e            /* file name symbol */
 
 #define        N_EXT   01              /* external bit, or'ed in */
 
 #define        N_EXT   01              /* external bit, or'ed in */
+#define        N_TYPE  0x1e            /* mask for all the type bits */
 
 
-#define        FORMAT  "%08x"
+/*
+ * Sdb entries have some of the N_STAB bits set.
+ * These are given in <stab.h>
+ */
+#define        N_STAB  0xe0            /* if any of these bits set, a SDB entry */
 
 
-#define        STABTYPES       0340
+/*
+ * Format for namelist values.
+ */
+#define        N_FORMAT        "%08x"