a.out.h
来自「TCP-IP红宝书源代码」· C头文件 代码 · 共 146 行
H
146 行
/*
* format of the exec header
* known by kernel and by user programs
*/
struct exec {
unsigned short a_machtype; /* machine type */
unsigned short a_magic; /* magic number */
unsigned long a_text; /* size of text segment */
unsigned long a_data; /* size of initialized data */
unsigned long a_bss; /* size of uninitialized data */
unsigned long a_syms; /* size of symbol table */
unsigned long a_entry; /* entry point */
unsigned long a_trsize; /* size of text relocation */
unsigned long a_drsize; /* size of data relocation */
};
#define OMAGIC 0407 /* old impure format */
#define NMAGIC 0410 /* read-only text */
#define ZMAGIC 0413 /* demand load format */
/* machine types */
#define M_OLDSUN2 0 /* old sun-2 executable files */
#define M_68010 1 /* runs on either 68010 or 68020 */
#define M_68020 2 /* runs only on 68020 */
/*
* memory management parameters
*/
#define PAGSIZ 0x2000
#define SEGSIZ 0x20000
#define OLD_PAGSIZ 0x800 /* THIS DISAPPEARS IN RELEASE 4.0 */
#define OLD_SEGSIZ 0x8000 /* THIS DISAPPEARS IN RELEASE 4.0 */
/*
* returns 1 if an object file type is invalid, i.e., if the other macros
* defined below will not yield the correct offsets. Note that a file may
* have N_BADMAG(x) = 0 and may be fully linked, but still may not be
* executable.
*/
#define N_BADMAG(x) \
((x).a_magic!=OMAGIC && (x).a_magic!=NMAGIC && (x).a_magic!=ZMAGIC)
/*
* relocation parameters. These are architecture-dependent
* and can be deduced from the machine type. They are used
* to calculate offsets of segments within the object file;
* See N_TXTOFF(x), etc. below.
*/
#define N_PAGSIZ(x) \
((x).a_machtype == M_OLDSUN2? OLD_PAGSIZ : PAGSIZ)
#define N_SEGSIZ(x) \
((x).a_machtype == M_OLDSUN2? OLD_SEGSIZ : SEGSIZ)
/*
* offsets of various sections of an object file.
*/
#define N_TXTOFF(x) \
/* text segment */ \
( (x).a_machtype == M_OLDSUN2 \
? ((x).a_magic==ZMAGIC ? N_PAGSIZ(x) : sizeof (struct exec)) \
: ((x).a_magic==ZMAGIC ? 0 : sizeof (struct exec)) )
#define N_SYMOFF(x) \
/* symbol table */ \
(N_TXTOFF(x)+(x).a_text+(x).a_data+(x).a_trsize+(x).a_drsize)
#define N_STROFF(x) \
/* string table */ \
(N_SYMOFF(x) + (x).a_syms)
/*
* Macros which take exec structures as arguments and tell where the
* various pieces will be loaded.
*/
#define N_TXTADDR(x) \
((x).a_machtype == M_OLDSUN2? N_SEGSIZ(x) : N_PAGSIZ(x))
#define N_DATADDR(x) \
(((x).a_magic==OMAGIC)? (N_TXTADDR(x)+(x).a_text) \
: (N_SEGSIZ(x)+((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZ(x)-1))))
#define N_BSSADDR(x) (N_DATADDR(x)+(x).a_data)
/*
* Format of a relocation datum.
*/
struct relocation_info {
long 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 */
};
/*
* Format of a symbol table entry
*/
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 (N_TEXT,..) */
char n_other; /* unused */
short n_desc; /* see <stab.h> */
unsigned long n_value; /* value of symbol (or sdb offset) */
};
/*
* 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 0x1f /* file name symbol */
#define N_EXT 01 /* external bit, or'ed in */
#define N_TYPE 0x1e /* mask for all the type bits */
/*
* Dbx 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 dbx symbol */
/*
* Format for namelist values.
*/
#define N_FORMAT "%08x"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?