Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/runtime/kernel/boot.c
ViewVC logotype

Diff of /sml/trunk/src/runtime/kernel/boot.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1127, Fri Mar 8 01:35:33 2002 UTC revision 1128, Fri Mar 8 21:05:27 2002 UTC
# Line 277  Line 277 
277   *  the data segment will not contain executable code at all but some form   *  the data segment will not contain executable code at all but some form
278   *  of bytecode that is to be interpreted separately.)   *  of bytecode that is to be interpreted separately.)
279   *   *
280   *  In the binfile, each code segment is represented by its size s (in   *  In the binfile, each code segment is represented by its size s and its
281   *  bytes -- written as a 4-byte big-endian integer) followed by s bytes of   *  entry point offset (in bytes -- written as 4-byte big-endian integers)
282   *  machine- (or byte-) code. The total length of all code segments   *  followed by s bytes of machine- (or byte-) code. The total length of all
283   *  (including the bytes spent on representing individual sizes) is codeSzB.   *  code segments (including the bytes spent on representing individual sizes
284     *  and entry points) is codeSzB.  The entrypoint field for the data segment
285     *  is currently ignored (and should be 0).
286   *   *
287   * LINKING CONVENTIONS:   * LINKING CONVENTIONS:
288   *   *
# Line 370  Line 372 
372      ml_val_t        codeObj, importRec, closure, val;      ml_val_t        codeObj, importRec, closure, val;
373      binfile_hdr_t   hdr;      binfile_hdr_t   hdr;
374      pers_id_t       exportPerID;      pers_id_t       exportPerID;
375      Int32_t         thisSzB;      Int32_t         thisSzB, thisEntryPoint;
376      size_t          archiveOffset;      size_t          archiveOffset;
377      char            *atptr, *colonptr;      char            *atptr, *colonptr;
378      char            *objname = fname;      char            *objname = fname;
# Line 464  Line 466 
466      }      }
467    
468    /* Read code objects and run them.  The first code object will be the    /* Read code objects and run them.  The first code object will be the
469     * data segment.  We add a comment string to each code object to mark     * data segment.  */
    * which bin file it came from.  This code should be the same as that  
    * in ../c-libs/smlnj-runtime/mkcode.c.  
    */  
470    
471      remainingCode = hdr.codeSzB;      remainingCode = hdr.codeSzB;
472    
473    /* read the size for the data object */    /* read the size and the dummy entry point for the data object */
474      ReadBinFile (file, &thisSzB, sizeof(Int32_t), fname);      ReadBinFile (file, &thisSzB, sizeof(Int32_t), fname);
475      thisSzB = BIGENDIAN_TO_HOST(thisSzB);      thisSzB = BIGENDIAN_TO_HOST(thisSzB);
476        ReadBinFile (file, &thisEntryPoint, sizeof(Int32_t), fname);
477        /* thisEntryPoint = BIGENDIAN_TO_HOST(thisEntryPoint); */
478    
479      remainingCode -= thisSzB + sizeof(Int32_t);      remainingCode -= thisSzB + 2 * sizeof(Int32_t);
480      if (remainingCode < 0)      if (remainingCode < 0)
481          Die ("format error (data size mismatch) in bin file \"%s\"", fname);          Die ("format error (data size mismatch) in bin file \"%s\"", fname);
482    
# Line 502  Line 503 
503    
504      while (remainingCode > 0) {      while (remainingCode > 0) {
505    
506        /* read the size for this code object */        /* read the size and entry point for this code object */
507          ReadBinFile (file, &thisSzB, sizeof(Int32_t), fname);          ReadBinFile (file, &thisSzB, sizeof(Int32_t), fname);
508          thisSzB = BIGENDIAN_TO_HOST(thisSzB);          thisSzB = BIGENDIAN_TO_HOST(thisSzB);
509            ReadBinFile (file, &thisEntryPoint, sizeof(Int32_t), fname);
510            thisEntryPoint = BIGENDIAN_TO_HOST(thisEntryPoint);
511    
512        /* how much more? */        /* how much more? */
513          remainingCode -= thisSzB + sizeof(Int32_t);          remainingCode -= thisSzB + 2 * sizeof(Int32_t);
514          if (remainingCode < 0)          if (remainingCode < 0)
515            Die ("format error (code size mismatch) in bin file \"%s\"", fname);            Die ("format error (code size mismatch) in bin file \"%s\"", fname);
516    
# Line 517  Line 520 
520    
521          FlushICache (PTR_MLtoC(char, codeObj), thisSzB);          FlushICache (PTR_MLtoC(char, codeObj), thisSzB);
522    
523        /* create closure */        /* create closure (taking entry point into account) */
524          REC_ALLOC1 (msp, closure, codeObj);          REC_ALLOC1 (msp, closure,
525                        PTR_CtoML (PTR_MLtoC (char, codeObj) + thisEntryPoint));
526    
527        /* apply the closure to the import PerID vector */        /* apply the closure to the import PerID vector */
528          SaveCState (msp, &BinFileList, NIL(ml_val_t *));          SaveCState (msp, &BinFileList, NIL(ml_val_t *));

Legend:
Removed from v.1127  
changed lines
  Added in v.1128

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0