1 /* Copyright (C) 1990-1996
2 * This file is part of the ld86 command for Linux-86
3 * It is distributed under the GNU Library General Public License.
5 * - This may actually be BSD or Minix code, can someone clarify please. -RDB
11 /* If the host isn't an x86 all bets are off, use chars. */
12 #if defined(i386) || defined(__BCC__) || defined(MSDOS)
19 struct exec
{ /* a.out header */
20 unsigned char a_magic
[2]; /* magic number */
21 unsigned char a_flags
; /* flags, see below */
22 unsigned char a_cpu
; /* cpu id */
23 unsigned char a_hdrlen
; /* length of header */
24 unsigned char a_unused
; /* reserved for future use */
25 unsigned char a_version
[2]; /* version stamp (not used at present) */
26 Long a_text
; /* size of text segement in bytes */
27 Long a_data
; /* size of data segment in bytes */
28 Long a_bss
; /* size of bss segment in bytes */
29 Long a_entry
; /* entry point */
30 Long a_total
; /* total memory allocated */
31 Long a_syms
; /* size of symbol table */
33 /* SHORT FORM ENDS HERE */
34 Long a_trsize
; /* text relocation size */
35 Long a_drsize
; /* data relocation size */
36 Long a_tbase
; /* text relocation base */
37 Long a_dbase
; /* data relocation base */
40 #define A_MAGIC0 (unsigned char) 0x01
41 #define A_MAGIC1 (unsigned char) 0x03
42 #define BADMAG(X) ((X).a_magic[0] != A_MAGIC0 ||(X).a_magic[1] != A_MAGIC1)
44 /* CPU Id of TARGET machine (byte order coded in low order two bits) */
45 #define A_NONE 0x00 /* unknown */
46 #define A_I8086 0x04 /* intel i8086/8088 */
47 #define A_M68K 0x0B /* motorola m68000 */
48 #define A_NS16K 0x0C /* national semiconductor 16032 */
49 #define A_I80386 0x10 /* intel i80386 */
50 #define A_SPARC 0x17 /* Sun SPARC */
52 #define A_BLR(cputype) ((cputype&0x01)!=0) /* TRUE if bytes left-to-right */
53 #define A_WLR(cputype) ((cputype&0x02)!=0) /* TRUE if words left-to-right */
56 #define A_UZP 0x01 /* unmapped zero page (pages) */
57 #define A_PAL 0x02 /* page aligned executable */
58 #define A_NSYM 0x04 /* new style symbol table */
59 #define A_EXEC 0x10 /* executable */
60 #define A_SEP 0x20 /* separate I/D */
61 #define A_PURE 0x40 /* pure text */
62 #define A_TOVLY 0x80 /* text overlay */
64 /* Offsets of various things. */
66 #define A_TEXTPOS(X) ((long)(X).a_hdrlen)
67 #define A_HASRELS(X) ((X).a_hdrlen > (unsigned char) A_MINHDR)
68 #define A_HASEXT(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 8))
69 #define A_HASLNS(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 16))
70 #define A_HASTOFF(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 24))
72 #define A_DATAPOS(X) (A_TEXTPOS(X) + (X).a_text)
73 #define A_TRELPOS(X) (A_DATAPOS(X) + (X).a_data)
74 #define A_DRELPOS(X) (A_TRELPOS(X) + (X).a_trsize)
75 #define A_SYMPOS(X) (A_TRELPOS(X) + (A_HASRELS(X) ? \
76 ((X).a_trsize + (X).a_drsize) : 0))
80 long r_vaddr
; /* virtual address of reference */
81 unsigned short r_symndx
; /* internal segnum or extern symbol num */
82 unsigned short r_type
; /* relocation type */
96 /* r_symndx for internal segments */
97 #define S_ABS ((unsigned short)-1)
98 #define S_TEXT ((unsigned short)-2)
99 #define S_DATA ((unsigned short)-3)
100 #define S_BSS ((unsigned short)-4)
102 struct nlist
{ /* symbol table entry */
103 char n_name
[8]; /* symbol name */
104 Long n_value
; /* value */
105 unsigned char n_sclass
; /* storage class */
106 unsigned char n_numaux
; /* number of auxiliary entries (not used) */
107 unsigned short n_type
; /* language base and derived type (not used) */
110 /* Low bits of storage class (section). */
111 #define N_SECT 07 /* section mask */
112 #define N_UNDF 00 /* undefined */
113 #define N_ABS 01 /* absolute */
114 #define N_TEXT 02 /* text */
115 #define N_DATA 03 /* data */
116 #define N_BSS 04 /* bss */
117 #define N_COMM 05 /* (common) */
119 /* High bits of storage class. */
120 #define N_CLASS 0370 /* storage class mask */
122 #define C_EXT 0020 /* external symbol */
123 #define C_STAT 0030 /* static */