Przeglądaj źródła

* refactored the internal linker ar object reader object creation to allow using
different 'ar' implementations under different platforms
* use the omflib reader instead of the ar reader in the msdos internal linker

git-svn-id: trunk@31322 -

nickysn 10 lat temu
rodzic
commit
d4a4b9a57b

+ 7 - 4
compiler/link.pas

@@ -33,7 +33,8 @@ interface
       fmodule,
       globtype,
       ldscript,
-      ogbase;
+      ogbase,
+      owbase;
 
     Type
       TLinkerInfo=record
@@ -93,6 +94,7 @@ interface
       private
          FCExeOutput : TExeOutputClass;
          FCObjInput  : TObjInputClass;
+         FCArObjectReader : TObjectReaderClass;
          { Libraries }
          FStaticLibraryList : TFPObjectList;
          FImportLibraryList : TFPHashObjectList;
@@ -115,6 +117,7 @@ interface
          linkscript : TCmdStrList;
          ScriptCount : longint;
          IsHandled : PBooleanArray;
+         property CArObjectReader:TObjectReaderClass read FCArObjectReader write FCArObjectReader;
          property CObjInput:TObjInputClass read FCObjInput write FCObjInput;
          property CExeOutput:TExeOutputClass read FCExeOutput write FCExeOutput;
          property StaticLibraryList:TFPObjectList read FStaticLibraryList;
@@ -159,7 +162,7 @@ Implementation
 {$endif hasUnix}
       script,globals,verbose,comphook,ppu,fpccrc,
       aasmbase,aasmtai,aasmdata,aasmcpu,
-      owbase,owar,ogmap;
+      ogmap;
 
     var
       CLinker : array[tlink] of TLinkerClass;
@@ -1094,7 +1097,7 @@ Implementation
 
     procedure TInternalLinker.Load_ReadStaticLibrary(const para:TCmdStr;asneededflag:boolean);
       var
-        objreader : TArObjectReader;
+        objreader : TObjectReader;
         objinput: TObjInput;
         objdata: TObjData;
         ScriptLexer: TScriptLexer;
@@ -1105,7 +1108,7 @@ Implementation
         if copy(ExtractFileName(para),1,6)='libimp' then
           exit;
         Comment(V_Tried,'Opening library '+para);
-        objreader:=TArObjectreader.create(para,true);
+        objreader:=CArObjectreader.createAr(para,true);
         if ErrorCount>0 then
           exit;
         if objreader.isarchive then

+ 3 - 1
compiler/oglx.pas

@@ -158,7 +158,8 @@ implementation
 uses
        strings,
        cutils,verbose,
-       globtype,globals,fmodule;
+       globtype,globals,fmodule,
+       owar;
 
 
 {****************************************************************************
@@ -376,6 +377,7 @@ end;
     constructor Tlxlinker.Create;
       begin
         inherited Create;
+        CArObjectReader:=TArObjectReader;
         exeoutput:=Tlxexeoutput.createos2;
       end;
 

+ 9 - 3
compiler/owar.pas

@@ -76,13 +76,13 @@ type
   protected
     function getfilename:string;override;
     function GetPos: longint;override;
+    function GetIsArchive: boolean; override;
   public
-    constructor create(const Aarfn:string;allow_nonar:boolean=false);
+    constructor createAr(const Aarfn:string;allow_nonar:boolean=false);override;
     destructor  destroy;override;
     function  openfile(const fn:string):boolean;override;
     procedure closefile;override;
     procedure seek(len:longint);override;
-    property isarchive: boolean read isar;
   end;
 
 
@@ -318,7 +318,7 @@ implementation
 *****************************************************************************}
 
 
-    constructor tarobjectreader.create(const Aarfn:string;allow_nonar:boolean);
+    constructor tarobjectreader.createAr(const Aarfn:string;allow_nonar:boolean);
       var
         magic:array[0..sizeof(armagic)-1] of char;
       begin
@@ -364,6 +364,12 @@ implementation
       end;
 
 
+    function tarobjectreader.GetIsArchive: boolean;
+      begin
+        Result:=isar;
+      end;
+
+
     function tarobjectreader.DecodeMemberName(ahdr:TArHdr):string;
       var
         hs : string;

+ 17 - 0
compiler/owbase.pas

@@ -67,8 +67,10 @@ type
   protected
     function getfilename : string;virtual;
     function GetPos: longint;virtual;
+    function GetIsArchive: boolean;virtual;
   public
     constructor create;
+    constructor createAr(const Aarfn:string;allow_nonar:boolean=false);virtual;
     destructor  destroy;override;
     function  openfile(const fn:string):boolean;virtual;
     procedure closefile;virtual;
@@ -78,8 +80,11 @@ type
     property filename : string read getfilename;
     property size:longint read bufmax;
     property Pos:longint read GetPos;
+    property IsArchive: boolean read GetIsArchive;
   end;
 
+  tobjectreaderclass = class of tobjectreader;
+
 implementation
 
 uses
@@ -241,6 +246,12 @@ begin
 end;
 
 
+constructor tobjectreader.createAr(const Aarfn:string;allow_nonar:boolean=false);
+begin
+  InternalError(2015081401);
+end;
+
+
 function tobjectreader.openfile(const fn:string):boolean;
 begin
   openfile:=false;
@@ -317,4 +328,10 @@ function tobjectreader.GetPos: longint;
     Result:=bufidx;
   end;
 
+
+function tobjectreader.GetIsArchive: boolean;
+  begin
+    Result:=false;
+  end;
+
 end.

+ 8 - 3
compiler/owomflib.pas

@@ -83,13 +83,13 @@ type
     procedure ReadDictionary(DictionaryOffset: DWord; DictionarySizeInBlocks: Word);
   protected
     function GetPos: longint;override;
+    function GetIsArchive: boolean;override;
   public
-    constructor create(const Aarfn:string;allow_nonar:boolean=false);
+    constructor createAr(const Aarfn:string;allow_nonar:boolean=false);override;
     destructor  destroy;override;
     function  openfile(const fn:string):boolean;override;
     procedure closefile;override;
     procedure seek(len:longint);override;
-    property isarchive: boolean read islib;
   end;
 
 implementation
@@ -406,7 +406,12 @@ implementation
       result:=inherited GetPos-CurrMemberPos;
     end;
 
-  constructor TOmfLibObjectReader.create(const Aarfn: string; allow_nonar: boolean);
+  function TOmfLibObjectReader.GetIsArchive: boolean;
+    begin
+      result:=islib;
+    end;
+
+  constructor TOmfLibObjectReader.createAr(const Aarfn: string; allow_nonar: boolean);
     var
       RecType: Byte;
     begin

+ 2 - 1
compiler/systems/t_go32v2.pas

@@ -34,7 +34,7 @@ implementation
        cutils,cfileutl,cclasses,
        globtype,globals,systems,verbose,script,
        fmodule,i_go32v2,
-       link,ogcoff,aasmbase;
+       link,ogcoff,owar,aasmbase;
 
     type
       TInternalLinkerGo32v2=class(TInternallinker)
@@ -60,6 +60,7 @@ implementation
     constructor TInternalLinkerGo32v2.Create;
       begin
         inherited Create;
+        CArObjectReader:=TArObjectReader;
         CExeoutput:=TDJCoffexeoutput;
         CObjInput:=TDJCoffObjInput;
       end;

+ 2 - 1
compiler/systems/t_linux.pas

@@ -82,7 +82,7 @@ implementation
     aasmbase,aasmtai,aasmcpu,cpubase,
     cgbase,cgobj,cgutils,ogbase,ncgutil,
     comprsrc,
-    ogelf,
+    ogelf,owar,
     rescmn, i_linux
     ;
 
@@ -1435,6 +1435,7 @@ begin
   SetupLibrarySearchPath;
   SetupDynlinker(dynlinker,libctype);
 
+  CArObjectReader:=TArObjectReader;
   CExeOutput:=ElfExeOutputClass;
   CObjInput:=TElfObjInput;
 

+ 2 - 1
compiler/systems/t_msdos.pas

@@ -37,7 +37,7 @@ implementation
        globtype,globals,systems,verbose,script,
        fmodule,i_msdos,
        link,aasmbase,cpuinfo,
-       omfbase,ogomf;
+       omfbase,ogomf,owomflib;
 
     type
       { Borland TLINK support }
@@ -424,6 +424,7 @@ end;
 constructor TInternalLinkerMsDos.create;
 begin
   inherited create;
+  CArObjectReader:=TOmfLibObjectReader;
   CExeOutput:=TMZExeOutput;
   CObjInput:=TOmfObjInput;
 end;

+ 2 - 1
compiler/systems/t_nwm.pas

@@ -97,7 +97,7 @@ implementation
     verbose,systems,globtype,globals,
     symconst,script,
     fmodule,aasmbase,aasmtai,aasmdata,aasmcpu,cpubase,symsym,symdef,
-    import,export,link,i_nwm,ogbase, ogcoff, ognlm, cclasses
+    import,export,link,i_nwm,ogbase, ogcoff, ognlm, owar, cclasses
     {$ifdef netware} ,dos {$endif}
     ;
 
@@ -593,6 +593,7 @@ end;
     constructor TInternalLinkerNetware.Create;
       begin
         inherited Create;
+        CArObjectReader:=TArObjectReader;
         CExeoutput:=TNLMexeoutput;
         CObjInput:=TNLMCoffObjInput;
         nlmSpecialSymbols_Segments := TFPHashList.create;

+ 1 - 0
compiler/systems/t_symbian.pas

@@ -56,6 +56,7 @@ implementation
     constructor TInternalLinkerSymbian.Create;
       begin
         inherited Create;
+        CArObjectReader:=TArObjectReader;
         CExeoutput:=TPECoffexeoutput;
         CObjInput:=TPECoffObjInput;
       end;

+ 1 - 0
compiler/systems/t_win.pas

@@ -933,6 +933,7 @@ implementation
     constructor TInternalLinkerWin.Create;
       begin
         inherited Create;
+        CArObjectReader:=TArObjectReader;
         CExeoutput:=TPECoffexeoutput;
         CObjInput:=TPECoffObjInput;
       end;