153899Smckusick /*- 2*63306Sbostic * Copyright (c) 1992, 1993 3*63306Sbostic * The Regents of the University of California. All rights reserved. 453899Smckusick * 553899Smckusick * %sccs.include.redist.c% 653899Smckusick * 7*63306Sbostic * @(#)exec.h 8.1 (Berkeley) 06/11/93 853899Smckusick */ 953899Smckusick 1053899Smckusick /* 1153899Smckusick * Portions of this file are subject to the following copyright notice: 1253899Smckusick * 1353899Smckusick * Copyright (C) 1989 Digital Equipment Corporation. 1453899Smckusick * Permission to use, copy, modify, and distribute this software and 1553899Smckusick * its documentation for any purpose and without fee is hereby granted, 1653899Smckusick * provided that the above copyright notice appears in all copies. 1753899Smckusick * Digital Equipment Corporation makes no representations about the 1853899Smckusick * suitability of this software for any purpose. It is provided "as is" 1953899Smckusick * without express or implied warranty. 2053899Smckusick */ 2153899Smckusick 2253899Smckusick /* 2353899Smckusick * /sprite/src/kernel/proc/ds3100.md/RCS/procMach.h,v 9.3 90/02/20 15:35:50 2453899Smckusick * shirriff Exp $ SPRITE (Berkeley) 2553899Smckusick */ 2653899Smckusick 2753899Smckusick /* Size of a page in an object file. */ 2853899Smckusick #define __LDPGSZ 4096 2953899Smckusick 3053899Smckusick /* Valid magic number check. */ 3153899Smckusick #define N_BADMAG(ex) \ 3253899Smckusick ((ex).a_magic != NMAGIC && (ex).a_magic != OMAGIC && \ 3353899Smckusick (ex).a_magic != ZMAGIC) 3453899Smckusick 3553899Smckusick /* Address of the bottom of the text segment. */ 3653899Smckusick #define N_TXTADDR(ex) 0x400000 3753899Smckusick 3853899Smckusick /* Address of the bottom of the data segment. */ 3953899Smckusick /* NOT DEFINED FOR THE MIPS. */ 4053899Smckusick 4153899Smckusick /* Text segment offset. */ 4253899Smckusick #define __N_TXTOFF_ROUND(ex) \ 4353899Smckusick ((ex).ex_aout.verStamp < 23 ? 7 : 15) 4453899Smckusick #define N_TXTOFF(ex) \ 4553899Smckusick ((ex).ex_aout.magic == ZMAGIC ? 0 : (sizeof(struct exec) + \ 4653899Smckusick (ex).ex_fhdr.numSections * sizeof(ProcSectionHeader) + \ 4753899Smckusick __N_TXTOFF_ROUND(ex)) & ~__N_TXTOFF_ROUND(ex)) 4853899Smckusick 4953899Smckusick /* Data segment offset. */ 5058614Sutashiro #define N_DATOFF(ex) \ 5153899Smckusick (N_TXTOFF(ex) + (ex).ex_aout.codeSize) 5253899Smckusick 5353899Smckusick /* Symbol table offset. */ 5458614Sutashiro /* NOT DEFINED FOR THE MIPS. */ 5553899Smckusick 5653899Smckusick /* String table offset. */ 5753899Smckusick /* NOT DEFINED FOR THE MIPS. */ 5853899Smckusick 5953899Smckusick /* 6053899Smckusick * XXX 6153899Smckusick * The ProcFileHeader structure and the ProcAOUTHeader structure should be 6253899Smckusick * folded together into a single struct exec. 6353899Smckusick */ 6453899Smckusick 6553899Smckusick /* Description of the COFF section. */ 6653899Smckusick typedef struct { 6753899Smckusick #if BYTE_ORDER == BIG_ENDIAN 6853899Smckusick # define COFF_MAGIC 0x0160 6953899Smckusick #else 7053899Smckusick # define COFF_MAGIC 0x0162 7153899Smckusick #endif 7253899Smckusick u_short magic; /* The magic number. */ 7353899Smckusick 7453899Smckusick u_short numSections; /* The number of sections. */ 7553899Smckusick long timeDateStamp; /* Time and date stamp. */ 7653899Smckusick long symPtr; /* File pointer to symbolic header. */ 7753899Smckusick long numSyms; /* Size of symbolic header. */ 7853899Smckusick u_short optHeader; /* Size of optional header. */ 7953899Smckusick u_short flags; /* Flags. */ 8053899Smckusick } ProcFileHeader; 8153899Smckusick 8253899Smckusick /* Description of the a.out section. */ 8353899Smckusick typedef struct { 8453899Smckusick #define OMAGIC 0407 /* old impure format */ 8553899Smckusick #define NMAGIC 0410 /* read-only text */ 8653899Smckusick #define ZMAGIC 0413 /* demand load format */ 8753899Smckusick short magic; /* Magic number. */ 8853899Smckusick 8953899Smckusick short verStamp; /* Version stamp. */ 9053899Smckusick long codeSize; /* Code size in bytes. */ 9153899Smckusick long heapSize; /* Initialized data size in bytes. */ 9253899Smckusick long bssSize; /* Uninitialized data size in bytes. */ 9353899Smckusick long entry; /* Entry point. */ 9453899Smckusick long codeStart; /* Base of code used for this file. */ 9553899Smckusick long heapStart; /* Base of heap used for this file. */ 9653899Smckusick long bssStart; /* Base of bss used for this file. */ 9753899Smckusick long gprMask; /* General purpose register mask. */ 9853899Smckusick long cprMask[4]; /* Co-processor register masks. */ 9953899Smckusick long gpValue; /* The gp value for this object. */ 10053899Smckusick } ProcAOUTHeader; 10153899Smckusick 10253899Smckusick /* Section header. */ 10353899Smckusick typedef struct { 10453899Smckusick char name[8]; /* Section name. */ 10553899Smckusick long physAddr; /* Section physical address. */ 10653899Smckusick long virtAddr; /* Section virtual address. */ 10753899Smckusick long size; /* Section size. */ 10853899Smckusick long sectionPtr; /* File pointer to section data. */ 10953899Smckusick long relocPtr; /* File pointer to relocation data. */ 11053899Smckusick long lnnoPtr; /* File pointer to gp tables. */ 11153899Smckusick u_short numReloc; /* Number of relocation entries. */ 11253899Smckusick u_short numLnno; /* Numberof gp tables. */ 11353899Smckusick long flags; /* Section flags. */ 11453899Smckusick } ProcSectionHeader; 11553899Smckusick 11653899Smckusick /* Description of the object file header. */ 11753899Smckusick struct exec { 11853899Smckusick ProcFileHeader ex_fhdr; 11953899Smckusick ProcAOUTHeader ex_aout; 12053899Smckusick }; 12153899Smckusick #define a_magic ex_aout.magic 12253899Smckusick #define a_text ex_aout.codeSize 12353899Smckusick #define a_data ex_aout.heapSize 12453899Smckusick #define a_bss ex_aout.bssSize 12553899Smckusick #define a_entry ex_aout.entry 126