1091cf699Storek /* 2*38fb30dbSbostic * Copyright (c) 1992, 1993 3*38fb30dbSbostic * The Regents of the University of California. All rights reserved. 4091cf699Storek * 5091cf699Storek * This software was developed by the Computer Systems Engineering group 6091cf699Storek * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7091cf699Storek * contributed to Berkeley. 8091cf699Storek * 938c33d08Sbostic * All advertising materials mentioning features or use of this software 1038c33d08Sbostic * must display the following acknowledgement: 1138c33d08Sbostic * This product includes software developed by the University of 12004c84b4Storek * California, Lawrence Berkeley Laboratory. 1338c33d08Sbostic * 14091cf699Storek * %sccs.include.redist.c% 15091cf699Storek * 16*38fb30dbSbostic * @(#)exec.h 8.1 (Berkeley) 06/11/93 17091cf699Storek * 18004c84b4Storek * from: $Header: exec.h,v 1.9 93/04/20 11:14:45 torek Exp $ 19091cf699Storek */ 20091cf699Storek 21091cf699Storek /* 22091cf699Storek * __LDPGSZ is the page size used by the linker and by exec(). 23091cf699Storek * It may be some multiple of the ``normal'' page size, so that, e.g., 24091cf699Storek * the same binaries can be run on hardware with different page sizes 25091cf699Storek * that otherwise use the same instruction set. It must be no larger 26091cf699Storek * than CLBYTES (in param.h). 27091cf699Storek */ 28091cf699Storek #define __LDPGSZ 8192 29091cf699Storek 30091cf699Storek /* Valid magic number check. */ 31091cf699Storek #define N_BADMAG(ex) \ 32091cf699Storek ((ex).a_magic != ZMAGIC && (ex).a_magic != NMAGIC && \ 33091cf699Storek (ex).a_magic != OMAGIC) 34091cf699Storek 35091cf699Storek /* 36091cf699Storek * N_TXTADDR is the address of the first executable instruction: that is, 37091cf699Storek * the place the pc could begin after an a.out is loaded, in order to run 38091cf699Storek * the instructions in that a.out. The pc will actually be set to ex.a_entry 39091cf699Storek * but this is the first place it could possibly reference. 40091cf699Storek * 41091cf699Storek * On the SPARC, binaries begin at __LDPGSZ, i.e., page 1. 42091cf699Storek */ 43091cf699Storek #define N_TXTADDR(ex) 8192 44091cf699Storek 45091cf699Storek /* Address of the bottom of the data segment. */ 46091cf699Storek #define N_DATADDR(ex) \ 47c525a80aStorek (N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text : \ 48c525a80aStorek (((ex).a_text + __LDPGSZ - 1) & ~(__LDPGSZ - 1)))) 49091cf699Storek 50091cf699Storek /* 51091cf699Storek * N_TXTOFF is the offset within an a.out file of the first executable 52091cf699Storek * instruction: that is, the offset in the a.out of the byte that winds 53091cf699Storek * up at N_TXTADDR. 54091cf699Storek * 55091cf699Storek * On the SPARC, the a.out header is included in the executable when running 56091cf699Storek * a ZMAGIC file (but not for OMAGIC and NMAGIC). 57091cf699Storek */ 58091cf699Storek #define N_TXTOFF(ex) ((ex).a_magic == ZMAGIC ? 0 : sizeof(struct exec)) 59091cf699Storek 60091cf699Storek /* Data segment offset. */ 61091cf699Storek #define N_DATOFF(ex) \ 62091cf699Storek (N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text : \ 63c525a80aStorek (((ex).a_text + __LDPGSZ - 1) & ~(__LDPGSZ - 1)))) 64091cf699Storek 65091cf699Storek /* Symbol table offset. */ 66091cf699Storek #define N_SYMOFF(ex) \ 67091cf699Storek (N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \ 68091cf699Storek (ex).a_drsize) 69091cf699Storek 70091cf699Storek /* String table offset. */ 71091cf699Storek #define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms) 72091cf699Storek 73091cf699Storek /* Description of the object file header (a.out format). */ 74091cf699Storek struct exec { 75091cf699Storek u_char a_dynamic:1; /* dynamically linked */ 76091cf699Storek u_char a_toolversion:7;/* Sun toolset version XXX */ 77091cf699Storek 78091cf699Storek #define MID_ZERO 0 /* unknown - implementation dependent */ 79091cf699Storek #define MID_SUN010 1 /* sun 68010/68020 binary */ 80091cf699Storek #define MID_SUN020 2 /* sun 68020-only binary */ 81091cf699Storek #define MID_SUN_SPARC 3 /* sparc binary */ 82091cf699Storek #define MID_HP200 200 /* hp200 (68010) BSD binary */ 83091cf699Storek #define MID_HP300 300 /* hp300 (68020+68881) BSD binary */ 84091cf699Storek #define MID_HPUX 0x20C /* hp200/300 HP-UX binary */ 85091cf699Storek #define MID_HPUX800 0x20B /* hp800 HP-UX binary */ 86091cf699Storek u_char a_mid; /* machine ID */ 87091cf699Storek 88091cf699Storek #define OMAGIC 0407 /* old impure format */ 89091cf699Storek #define NMAGIC 0410 /* read-only text */ 90091cf699Storek #define ZMAGIC 0413 /* demand load format */ 91091cf699Storek u_short a_magic; /* magic number */ 92091cf699Storek 93091cf699Storek u_long a_text; /* text segment size */ 94091cf699Storek u_long a_data; /* initialized data size */ 95091cf699Storek u_long a_bss; /* uninitialized data size */ 96091cf699Storek u_long a_syms; /* symbol table size */ 97091cf699Storek u_long a_entry; /* entry point */ 98091cf699Storek u_long a_trsize; /* text relocation size */ 99091cf699Storek u_long a_drsize; /* data relocation size */ 100091cf699Storek }; 101091cf699Storek #define a_machtype a_mid /* SUN compatibility */ 102