Page 142 - DCAP507_SYSTEM_SOFTWARE
P. 142

System Software




                    Notes          {
                                   fscanf(fp1,  "%s%lx",  input,  &loc);
                                   while((strcmp(input,  "R")!=0))
                                   {
                                   strcpy(table[count].csect,  "");
                                   strcpy(table[count].sym_name,  input);
                                   table[count].add=loc+start;
                                   table[count++].length=0;
                                   fscanf(fp1,  "%s%lx",  input,  &loc);
                                   }
                                   while(strcmp(input,  "T")!=0)
                                   fscanf(fp1,  "%s",  input);
                                   }
                                   if(strcmp(input,  "T")==0)
                                   while(strcmp(input,  "E")!=0)
                                   fscanf(fp1,  "%s",  input);
                                   fscanf(fp1,  "%s",  input);
                                   start=start+length;
                                   }
                                   for(i=0;  i<count;  i++)
                                   fprintf(fp2,  "%s\t%s\t%lx\t%d\n",  table[i].csect,  table[i].sym_name,
                                   table[i].add,  table[i].length);
                                   printf("\nPass  1  of  Direct  Linking  Loaded  is  completed");
                                   getch();
                                   }

                                   Pass 2 – Load Text and Relocate/Link Address Constants

                                   After all the segments have been allocate locations and the external symbols have been defined
                                   by pass 1, it is possible to complete the loading by loading the text and changing (relocation or
                                   linking) address constants. At the end of pass 2, the loader will transmit control to the loaded
                                   program. The following simple rule is frequently used to find out where to begin execution:
                                   1.  If an address is stated on the END record, that address is used as the implementation start address.

                                   2.  Or else, execution will begin at the beginning of the first segment
                                   At the starting of pass 2 the program load address is initialized as in pass 1, and the execution
                                   start address

                                   (EXADDR) is set to IPLA. The records are read one by one from the object file left by pass 1.
                                   All of the five types of records is processed in a different way, as follows:

                                   ESD Records

                                   Each of the ESD record types is processed in a different way.





          136                               LOVELY PROFESSIONAL UNIVERSITY
   137   138   139   140   141   142   143   144   145   146   147