home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / pgmutil / val_link.zip / INITLINK.C < prev    next >
Text File  |  1989-02-18  |  16KB  |  283 lines

  1. /*                                 INITLINK.C                              */
  2.  
  3. /*+-------------------------------------------------------------------------+
  4.   |                                                                         |
  5.   |                       primary_linker_initialization                     |
  6.   |                                                                         |
  7.   +-------------------------------------------------------------------------+*/
  8. void primary_linker_initialization(byte *program_directory)
  9. BeginDeclarations
  10. EndDeclarations
  11. BeginCode
  12.  
  13.  /* Note start time */
  14.  linker_start_time = Now;
  15.  
  16.  /* Issue Signon message */
  17.  linker_message("VAL Experimental Linker Compiled %s %s\n",__DATE__,__TIME__);
  18.  
  19. /*+-------------------------------------------------------------------------+
  20.   |                                                                         |
  21.   |                     Memory Pool Initialization                          |
  22.   |                                                                         |
  23.   +-------------------------------------------------------------------------+*/
  24.  
  25.  initialize_memory();
  26.  
  27. /*+-------------------------------------------------------------------------+
  28.   |                                                                         |
  29.   |                     Constant String Initialization                      |
  30.   |                                                                         |
  31.   +-------------------------------------------------------------------------+*/
  32.  
  33. /* Uninitialized strings */
  34.  
  35.  current_filename         = allocate_string(Addr(static_pool), TEMP_STRING_LENGTH);
  36.  current_path             = allocate_string(Addr(static_pool), TEMP_STRING_LENGTH);
  37.  default_directory_string = allocate_string(Addr(static_pool), TEMP_STRING_LENGTH);
  38.  default_filename         = allocate_string(Addr(static_pool), TEMP_STRING_LENGTH);
  39.  help_filename            = allocate_string(Addr(static_pool), TEMP_STRING_LENGTH);
  40.  next_token               = allocate_string(Addr(static_pool), TEMP_STRING_LENGTH);
  41.  parm_string              = allocate_string(Addr(static_pool), TEMP_STRING_LENGTH);
  42.  temp_string              = allocate_string(Addr(static_pool), TEMP_STRING_LENGTH);
  43.  token                    = allocate_string(Addr(static_pool), TEMP_STRING_LENGTH);
  44.  
  45. /* Initialized strings */
  46.  
  47.  ampersand_string         = make_constant_string(Addr(static_pool),
  48.                                                  (byte *) "&");
  49.  and_string               = make_constant_string(Addr(static_pool),
  50.                                                  (byte *) "and");
  51.  at_string                = make_constant_string(Addr(static_pool),
  52.                                                  (byte *) "@");
  53.  backslash_string         = make_constant_string(Addr(static_pool),
  54.                                                  (byte *) "\\");
  55.  backslash_dot_string     = make_constant_string(Addr(static_pool),
  56.                                                  (byte *) "\\.\\");
  57.  backslash_dot_dot_string = make_constant_string(Addr(static_pool),
  58.                                                  (byte *) "\\..\\");
  59.  bar_string               = make_constant_string(Addr(static_pool),
  60.                                                  (byte *) "|");
  61.  class_string             = make_constant_string(Addr(static_pool),
  62.                                                  (byte *) "class");
  63.  close_angle_string       = make_constant_string(Addr(static_pool),
  64.                                                  (byte *) ">");
  65.  close_paren_string       = make_constant_string(Addr(static_pool),
  66.                                                  (byte *) ")");
  67.  colon_string             = make_constant_string(Addr(static_pool),
  68.                                                  (byte *) ":");
  69.  com_extension_string     = make_constant_string(Addr(static_pool),
  70.                                                  (byte *) ".com");
  71.  comma_string             = make_constant_string(Addr(static_pool),
  72.                                                  (byte *) ",");
  73.  default_drive_string     = default_drive();
  74.  device_AUX               = make_constant_string(Addr(static_pool),
  75.                                                  (byte *) "aux:");
  76.  device_CON               = make_constant_string(Addr(static_pool),
  77.                                                  (byte *) "con:");
  78.  device_PRN               = make_constant_string(Addr(static_pool),
  79.                                                  (byte *) "prn:");
  80.  dot_string               = make_constant_string(Addr(static_pool),
  81.                                                  (byte *) ".");
  82.  env_extension_string     = make_constant_string(Addr(static_pool),
  83.                                                  (byte *) ".env");
  84.  exclamation_string       = make_constant_string(Addr(static_pool),
  85.                                                  (byte *) "!");
  86.  exe_extension_string     = make_constant_string(Addr(static_pool),
  87.                                                  (byte *) ".exe");
  88.  group_string             = make_constant_string(Addr(static_pool),
  89.                                                  (byte *) "group");
  90.  help_extension_string    = make_constant_string(Addr(static_pool),
  91.                                                  (byte *) ".hlp");
  92.  lib_extension_string     = make_constant_string(Addr(static_pool),
  93.                                                  (byte *) ".lib");
  94.  lst_extension_string     = make_constant_string(Addr(static_pool),
  95.                                                  (byte *) ".map");
  96.  minus_string             = make_constant_string(Addr(static_pool),
  97.                                                  (byte *) "-");
  98.  not_string               = make_constant_string(Addr(static_pool),
  99.                                                  (byte *) "not");
  100.  null_string              = make_constant_string(Addr(static_pool),
  101.                                                  (byte *) "");
  102.  obj_extension_string     = make_constant_string(Addr(static_pool),
  103.                                                  (byte *) ".obj");
  104.  open_paren_string        = make_constant_string(Addr(static_pool),
  105.                                                  (byte *) "<");
  106.  open_paren_string        = make_constant_string(Addr(static_pool),
  107.                                                  (byte *) "(");
  108.  or_string                = make_constant_string(Addr(static_pool),
  109.                                                  (byte *) "or");
  110.  plus_string              = make_constant_string(Addr(static_pool),
  111.                                                  (byte *) "+");
  112.  program_directory_string = make_constant_string(Addr(static_pool),
  113.                                                  program_directory);
  114.  process_filename(program_directory_string);
  115.  segment_string           = make_constant_string(Addr(static_pool),
  116.                                                  (byte *) "segment");
  117.  semicolon_string         = make_constant_string(Addr(static_pool),
  118.                                                  (byte *) ";");
  119.  space_string             = make_constant_string(Addr(static_pool),
  120.                                                  (byte *) " ");
  121.  star_string              = make_constant_string(Addr(static_pool),
  122.                                                  (byte *) "*");
  123.  sys_extension_string     = make_constant_string(Addr(static_pool),
  124.                                                  (byte *) ".sys");
  125.  tilde_string             = make_constant_string(Addr(static_pool),
  126.                                                  (byte *) "~");
  127.  true_string              = make_constant_string(Addr(static_pool),
  128.                                                  (byte *) "true");
  129.  
  130. /*+-------------------------------------------------------------------------+
  131.   |                                                                         |
  132.   |                          DOS Initialization                             |
  133.   |                                                                         |
  134.   +-------------------------------------------------------------------------+*/
  135.   DTA = (DTA_ptr) allocate_memory(Addr(static_pool), 
  136.                                   Bit_32(sizeof(DTA_type)));
  137.  
  138. /*+-------------------------------------------------------------------------+
  139.   |                                                                         |
  140.   |                          Other Initialization                           |
  141.   |                                                                         |
  142.   +-------------------------------------------------------------------------+*/
  143.  current_record_header     = (obj_record_header_ptr) object_file_element;
  144.  last_LIDATA_record_header = (obj_record_header_ptr) last_LIDATA_record;
  145.  copy_string(help_filename, program_directory_string);
  146.  change_extension(help_filename, help_extension_string);
  147.  return;
  148. EndCode
  149.  
  150. /*+-------------------------------------------------------------------------+
  151.   |                                                                         |
  152.   |                     secondary_linker_initialization                     |
  153.   |                                                                         |
  154.   +-------------------------------------------------------------------------+
  155.  
  156. There are several steps in the initialization process which had to be
  157. delayed because switches specified by the user affect the initialization
  158. process.  After user input is processed, this procedure is called and that
  159. initialization occurs. */
  160.  
  161. void secondary_linker_initialization()
  162. BeginDeclarations
  163. EndDeclarations
  164. BeginCode
  165.  
  166.  secondary_init_start_time = Now;
  167.  
  168. /*+-------------------------------------------------------------------------+
  169.   |                                                                         |
  170.   |                         Allocate the I/O buffer.                        |
  171.   |                                                                         |
  172.   +-------------------------------------------------------------------------+*/
  173.  
  174.  infile_buffer              = allocate_memory(Addr(static_pool),
  175.                                               Bit_32(buffer_size.val));
  176.  infile.buffer              = infile_buffer;
  177.  infile.buffer_size         = buffer_size.val;
  178.  
  179.  outfile_buffer             = allocate_memory(Addr(static_pool),
  180.                                               Bit_32(buffer_size.val));
  181.  outfile.buffer             = outfile_buffer;
  182.  outfile.buffer_size        = buffer_size.val;
  183.  
  184.  If temp_filename.val IsNull
  185.   Then
  186.    temp_file = (file_info_ptr)
  187.                 allocate_memory(Addr(static_pool),
  188.                                 Bit_32(sizeof(file_info_type)) + 5L);
  189.    far_move((*temp_file).filename, BytePtr("l.tmp"), 6);
  190.   Else
  191.    copy_string(temp_filename.val, 
  192.                substr(temp_filename.val, 1, Length(temp_filename.val)-2));
  193.    temp_file = (file_info_ptr)
  194.                 allocate_memory(Addr(static_pool),
  195.                                 Bit_32(sizeof(file_info_type)) + 
  196.                                 Length(temp_filename.val));
  197.    far_move((*temp_file).filename, 
  198.             String(temp_filename.val),
  199.             Length(temp_filename.val));
  200.   EndIf;
  201.  
  202. /*+-------------------------------------------------------------------------+
  203.   |                                                                         |
  204.   |                           Allocate hash tables.                         |
  205.   |                                                                         |
  206.   +-------------------------------------------------------------------------+*/
  207.  
  208.  externals          = (public_entry_ptr_array)
  209.                        allocate_memory(Addr(static_pool),
  210.                                        (Bit_32(max_externals.val)+1L) *
  211.                                         Bit_32(sizeof(group_entry_ptr)));
  212.  
  213.  gnames             = (group_entry_ptr_array)
  214.                        allocate_memory(Addr(static_pool),
  215.                                        (Bit_32(max_groups.val)+1L) *
  216.                                         Bit_32(sizeof(group_entry_ptr)));
  217.  
  218.  group_hash_table   = (group_entry_ptr_array)
  219.                        allocate_memory(Addr(static_pool),
  220.                                        Bit_32(group_table_hash_size.val) *
  221.                                         Bit_32(sizeof(group_entry_ptr)));
  222.  
  223.  lname_hash_table   = (lname_entry_ptr_array)
  224.                        allocate_memory(Addr(static_pool),
  225.                                        Bit_32(lname_table_hash_size.val) *
  226.                                         Bit_32(sizeof(lname_entry_ptr)));
  227.  
  228.  lnames             = (lname_entry_ptr_array)
  229.                        allocate_memory(Addr(static_pool),
  230.                                        (Bit_32(max_lnames.val)+1L) *
  231.                                         Bit_32(sizeof(lname_entry_ptr)));
  232.  
  233.  public_hash_table  = (public_entry_ptr_array)
  234.                        allocate_memory(Addr(static_pool),
  235.                                        Bit_32(public_table_hash_size.val) *
  236.                                        Bit_32(sizeof(public_entry_ptr)));
  237.  
  238.  segment_hash_table = (segment_entry_ptr_array)
  239.                        allocate_memory(Addr(static_pool),
  240.                                        Bit_32(segment_table_hash_size.val) *
  241.                                         Bit_32(sizeof(segment_entry_ptr)));
  242.  
  243.  snames             = (lseg_ptr_array)
  244.                        allocate_memory(Addr(static_pool),
  245.                                        (Bit_32(max_segments.val)+1L) *
  246.                                         Bit_32(sizeof(lseg_ptr)));
  247.  
  248. /*+-------------------------------------------------------------------------+
  249.   |                                                                         |
  250.   |                  Miscellaneous Secondary Initialization                 |
  251.   |                                                                         |
  252.   +-------------------------------------------------------------------------+*/
  253.  
  254.  c_common_lname  = lookup_lname(8, (byte *) "c_common");
  255.  generated_lname = lookup_lname(11 ,(byte *) "(generated)");
  256.  none_lname      = lookup_lname(6,  (byte *) "(none)");
  257.  If case_ignore.val IsTrue
  258.   Then
  259.    BSS_lname                = lookup_lname(3, (byte *) "bss");
  260.    DGROUP_lname             = lookup_lname(6, (byte *) "dgroup");
  261.    FAR_BSS_lname            = lookup_lname(7, (byte *) "far_bss");
  262.    HUGE_BSS_lname           = lookup_lname(8, (byte *) "huge_bss");
  263.    STACK_lname              = lookup_lname(5, (byte *) "stack");
  264.    codeview_class_DEBSYM    = lookup_lname(6, (byte *) "debsym");
  265.    codeview_class_DEBTYP    = lookup_lname(6, (byte *) "debtyp");
  266.    codeview_segment_SYMBOLS = lookup_lname(9, (byte *) "$$symbols");
  267.    codeview_segment_TYPES   = lookup_lname(7, (byte *) "$$types");
  268.   Else
  269.    BSS_lname                = lookup_lname(3, (byte *) "BSS");
  270.    DGROUP_lname             = lookup_lname(6, (byte *) "DGROUP");
  271.    FAR_BSS_lname            = lookup_lname(7, (byte *) "FAR_BSS");
  272.    HUGE_BSS_lname           = lookup_lname(8, (byte *) "HUGE_BSS");
  273.    STACK_lname              = lookup_lname(5, (byte *) "STACK");
  274.    codeview_class_DEBSYM    = lookup_lname(6, (byte *) "DEBSYM");
  275.    codeview_class_DEBTYP    = lookup_lname(6, (byte *) "DEBTYP");
  276.    codeview_segment_SYMBOLS = lookup_lname(9, (byte *) "$$SYMBOLS");
  277.    codeview_segment_TYPES   = lookup_lname(7, (byte *) "$$TYPES");
  278.   EndIf;
  279.  exefile = (comfile.val IsFalse) AndIf (sysfile.val IsFalse);
  280.  return;
  281. EndCode
  282.  
  283.