"I am a person who works hard and plays hard."

Yuan Wei
Second Year Graduate Student Department of Computer Science
University of Virginia Charlottesville, VA 22903
Email: yw3f@cs.virginia.edu


Source Code Analysis

Main Page   Compound List   File List   Compound Members   File Members  

loader.h

Go to the documentation of this file.
00001 /*
00002  * loader.h - program loader interfaces
00003  *
00004  * This file is a part of the SimpleScalar tool suite written by
00005  * Todd M. Austin as a part of the Multiscalar Research Project.
00006  *  
00007  * The tool suite is currently maintained by Doug Burger and Todd M. Austin.
00008  * 
00009  * Copyright (C) 1994, 1995, 1996, 1997, 1998 by Todd M. Austin
00010  *
00011  * This source file is distributed "as is" in the hope that it will be
00012  * useful.  The tool set comes with no warranty, and no author or
00013  * distributor accepts any responsibility for the consequences of its
00014  * use. 
00015  * 
00016  * Everyone is granted permission to copy, modify and redistribute
00017  * this tool set under the following conditions:
00018  * 
00019  *    This source code is distributed for non-commercial use only. 
00020  *    Please contact the maintainer for restrictions applying to 
00021  *    commercial use.
00022  *
00023  *    Permission is granted to anyone to make or distribute copies
00024  *    of this source code, either as received or modified, in any
00025  *    medium, provided that all copyright notices, permission and
00026  *    nonwarranty notices are preserved, and that the distributor
00027  *    grants the recipient permission for further redistribution as
00028  *    permitted by this document.
00029  *
00030  *    Permission is granted to distribute this file in compiled
00031  *    or executable form under the same conditions that apply for
00032  *    source code, provided that either:
00033  *
00034  *    A. it is accompanied by the corresponding machine-readable
00035  *       source code,
00036  *    B. it is accompanied by a written offer, with no time limit,
00037  *       to give anyone a machine-readable copy of the corresponding
00038  *       source code in return for reimbursement of the cost of
00039  *       distribution.  This written offer must permit verbatim
00040  *       duplication by anyone, or
00041  *    C. it is distributed by someone who received only the
00042  *       executable form, and is accompanied by a copy of the
00043  *       written offer of source code that they received concurrently.
00044  *
00045  * In other words, you are welcome to use, share and improve this
00046  * source file.  You are forbidden to forbid anyone else to use, share
00047  * and improve what you give them.
00048  *
00049  * INTERNET: dburger@cs.wisc.edu
00050  * US Mail:  1210 W. Dayton Street, Madison, WI 53706
00051  *
00052  * $Id: loader.h,v 1.1.1.1 2000/05/26 15:18:58 taustin Exp $
00053  *
00054  * $Log: loader.h,v $
00055  * Revision 1.1.1.1  2000/05/26 15:18:58  taustin
00056  * SimpleScalar Tool Set
00057  *
00058  *
00059  * Revision 1.6  1998/08/27 16:44:14  taustin
00060  * implemented host interface description in host.h
00061  * added target interface support
00062  * added support for register and memory contexts
00063  *
00064  * Revision 1.5  1997/03/11  01:13:20  taustin
00065  * updated copyright
00066  *
00067  * Revision 1.4  1997/01/06  16:00:03  taustin
00068  * ld_prog_fname variable exported
00069  *
00070  * Revision 1.3  1996/12/27  15:52:06  taustin
00071  * updated comments
00072  *
00073  * Revision 1.1  1996/12/05  18:50:23  taustin
00074  * Initial revision
00075  *
00076  *
00077  */
00078 
00079 #ifndef LOADER_H
00080 #define LOADER_H
00081 
00082 #include <stdio.h>
00083 
00084 #include "host.h"
00085 #include "misc.h"
00086 #include "machine.h"
00087 #include "regs.h"
00088 #include "memory.h"
00089 
00090 /*
00091  * This module implements program loading.  The program text (code) and
00092  * initialized data are first read from the program executable.  Next, the
00093  * program uninitialized data segment is initialized to all zero's.  Finally,
00094  * the program stack is initialized with command line arguments and
00095  * environment variables.  The format of the top of stack when the program
00096  * starts execution is as follows:
00097  *
00098  * 0x7fffffff    +----------+
00099  *               | unused   |
00100  * 0x7fffc000    +----------+
00101  *               | envp     |
00102  *               | strings  |
00103  *               +----------+
00104  *               | argv     |
00105  *               | strings  |
00106  *               +----------+
00107  *               | envp     |
00108  *               | array    |
00109  *               +----------+
00110  *               | argv     |
00111  *               | array    |
00112  *               +----------+
00113  *               | argc     |
00114  * regs_R[29]    +----------+
00115  * (stack ptr)
00116  *
00117  * NOTE: the start of envp is computed in crt0.o (C startup code) using the
00118  * value of argc and the computed size of the argv array, the envp array size
00119  * is not specified, but rather it is NULL terminated, so the startup code
00120  * has to scan memory for the end of the string.
00121  */
00122 
00123 /*
00124  * program segment ranges, valid after calling ld_load_prog()
00125  */
00126 
00127 /* program text (code) segment base */
00128 extern md_addr_t ld_text_base;
00129 
00130 /* program text (code) size in bytes */
00131 extern unsigned int ld_text_size;
00132 
00133 /* program initialized data segment base */
00134 extern md_addr_t ld_data_base;
00135 
00136 /* program initialized ".data" and uninitialized ".bss" size in bytes */
00137 extern unsigned int ld_data_size;
00138 
00139 /* top of the data segment */
00140 extern md_addr_t ld_brk_point;
00141 
00142 /* program stack segment base (highest address in stack) */
00143 extern md_addr_t ld_stack_base;
00144 
00145 /* program initial stack size */
00146 extern unsigned int ld_stack_size;
00147 
00148 /* lowest address accessed on the stack */
00149 extern md_addr_t ld_stack_min;
00150 
00151 /* program file name */
00152 extern char *ld_prog_fname;
00153 
00154 /* program entry point (initial PC) */
00155 extern md_addr_t ld_prog_entry;
00156 
00157 /* program environment base address address */
00158 extern md_addr_t ld_environ_base;
00159 
00160 /* target executable endian-ness, non-zero if big endian */
00161 extern int ld_target_big_endian;
00162 
00163 /* register simulator-specific statistics */
00164 void
00165 ld_reg_stats(struct stat_sdb_t *sdb);   /* stats data base */
00166 
00167 /* load program text and initialized data into simulated virtual memory
00168    space and initialize program segment range variables */
00169 void
00170 ld_load_prog(char *fname,               /* program to load */
00171              int argc, char **argv,     /* simulated program cmd line args */
00172              char **envp,               /* simulated program environment */
00173              struct regs_t *regs,       /* registers to initialize for load */
00174              struct mem_t *mem,         /* memory space to load prog into */
00175              int zero_bss_segs);        /* zero uninit data segment? */
00176 
00177 #endif /* LOADER_H */


UVa CS Department of Computer Science
School of Engineering, University of Virginia
151 Engineer's Way, P.O. Box 400740
Charlottesville, Virginia 22904-4740

(434) 982-2200  Fax: (434) 982-2214