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