/* @(#)a.out.h 4.3 (ULTRIX) 9/4/90 */ /************************************************************************ * * * Copyright (c) 1986,1988 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************/ #include "ansi_compat.h" #define OMAGIC 0407 #define NMAGIC 0410 #define ZMAGIC 0413 #define LIBMAGIC 0443 #define N_BADMAG(x) \ (((x).magic)!=OMAGIC && ((x).magic)!=NMAGIC && ((x).magic)!=ZMAGIC && \ ((x).magic)!=LIBMAGIC) typedef struct aouthdr { short magic; /* see above */ short vstamp; /* version stamp */ int tsize; /* text size in bytes, padded to DW bdry*/ int dsize; /* initialized data " " */ int bsize; /* uninitialized data " " */ int entry; /* entry pt. */ int text_start; /* base of text used for this file */ int data_start; /* base of data used for this file */ int bss_start; /* base of bss used for this file */ int gprmask; /* general purpose register mask */ int cprmask[4]; /* co-processor register masks */ int gp_value; /* the gp value used for this object */ } AOUTHDR; #define AOUTHSZ sizeof(AOUTHDR) struct scnhdr { char s_name[8]; /* section name */ long s_paddr; /* physical address, aliased s_nlib */ long s_vaddr; /* virtual address */ long s_size; /* section size */ long s_scnptr; /* file ptr to raw data for section */ long s_relptr; /* file ptr to relocation */ long s_lnnoptr; /* file ptr to gp histogram */ unsigned short s_nreloc; /* number of relocation entries */ unsigned short s_nlnno; /* number of gp histogram entries */ long s_flags; /* flags */ }; #define SCNROUND ((long)16) /* the number of shared libraries in a .lib section in an absolute output file * is put in the s_paddr field of the .lib section header, the following define * allows it to be referenced as s_nlib */ #define s_nlib s_paddr #define SCNHDR struct scnhdr #define SCNHSZ sizeof(SCNHDR) /* * Define constants for names of "special" sections */ #define _TEXT ".text" #define _DATA ".data" #define _BSS ".bss" #define _TV ".tv" #define _INIT ".init" #define _FINI ".fini" #define _LIB ".lib" /* * Mips names for read only data (.rdata), small data (.sdata) and small bss * (.bss). Small sections are used for global pointer relative data items. */ #define _RDATA ".rdata" #define _SDATA ".sdata" #define _SBSS ".sbss" #define _UCODE ".ucode" #define _LIT8 ".lit8" #define _LIT4 ".lit4" /* * The low 4 bits of s_flags is used as a section "type" */ #define STYP_REG 0x00 /* "regular" section: allocated, relocated, loaded */ #define STYP_DSECT 0x01 /* "dummy" section: not allocated, relocated, not loaded */ #define STYP_NOLOAD 0x02 /* "noload" section: allocated, relocated, not loaded */ #define STYP_GROUP 0x04 /* "grouped" section: formed of input sections */ #define STYP_PAD 0x08 /* "padding" section: not allocated, not relocated, loaded */ #define STYP_COPY 0x10 /* "copy" section: for decision function used by field update; not allocated, not relocated, loaded; reloc & lineno entries processed normally */ #define STYP_TEXT 0x20 /* section contains text only */ #define STYP_DATA 0x40 /* section contains data only */ #define STYP_BSS 0x80 /* section contains bss only */ #define STYP_RDATA 0x100 /* section contains read only data */ #define STYP_SDATA 0x200 /* section contains small data only */ #define STYP_SBSS 0x400 /* section contains small bss only */ #define STYP_UCODE 0x800 /* section only contains ucodes */ #define STYP_LIT8 0x08000000 /* literal pool for 8 byte literals */ #define STYP_LIT4 0x10000000 /* literal pool for 4 byte literals */ #define S_NRELOC_OVFL 0x20000000 /* s_nreloc overflowed, the value is in v_addr of the first entry */ #define STYP_LIB 0x40000000 /* section is a .lib section */ #define STYP_INIT 0x80000000 /* section only contains the text instructions for the .init sec. */ /* * In a minimal file or an update file, a new function * (as compared with a replaced function) is indicated by S_NEWFCN */ #define S_NEWFCN 0x100 /* * In 3b Update Files (output of ogen), sections which appear in SHARED * segments of the Pfile will have the S_SHRSEG flag set by ogen, to inform * dufr that updating 1 copy of the proc. will update all process invocations. */ #define S_SHRSEG 0x20 /* * This table gives the section size corresponding to each applicable * Gnum (always including 0), sorted by smallest size first. It is pointed to * by the s_lnnoptr field in the section header and its number of entries * (including the header) is in the s_nlnno field in the section header. * This table only needs to exist for the .sdata and .sbss sections * sections. If there is no "small" section then the gp table for it is * attached to the coresponding "large" section so the information still * gets to the loader. */ union gp_table { struct { long current_g_value; /* actual value */ long unused; } header; struct { long g_value; /* hypothetical value */ long bytes; /* section size corresponding to hypothetical value */ } entry; }; #define GPTAB union gp_table #define GPTABSZ sizeof(GPTAB) /* * This is the definition of a mips .lib section entry. Note the size and * offset are in sizeof(long)'s not bytes. */ struct libscn { long size; /* size of this entry (including target name) */ long offset; /* offset from start of entry to target name */ long tsize; /* text size in bytes, padded to DW boundary */ long dsize; /* initialized data " " " " " */ long bsize; /* uninitialized data " " " " " */ long text_start; /* base of text used for this library */ long data_start; /* base of data used for this library */ long bss_start; /* base of bss used for this library */ /* pathname of target shared library */ }; #define LIBSCN struct libscn #define LSCNSZ sizeof(LIBSCN) /* $Header: a.out.h,v 2010.5.1.5 89/11/29 22:40:53 bettina Exp $ */ #define N_TXTOFF(f, a) \ ((a).magic == ZMAGIC || (a).magic == LIBMAGIC ? 0 : \ ((a).vstamp < 23 ? \ ((FILHSZ + AOUTHSZ + (f).f_nscns * SCNHSZ + 7) & 0xfffffff8) : \ ((FILHSZ + AOUTHSZ + (f).f_nscns * SCNHSZ + SCNROUND-1) & ~(SCNROUND-1)) ) ) /* * Format of an a.out header */ struct exec { /* a.out header */ short a_magic; /* magic number */ unsigned a_text; /* size of text segment */ /* in bytes */ /* padded out to next */ /* page boundary with */ /* binary zeros. */ unsigned a_data; /* size of initialized data */ /* segment in bytes */ /* padded out to next */ /* page boundary with */ /* binary zeros. */ unsigned a_bss; /* Actual size of */ /* uninitialized data */ /* segment in bytes. */ unsigned a_syms; /* size of symbol table */ unsigned a_entry; /* entry point */ }; #define A_MAGIC1 0407 /* normal */ #define A_MAGIC0 0401 /* lpd (UNIX/RT) */ #define A_MAGIC2 0410 /* read-only text */ #define A_MAGIC3 0411 /* separated I&D */ #define A_MAGIC4 0405 /* overlay */ #define A_MAGIC5 0437 /* system overlay, separated I&D */ /* in invocation of BADMAG macro, argument should not be a function. */ #define BADMAG(X) (X.a_magic != A_MAGIC1 &&\ X.a_magic != A_MAGIC2 &&\ X.a_magic != A_MAGIC3 &&\ X.a_magic != A_MAGIC4 &&\ X.a_magic != A_MAGIC5 &&\ X.a_magic != A_MAGIC0) /* values for type flag */ #define N_UNDF 0 /* undefined */ #define N_TYPE 037 #define N_FN 037 /* file name symbol */ #define N_ABS 02 /* absolute */ #define N_TEXT 04 /* text */ #define N_DATA 06 /* data */ #define N_BSS 010 #define N_GSYM 0040 /* global sym: name,,type,0 */ #define N_FNAME 0042 /* procedure name (f77 kludge): name,,,0 */ #define N_FUN 0044 /* procedure: name,,linenumber,address */ #define N_STSYM 0046 /* static symbol: name,,type,address */ #define N_LCSYM 0050 /* .lcomm symbol: name,,type,address */ #define N_BSTR 0060 /* begin structure: name,,, */ #define N_RSYM 0100 /* register sym: name,,register,offset */ #define N_SLINE 0104 /* src line: ,,linenumber,address */ #define N_ESTR 0120 /* end structure: name,,, */ #define N_SSYM 0140 /* structure elt: name,,type,struct_offset */ #define N_SO 0144 /* source file name: name,,,address */ #define N_BENUM 0160 /* begin enum: name,,, */ #define N_LSYM 0200 /* local sym: name,,type,offset */ #define N_SOL 0204 /* #line source filename: name,,,address */ #define N_ENUM 0220 /* enum element: name,,,value */ #define N_PSYM 0240 /* parameter: name,,type,offset */ #define N_ENTRY 0244 /* alternate entry: name,,linenumber,address */ #define N_EENUM 0260 /* end enum: name,,, */ #define N_LBRAC 0300 /* left bracket: ,,nesting level,address */ #define N_RBRAC 0340 /* right bracket: ,,nesting level,address */ #define N_BCOMM 0342 /* begin common: name,,, */ #define N_ECOMM 0344 /* end common: name,,, */ #define N_ECOML 0350 /* end common (local name): ,,,address */ #define N_STRU 0374 /* 2nd entry for structure: str tag,,,length */ #define N_LENG 0376 /* second stab entry with length information */ #define N_EXT 01 /* external bit, or'ed in */ #define FORMAT "%.8x" #define STABTYPES 0340