1 /* 2 * Copyright (c) 1992 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This software was developed by the Computer Systems Engineering group 6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7 * contributed to Berkeley. 8 * 9 * All advertising materials mentioning features or use of this software 10 * must display the following acknowledgement: 11 * This product includes software developed by the University of 12 * California, Lawrence Berkeley Laboratories. 13 * 14 * %sccs.include.redist.c% 15 * 16 * @(#)exec.h 7.3 (Berkeley) 09/05/92 17 * 18 * from: $Header: exec.h,v 1.8 92/09/06 01:35:41 torek Exp $ 19 */ 20 21 /* 22 * __LDPGSZ is the page size used by the linker and by exec(). 23 * It may be some multiple of the ``normal'' page size, so that, e.g., 24 * the same binaries can be run on hardware with different page sizes 25 * that otherwise use the same instruction set. It must be no larger 26 * than CLBYTES (in param.h). 27 */ 28 #define __LDPGSZ 8192 29 30 /* Valid magic number check. */ 31 #define N_BADMAG(ex) \ 32 ((ex).a_magic != ZMAGIC && (ex).a_magic != NMAGIC && \ 33 (ex).a_magic != OMAGIC) 34 35 /* 36 * N_TXTADDR is the address of the first executable instruction: that is, 37 * the place the pc could begin after an a.out is loaded, in order to run 38 * the instructions in that a.out. The pc will actually be set to ex.a_entry 39 * but this is the first place it could possibly reference. 40 * 41 * On the SPARC, binaries begin at __LDPGSZ, i.e., page 1. 42 */ 43 #define N_TXTADDR(ex) 8192 44 45 /* Address of the bottom of the data segment. */ 46 #define N_DATADDR(ex) \ 47 (N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text : \ 48 (((ex).a_text + __LDPGSZ - 1) & ~(__LDPGSZ - 1)))) 49 50 /* 51 * N_TXTOFF is the offset within an a.out file of the first executable 52 * instruction: that is, the offset in the a.out of the byte that winds 53 * up at N_TXTADDR. 54 * 55 * On the SPARC, the a.out header is included in the executable when running 56 * a ZMAGIC file (but not for OMAGIC and NMAGIC). 57 */ 58 #define N_TXTOFF(ex) ((ex).a_magic == ZMAGIC ? 0 : sizeof(struct exec)) 59 60 /* Data segment offset. */ 61 #define N_DATOFF(ex) \ 62 (N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text : \ 63 (((ex).a_text + __LDPGSZ - 1) & ~(__LDPGSZ - 1)))) 64 65 /* Symbol table offset. */ 66 #define N_SYMOFF(ex) \ 67 (N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \ 68 (ex).a_drsize) 69 70 /* String table offset. */ 71 #define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms) 72 73 /* Description of the object file header (a.out format). */ 74 struct exec { 75 u_char a_dynamic:1; /* dynamically linked */ 76 u_char a_toolversion:7;/* Sun toolset version XXX */ 77 78 #define MID_ZERO 0 /* unknown - implementation dependent */ 79 #define MID_SUN010 1 /* sun 68010/68020 binary */ 80 #define MID_SUN020 2 /* sun 68020-only binary */ 81 #define MID_SUN_SPARC 3 /* sparc binary */ 82 #define MID_HP200 200 /* hp200 (68010) BSD binary */ 83 #define MID_HP300 300 /* hp300 (68020+68881) BSD binary */ 84 #define MID_HPUX 0x20C /* hp200/300 HP-UX binary */ 85 #define MID_HPUX800 0x20B /* hp800 HP-UX binary */ 86 u_char a_mid; /* machine ID */ 87 88 #define OMAGIC 0407 /* old impure format */ 89 #define NMAGIC 0410 /* read-only text */ 90 #define ZMAGIC 0413 /* demand load format */ 91 u_short a_magic; /* magic number */ 92 93 u_long a_text; /* text segment size */ 94 u_long a_data; /* initialized data size */ 95 u_long a_bss; /* uninitialized data size */ 96 u_long a_syms; /* symbol table size */ 97 u_long a_entry; /* entry point */ 98 u_long a_trsize; /* text relocation size */ 99 u_long a_drsize; /* data relocation size */ 100 }; 101 #define a_machtype a_mid /* SUN compatibility */ 102