source: branches/minix3-book/include/a.out.h@ 11

Last change on this file since 11 was 4, checked in by Mattia Monga, 14 years ago

Importazione sorgenti libro

File size: 4.0 KB
Line 
1/* The <a.out> header file describes the format of executable files. */
2
3#ifndef _AOUT_H
4#define _AOUT_H
5
6struct exec { /* a.out header */
7 unsigned char a_magic[2]; /* magic number */
8 unsigned char a_flags; /* flags, see below */
9 unsigned char a_cpu; /* cpu id */
10 unsigned char a_hdrlen; /* length of header */
11 unsigned char a_unused; /* reserved for future use */
12 unsigned short a_version; /* version stamp (not used at present) */
13 long a_text; /* size of text segement in bytes */
14 long a_data; /* size of data segment in bytes */
15 long a_bss; /* size of bss segment in bytes */
16 long a_entry; /* entry point */
17 long a_total; /* total memory allocated */
18 long a_syms; /* size of symbol table */
19
20 /* SHORT FORM ENDS HERE */
21 long a_trsize; /* text relocation size */
22 long a_drsize; /* data relocation size */
23 long a_tbase; /* text relocation base */
24 long a_dbase; /* data relocation base */
25};
26
27#define A_MAGIC0 (unsigned char) 0x01
28#define A_MAGIC1 (unsigned char) 0x03
29#define BADMAG(X) ((X).a_magic[0] != A_MAGIC0 ||(X).a_magic[1] != A_MAGIC1)
30
31/* CPU Id of TARGET machine (byte order coded in low order two bits) */
32#define A_NONE 0x00 /* unknown */
33#define A_I8086 0x04 /* intel i8086/8088 */
34#define A_M68K 0x0B /* motorola m68000 */
35#define A_NS16K 0x0C /* national semiconductor 16032 */
36#define A_I80386 0x10 /* intel i80386 */
37#define A_SPARC 0x17 /* Sun SPARC */
38
39#define A_BLR(cputype) ((cputype&0x01)!=0) /* TRUE if bytes left-to-right */
40#define A_WLR(cputype) ((cputype&0x02)!=0) /* TRUE if words left-to-right */
41
42/* Flags. */
43#define A_UZP 0x01 /* unmapped zero page (pages) */
44#define A_PAL 0x02 /* page aligned executable */
45#define A_NSYM 0x04 /* new style symbol table */
46#define A_IMG 0x08 /* image instead of executable (e.g. root FS) */
47#define A_EXEC 0x10 /* executable */
48#define A_SEP 0x20 /* separate I/D */
49#define A_PURE 0x40 /* pure text */ /* not used */
50#define A_TOVLY 0x80 /* text overlay */ /* not used */
51
52/* Offsets of various things. */
53#define A_MINHDR 32
54#define A_TEXTPOS(X) ((long)(X).a_hdrlen)
55#define A_DATAPOS(X) (A_TEXTPOS(X) + (X).a_text)
56#define A_HASRELS(X) ((X).a_hdrlen > (unsigned char) A_MINHDR)
57#define A_HASEXT(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 8))
58#define A_HASLNS(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 16))
59#define A_HASTOFF(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 24))
60#define A_TRELPOS(X) (A_DATAPOS(X) + (X).a_data)
61#define A_DRELPOS(X) (A_TRELPOS(X) + (X).a_trsize)
62#define A_SYMPOS(X) (A_TRELPOS(X) + (A_HASRELS(X) ? \
63 ((X).a_trsize + (X).a_drsize) : 0))
64
65struct reloc {
66 long r_vaddr; /* virtual address of reference */
67 unsigned short r_symndx; /* internal segnum or extern symbol num */
68 unsigned short r_type; /* relocation type */
69};
70
71/* r_tyep values: */
72#define R_ABBS 0
73#define R_RELLBYTE 2
74#define R_PCRBYTE 3
75#define R_RELWORD 4
76#define R_PCRWORD 5
77#define R_RELLONG 6
78#define R_PCRLONG 7
79#define R_REL3BYTE 8
80#define R_KBRANCHE 9
81
82/* r_symndx for internal segments */
83#define S_ABS ((unsigned short)-1)
84#define S_TEXT ((unsigned short)-2)
85#define S_DATA ((unsigned short)-3)
86#define S_BSS ((unsigned short)-4)
87
88struct nlist { /* symbol table entry */
89 char n_name[8]; /* symbol name */
90 long n_value; /* value */
91 unsigned char n_sclass; /* storage class */
92 unsigned char n_numaux; /* number of auxiliary entries (not used) */
93 unsigned short n_type; /* language base and derived type (not used) */
94};
95
96/* Low bits of storage class (section). */
97#define N_SECT 07 /* section mask */
98#define N_UNDF 00 /* undefined */
99#define N_ABS 01 /* absolute */
100#define N_TEXT 02 /* text */
101#define N_DATA 03 /* data */
102#define N_BSS 04 /* bss */
103#define N_COMM 05 /* (common) */
104
105/* High bits of storage class. */
106#define N_CLASS 0370 /* storage class mask */
107#define C_NULL
108#define C_EXT 0020 /* external symbol */
109#define C_STAT 0030 /* static */
110
111/* Function prototypes. */
112#ifndef _ANSI_H
113#include <ansi.h>
114#endif
115
116_PROTOTYPE( int nlist, (char *_file, struct nlist *_nl) );
117
118#endif /* _AOUT_H */
Note: See TracBrowser for help on using the repository browser.