/*
 * $Header: /smsa/bsd:include/sys/exec.h:bsd  1.18  $
 * $Source: /smsa/bsd:include/sys/exec.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 *
 */
/* @(#)exec.h	1.2 87/05/15 3.2/4.3NFSSRC */
/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 *
 *	@(#)exec.h	7.1 (Berkeley) 6/4/86
 */

#ifndef	__sys_exec_h
#define	__sys_exec_h

/*
 * Header prepended to each a.out file.
 * For compatibility reasons this structure is called "exec"
 * although an extended structure is actually prepended to all files
 * that are actually executable. The (old) "exec" header is only
 * now used on .o (i.e. type OMAGIC) files produced by compilers,
 * and not on any file that has been completely ld'd.
 */

struct exec {
	long	a_magic;	/* magic number */
unsigned long	a_text;		/* size of text segment */
unsigned long	a_data;		/* size of initialized data */
unsigned long	a_bss;		/* size of uninitialized data */
unsigned long	a_syms;		/* size of symbol table */
unsigned long	a_entry;	/* entry point */
#define a_sldatabase a_entry    /* used as data address for shared libs */
unsigned long	a_trsize;	/* size of text relocation */
unsigned long	a_drsize;	/* size of data relocation */
};

#ifndef __sys_types_h
#include "types.h"
#endif
#ifndef __sys_version_h
#include "version.h"
#endif


#define	SHLIBLEN	60

/* This is the structure that is actually prepended to all files that
 * the kernel can execute. It contains slots for the extra information
 * required to support shared libraries and/or squeezed images.
 */
struct exec_header {
	struct	exec a_exec;	/* The (old) small header */
	struct  version a_version;  /* Version number time and text */
unsigned long	a_sq4items;	/* number of squeezed type 4 items */
unsigned long	a_sq3items;	/* number of squeezed type 3 items */
unsigned long	a_sq4size;	/* size of squeezed type 4 items */
unsigned long	a_sq3size;	/* size of squeezed type 3 items */
unsigned long	a_sq4last;	/* last entry in type 4 table (check only) */
unsigned long	a_sq3last;	/* last entry in type 3 table (check only) */
	time_t	a_timestamp;	/* link time of this object */
	time_t	a_shlibtime;	/* timestamp of shared library */
	char	a_shlibname[SHLIBLEN]; /* Path name of shared library */
};


/*
 * Structure used for recording details of a shared library.
 */

struct shlib_info
{
  struct vnode	*si_vp;		/* Vnode of file containing shared lib */
  struct exec si_exec;	/* basic header from the file */
  int		si_xoffset;	/* Offset (pages) of text in text segment */
};


/* Basic magic numbers */

#define	OMAGIC	0407		/* old impure format */
#define	NMAGIC	0410		/* read-only text */
#define	ZMAGIC	0413		/* demand load format (pure sharable text) */

/* Magic flags - all combinations are valid */

#define MF_IMPURE   00200	/* impure text                       */
#define MF_SQUEEZED 01000	/* text and data squeezed            */
#define MF_USES_SL  02000	/* this object uses a shared library */
#define MF_IS_SL    04000	/* this object is a shared library   */

/* Names for some common magic number/flag combinations */

#define	IMAGIC	 (MF_IMPURE|ZMAGIC)	/* demand load format (impure text) */

#define SPOMAGIC (MF_USES_SL|OMAGIC)	/* OMAGIC with a large header - may */
					/* contain a reference to a shared  */
					/* library required by the object.  */

#define SLOMAGIC (MF_IS_SL|OMAGIC)	/* a reference to a shared library. */
					/* The text portion of the object   */
					/* contains ``overflow text'' from  */
					/* the shared library to be linked  */
					/* in with an object.		    */

#define	QMAGIC	  (MF_SQUEEZED|ZMAGIC)	/* squeezed demand paged            */
#define	SPZMAGIC  (MF_USES_SL|ZMAGIC)	/* program which uses shared lib    */
#define	SPQMAGIC  (MF_USES_SL|QMAGIC)	/* squeezed         ditto           */
#define	SLZMAGIC  (MF_IS_SL|ZMAGIC)	/* shared library part of program   */
#define SLPZMAGIC (MF_USES_SL|SLZMAGIC)	/* shared lib which uses another    */

/* Squeezed shared libraries are not supported (and probably not worth the  */
/* trouble they would cause).                                               */


/* Macros for finding properties of magic numbers */

#define IS_SQUEEZED(magic) 	(((magic) & MF_SQUEEZED) != 0)
#define IS_SHARED_LIB(magic)	(((magic) & MF_IS_SL)    != 0)

#endif/*__sys_exec_h*/

/* EOF exec.h */
