DataMuseum.dk

Presents historical artifacts from the history of:

Bogika Butler

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Bogika Butler

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download

⟦1ad8d74d9⟧ TextFile

    Length: 11392 (0x2c80)
    Types: TextFile
    Names: »LNKP2.BAK«

Derivation

└─⟦d36b687c5⟧ Bits:30009789/_.ft.Ibm2.50007363.imd Mogens Pelles Zilog 80,000 / EOS projekt
    └─⟦this⟧ »LNKP2.BAK« 

TextFile

(******************************************************************************)
(*                                                                            *)
(*   Copyright (1985) by Metanic Aps., Denmark                                *)
(*                                                                            *)
(*   Author: Lars Gregers Jakobsen.                                           *)
(*                                                                            *)
(******************************************************************************)

   PROCEDURE Pass2(VAR Status: StatusType
                  ;VAR TargetFile: FileType
                  ;VAR LogFile: LogFileType
                  );

      LABEL
         999;

      VAR
         SegmentInx: SegmentNoType;
         ModuleInx: ModuleTableIndexType;
         Crid: BitMappedFileType;  (*Composite relocation import directory*)
         Covr: FileType;           (*Composite overrun store*)

(*$I B:LNKDF5.PAS  Bit Map Buffer Test Output *)
(*$I B:LNKDF6.PAS  Bit Map Access Primitives  *)

      PROCEDURE LinkSection(VAR Status: StatusType
                           ;VAR TargetFile: FileType
                           ;VAR LogFile: LogFileType
                           ;VAR Crid: BitMappedFileType
                           ;VAR Covr: FileType
                           ;VAR SCTrec: SectionTableRecordType
                           ;VAR MDTrec: ModuleTableRecordType
                           );

         LABEL
            99;

         VAR
            Oimg: FileType;
            Orid: BitMappedFileType;
            Oovr: FileType;
            ImageUnit: ImageUnitType;
            QuadImageUnit: QuadImageUnitType;
            Relocatable: boolean;
            Importable: boolean;
            Index: i8;
            Address: FileAddressType; (*relative to current obj. section*)
            LocalImageSize: FileAddressType;
            OvrIndex: QuadImageUnitType;


        BEGIN (*LINKSECTION*)
         WITH MDTrec, SCTrec DO
           BEGIN
            IF ImageSize > 0 THEN
              BEGIN
               FilAsg(Oimg, FileNameTable(.FileNameReference.));
               FilRst(Status, Oimg);
               FilSeek(Status, Oimg, CurrentFileAddress);
               CurrentFileAddress := CurrentFileAddress + ImageSize * 4;

               WITH Orid DO
                 BEGIN
                  assign(F, FileNameTable(.FileNameReference.));
                  reset(F);
                  seek(F, CurrentFileAddress);
                  WITH B DO
                    BEGIN
                     P := 16;
                     I := (..);
                     read(F, Y1);
                    END;
                 END;
               CurrentFileAddress := CurrentFileAddress + ImageSize;

               IF OvrSize > 0 THEN
                 BEGIN
                  FilAsg(Oovr, FileNameTable(.FileNameReference.));
                  FilRst(Status, Oovr);
                  FilSeek(Status, Oovr, CurrentFileAddress);
                  CurrentFileAddress := CurrentFileAddress + OvrSize;
                 END
               ELSE
                  Oovr.P := CurrentFileAddress;

               (*CurrentFileAddress now reflects starting position of
                 next section in file if any*)

               Address := 0;
               LocalImageSize := (ImageSize - 1) * 4;
               WHILE (Address <= LocalImageSize) and (Status = (..)) DO
                 BEGIN
                  BMG2(Orid, Relocatable, Importable);
                  IF Relocatable <> Importable THEN
                    BEGIN
                     BMG6(Orid, Index);
                     FGi32(Status, Oimg, QuadImageUnit);
                     IF Relocatable THEN
                        (* Relocate *)
                        IF Index IN (.1..NooSegments.) THEN
                           WITH SectionTable(.SCTBase + Index.) DO
                              QuadImageUnit := QuadImageUnit + RelocationConstant
                        ELSE
                           Status := Status + (.BadRelocationCode.)
                     ELSE
                        (* Import *)
                       BEGIN (*IMPORT*)
                        IF Index = OvrCode THEN
                           IF Oovr.P  < CurrentFileAddress - 3 THEN
                              FGi32(Status, Oovr, OvrIndex)
                           ELSE
                              Status := Status + (.UnexpectedEof.)
                        ELSE
                           OvrIndex := Index;
                        IF OvrIndex IN (.1..NooExternalImportSymbols.) THEN
                           WITH ValueTable(.ExternalImportTable(.EITOffset + OvrIndex
                                                               .).SymbolNo
                                          .) DO
                              IF SegmentNo > UnResolved THEN
                                BEGIN
                                 QuadImageUnit := QuadImageUnit + Value; (*?* + ? *)
                                 Importable := false;
                                 Index := SegmentNo;
                                END
                              ELSE
                                 IF Value IN (.0..63.) THEN
                                    Index := Value
                                 ELSE
                                   BEGIN
                                    Index := OvrCode;
                                    FPi32(Covr, Value);
                                   END
                        ELSE
                           Status := Status + (.BadImportCode.)
                       END;  (*IMPORT*)
                     FPi32(TargetFile, QuadImageUnit);
                     BMP2(Crid, Relocatable, Importable);
                     BMP6(Crid, Index);
                     Address := Address + 4;
                    END
                  ELSE
                     IF Relocatable THEN
                       BEGIN
                        Status := Status + (.Baddibit.);
                        GOTO 99; (*EXIT procedure*)
                       END
                     ELSE
                       BEGIN
                        FGi8(Status, Oimg, ImageUnit);
                        FPi8(TargetFile, ImageUnit);
                        BMP2(Crid, Relocatable, Importable);
                        Address := Address + 1;
                       END;
                 END;
               LocalImageSize := ImageSize * 4;
               WHILE (Address < LocalImageSize) and (Status = (..)) DO
                 BEGIN
                  BMG2(Orid, Relocatable, Importable);
                  IF Relocatable or Importable THEN
                    BEGIN
                     Status := Status + (.Baddibit.);
                     GOTO 99; (*EXIT procedure*)
                    END
                  ELSE
                    BEGIN
                     FGi8(Status, Oimg, ImageUnit);
                     FPi8(TargetFile, ImageUnit);
                     BMP2(Crid, Relocatable, Importable);
                     Address := Address + 1;
                    END;
                 END;
              END; (* IF ImageSize > 0 THEN *)
99:        END; (* WITH MDTrec, SCTrec DO *)
        END;  (*LINKSECTION*)

      PROCEDURE CopyBuffer(VAR Status: StatusType
                          ;VAR Buffer: BasicFileType
                          ;VAR TargetFile: FileType
                          ;VAR Size: SizeType
                          );

         VAR
            Item: i8;
            Start: FileAddressType;

        BEGIN (*COPYBUFFER*)
         reset(Buffer);
         Start := TargetFile.P;
         WHILE not eof(Buffer) DO
           BEGIN
            read(Buffer, Item);
            FPi8(TargetFile, Item); (*Advancing TargetFile.P*)
           END;
         Size := TargetFile.P - Start;
         IF test((.0,20.)) THEN
           BEGIN
            writeln(TestOut, 'CPYBUF   ', 'Start= ', Start:1
                                        , ' End= ', TargetFile.P:1
                                        , ' Size= ', Size:1
                   );
           END;
        END;  (*COPYBUFFER*)

      PROCEDURE UPDINX(VAR Status: StatusType
                       VAR TargetFile: FileType
                      );

         VAR
            ModuleSize: i32;
            ModuleName: ModuleNameType;
            SegmentInx: SegmentNoType;

        BEGIN (*UPDINX*)
         ModuleSize := TargetFile.P - 4;
         update(TargetFile.F);
         FilSeek(Status, TargetFile, 8);
         IF Status = (..) THEN
           BEGIN
            FPi32(TargetFile, ModuleSize);
            FPi32(TargetFile, CurSegmentCount);
            FPi32(TargetFile, NooExpSymbols);
            FPi32(TargetFile, NooExiSymbols);
            FGsym(Status, TargetFile, ModuleName); (*skip past name*)
            IF Status = (..) THEN
               FOR SegmentInx := 1 TO CurSegmentCount DO
                  WITH SectionTable(.TargetSectionOffset + SegmentInx.) DO
                    BEGIN
                     FPi32(TargetFile, ImageSize);
                     FPi32(TargetFile, OvrSize);
                    END;
           END;
        END;  (*UPDINX*)

     BEGIN (*PASS2*)
      FOR SegmentInx := 1 TO CurSegmentCount DO
        BEGIN
         WITH Crid DO
           BEGIN
            rewrite(F);
            WITH B DO
              BEGIN
               P := 16;
               I := (..)
              END
           END;
         FilRwt(Covr);
         FOR ModuleInx := 1 TO TargetModuleNo - 1 DO
           BEGIN
            IF test((.0,20.)) THEN
              BEGIN
               write(TestOut, 'Pass-2   '); TSTstat(Status); TSTindt;
               writeln(TestOut, 'SgmInx= ', SegmentInx:1
                              , ' MdlInx= ', ModuleInx:1
                              );
               TSTindt; TSTindt; TSTindt;
               TSTmdt(ModuleInx);
               TSTindt; TSTindt; TSTindt;
               TSTsct(ModuleTable(.ModuleInx.).SCTBase + SegmentInx);
              END;
            IF (SectionTable(.ModuleTable(.ModuleInx
                                         .).SCTBase + SegmentInx
                            .).ModuleNo = ModuleInx) THEN
              BEGIN
               LinkSection(Status, TargetFile, LogFile, Crid, Covr
                          ,SectionTable(.ModuleTable(.ModuleInx
                                                     .).SCTBase + SegmentInx
                                       .)
                          ,ModuleTable(.ModuleInx.)
                          );
               IF Status <> (..) THEN
                  GOTO 999; (*************  EXIT BOTH FOR LOOPS **************)
              END;
           END;
         WITH SectionTable(.TargetSectionOffset + SegmentInx.) DO
           BEGIN
            CopyBuffer(Status, Crid.F, TargetFile, ImageSize);
            CopyBuffer(Status, Covr.F, TargetFile, OvrSize);
           END;
        END;
999:
      (*backpatch info to target.inx*)
      UPDINX(Status, TargetFile);

     END;  (*PASS2*)
«eof»