1 /* $NetBSD: exec_ecoff.h,v 1.5 1994/06/29 06:44:06 cgd Exp $ */ 2 3 /* 4 * Copyright (c) 1994 Adam Glass 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Adam Glass. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef _SYS_EXEC_ECOFF_H_ 34 #define _SYS_EXEC_ECOFF_H_ 35 36 #include <machine/ecoff.h> 37 38 struct ecoff_filehdr { 39 u_short ef_magic; /* magic number */ 40 u_short ef_nsecs; /* # of sections */ 41 u_int ef_timestamp; /* time and date stamp */ 42 u_long ef_symptr; /* file offset of symbol table */ 43 u_int ef_syms; /* # of symbol table entries */ 44 u_short ef_opthdr; /* sizeof the optional header */ 45 u_short ef_flags; /* flags??? */ 46 }; 47 48 struct ecoff_aouthdr { 49 u_short ea_magic; 50 u_short ea_vstamp; 51 ECOFF_PAD 52 u_long ea_tsize; 53 u_long ea_dsize; 54 u_long ea_bsize; 55 u_long ea_entry; 56 u_long ea_text_start; 57 u_long ea_data_start; 58 u_long ea_bss_start; 59 ECOFF_MACHDEP; 60 }; 61 62 struct ecoff_scnhdr { /* needed for size info */ 63 char es_name[8]; /* name */ 64 u_long es_physaddr; /* physical addr? for ROMing?*/ 65 u_long es_virtaddr; /* virtual addr? */ 66 u_long es_size; /* size */ 67 u_long es_raw_offset; /* file offset of raw data */ 68 u_long es_reloc_offset; /* file offset of reloc data */ 69 u_long es_line_offset; /* file offset of line data */ 70 u_short es_nreloc; /* # of relocation entries */ 71 u_short es_nline; /* # of line entries */ 72 u_int es_flags; /* flags */ 73 }; 74 75 #define ECOFF_HDR_SIZE (sizeof(struct ecoff_filehdr) + \ 76 sizeof(struct ecoff_aouthdr)) 77 78 #define ECOFF_OMAGIC 0407 79 #define ECOFF_NMAGIC 0410 80 #define ECOFF_ZMAGIC 0413 81 82 #define ECOFF_ROUND(value, by) \ 83 (((value) + by - 1) & ~(by - 1)) 84 85 #define ECOFF_BLOCK_ALIGN(eap, value) \ 86 (eap->ea_magic == ECOFF_ZMAGIC ? ECOFF_ROUND(value, ECOFF_LDPGSZ) : \ 87 value) 88 89 #define ECOFF_TXTOFF(efp, eap) \ 90 (eap->ea_magic == ECOFF_ZMAGIC ? 0 : \ 91 ECOFF_ROUND(ECOFF_HDR_SIZE + efp->ef_nsecs * \ 92 sizeof(struct ecoff_scnhdr),ECOFF_SEGMENT_ALIGNMENT(eap))) 93 94 #define ECOFF_DATOFF(efp, eap) \ 95 (ECOFF_BLOCK_ALIGN(eap, ECOFF_TXTOFF(efp, eap) + eap->ea_tsize)) 96 97 #define ECOFF_SEGMENT_ALIGN(eap, value) \ 98 (ECOFF_ROUND(value, (eap->ea_magic == ECOFF_ZMAGIC ? ECOFF_LDPGSZ : \ 99 ECOFF_SEGMENT_ALIGNMENT(eap)))) 100 101 #ifdef KERNEL 102 int exec_ecoff_makecmds __P((struct proc *, struct exec_package *)); 103 #endif /* KERNEL */ 104 #endif /* !_SYS_EXEC_ECOFF_H_ */ 105