~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Minix Cross Reference
Minix/Solaris/next_prog_addr.c


  1 static char *rcsid = "$Id: next_prog_addr.c,v 1.1 1996/06/04 08:29:55 paul Exp $";
  2 
  3 /*
  4  * This program is used in conjunction with the make_map_file script
  5  * to generate the map files used in linking of mm and fs.
  6  * It prints the ending virtual address of the end of the address space 
  7  * of the smx executable on the standard input.
  8  */
  9 #include <stdio.h>
 10 #include <unistd.h>
 11 
 12 #include "../../include/minix/config.h"
 13 #undef NULL /* Defined again in const.h */
 14 #include "../../include/minix/const.h"
 15 #include "../../include/ansi.h"
 16 #include "../../include/a.out.h"
 17 
 18 
 19 static char *progname;
 20 
 21 /*
 22  * Local functions
 23  */
 24 static void usage(void);
 25 
 26 /*
 27  * Function: main
 28  * Parameters: argc, argv - no command line arguments
 29  *
 30  * Reads the header, validates it, then prints out the virtual address of the
 31  * first byte that follows this address space (which should be click
 32  * aligned).  In other words, prints the address at which the program
 33  * to follow this one should be loaded.
 34  */
 35 int main(int argc, char *argv[])
 36 {
 37     struct exec mxhead;
 38 
 39     progname = argv[0];
 40     if (argc != 1) usage();
 41 
 42     if (read(0, &mxhead, sizeof(mxhead)) != sizeof(mxhead)) {
 43         return 1;
 44     }
 45 
 46     if (BADMAG(mxhead) || mxhead.a_hdrlen != sizeof(mxhead) ||
 47         mxhead.a_cpu != A_SUNOS || (mxhead.a_flags & A_SEP) == 0 ||
 48         mxhead.a_total == 0 || mxhead.a_text % CLICK_SIZE != 0 ||
 49         mxhead.a_total < mxhead.a_data + mxhead.a_bss) {
 50         return 0;
 51     }
 52     
 53     printf("0x%lx\n", mxhead.a_tbase + mxhead.a_text + 
 54            upclick(mxhead.a_total));
 55     return 0;
 56 }
 57 
 58 
 59 /*
 60  * Function: usage
 61  */
 62 static void usage(void)
 63 {
 64     fprintf(stderr, "Usage: %s\n", progname);
 65 }
 66 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.