153006Sbostic /*- 2*63217Sbostic * Copyright (c) 1992, 1993 3*63217Sbostic * The Regents of the University of California. All rights reserved. 453006Sbostic * 553006Sbostic * %sccs.include.redist.c% 653006Sbostic * 7*63217Sbostic * @(#)exec.h 8.1 (Berkeley) 06/10/93 853006Sbostic */ 953006Sbostic 1057867Sralph #include <machine/endian.h> 1153006Sbostic 1253006Sbostic /* Size of a page in an object file. */ 1353006Sbostic #define __LDPGSZ 4096 1453006Sbostic 1553006Sbostic /* Valid magic number check. */ 1653006Sbostic #define N_BADMAG(ex) \ 1753006Sbostic ((ex).a_magic != NMAGIC && (ex).a_magic != OMAGIC && \ 1853006Sbostic (ex).a_magic != ZMAGIC) 1953006Sbostic 2053006Sbostic /* Address of the bottom of the text segment. */ 2157867Sralph #define N_TXTADDR(X) __LDPGSZ 2253006Sbostic 2353006Sbostic /* Address of the bottom of the data segment. */ 2457867Sralph #define N_DATADDR(ex) \ 2557867Sralph (N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text \ 2657867Sralph : __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1)))) 2753006Sbostic 2853006Sbostic /* Text segment offset. */ 2953006Sbostic #define N_TXTOFF(ex) \ 3057867Sralph ((ex).a_magic == ZMAGIC ? 0 : sizeof(struct exec)) 3153006Sbostic 3253006Sbostic /* Data segment offset. */ 3357867Sralph #define N_DATOFF(ex) \ 3457867Sralph (N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text : \ 3557867Sralph __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1)))) 3653006Sbostic 3753006Sbostic /* Symbol table offset. */ 3857867Sralph #define N_SYMOFF(ex) \ 3957867Sralph (N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \ 4057867Sralph (ex).a_drsize) 4153006Sbostic 4253006Sbostic /* String table offset. */ 4357867Sralph #define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms) 4453006Sbostic 4557867Sralph /* Description of the object file header (a.out format). */ 4657867Sralph struct exec { 4757867Sralph #if BYTE_ORDER == BIG_ENDIAN 4857867Sralph u_short a_mid; /* machine ID */ 4957867Sralph u_short a_magic; /* magic number */ 5057867Sralph #else 5157867Sralph u_short a_magic; /* magic number */ 5257867Sralph u_short a_mid; /* machine ID */ 5357867Sralph #endif 5453006Sbostic 5557867Sralph u_long a_text; /* text segment size */ 5657867Sralph u_long a_data; /* initialized data size */ 5757867Sralph u_long a_bss; /* uninitialized data size */ 5857867Sralph u_long a_syms; /* symbol table size */ 5957867Sralph u_long a_entry; /* entry point */ 6057867Sralph u_long a_trsize; /* text relocation size */ 6157867Sralph u_long a_drsize; /* data relocation size */ 6257867Sralph }; 6353006Sbostic 6457867Sralph #define a_machtype a_mid /* SUN compatibility */ 6553006Sbostic 6657867Sralph #define MID_ZERO 0 /* unknown - implementation dependent */ 6757867Sralph #define MID_SUN010 1 /* sun 68010/68020 binary */ 6857867Sralph #define MID_SUN020 2 /* sun 68020-only binary */ 6957867Sralph #define MID_SUN_SPARC 3 /* sparc binary */ 7057867Sralph #define MID_386 100 /* Intel 80386 binary */ 7157867Sralph #define MID_29K 101 /* AMD 29000 binary */ 7257867Sralph #define MID_MIPSI 151 /* MIPS R2000/R3000 binary */ 7357867Sralph #define MID_MIPSII 152 /* MIPS R4000 binary */ 7457867Sralph #define MID_HP200 200 /* hp200 (68010) BSD binary */ 7557867Sralph #define MID_HP300 300 /* hp300 (68020+68881) BSD binary */ 7657867Sralph #define MID_HPUX 0x20C /* hp200/300 HP-UX binary */ 7757867Sralph #define MID_HPUX800 0x20B /* hp800 HP-UX binary */ 7857867Sralph 7953006Sbostic #define OMAGIC 0407 /* old impure format */ 8053006Sbostic #define NMAGIC 0410 /* read-only text */ 8153006Sbostic #define ZMAGIC 0413 /* demand load format */ 82