Browse Source

* Factored a common linker script building block into separate method.

git-svn-id: trunk@21730 -
sergei 13 years ago
parent
commit
346fbef445
2 changed files with 31 additions and 22 deletions
  1. 30 0
      compiler/link.pas
  2. 1 22
      compiler/systems/t_win.pas

+ 30 - 0
compiler/link.pas

@@ -116,6 +116,7 @@ interface
          property ImportLibraryList:TFPHashObjectList read FImportLibraryList;
          procedure DefaultLinkScript;virtual;abstract;
          procedure ConcatGenericSections(secnames:string);
+         procedure ScriptAddSourceStatements(AddSharedAsStatic:boolean);virtual;
       public
          IsSharedLibrary : boolean;
          UseStabs : boolean;
@@ -897,6 +898,35 @@ Implementation
       end;
 
 
+    procedure TInternalLinker.ScriptAddSourceStatements(AddSharedAsStatic:boolean);
+      var
+        s,s2: TCmdStr;
+      begin
+        while not ObjectFiles.Empty do
+          begin
+            s:=ObjectFiles.GetFirst;
+            if s<>'' then
+              LinkScript.Concat('READOBJECT '+MaybeQuoted(s));
+          end;
+        while not StaticLibFiles.Empty do
+          begin
+            s:=StaticLibFiles.GetFirst;
+            if s<>'' then
+              LinkScript.Concat('READSTATICLIBRARY '+MaybeQuoted(s));
+          end;
+        if not AddSharedAsStatic then
+          exit;
+        while not SharedLibFiles.Empty do
+          begin
+            S:=SharedLibFiles.GetFirst;
+            if FindLibraryFile(s,target_info.staticClibprefix,target_info.staticClibext,s2) then
+              LinkScript.Concat('READSTATICLIBRARY '+MaybeQuoted(s2))
+            else
+              Comment(V_Error,'Import library not found for '+S);
+          end;
+      end;
+
+
     procedure TInternalLinker.Load_ReadObject(const para:TCmdStr);
       var
         objdata   : TObjData;

+ 1 - 22
compiler/systems/t_win.pas

@@ -939,31 +939,10 @@ implementation
 
 
     procedure TInternalLinkerWin.DefaultLinkScript;
-      var
-        s,s2 : TCmdStr;
       begin
+        ScriptAddSourceStatements(true);
         with LinkScript do
           begin
-            while not ObjectFiles.Empty do
-              begin
-                s:=ObjectFiles.GetFirst;
-                if s<>'' then
-                  Concat('READOBJECT '+MaybeQuoted(s));
-              end;
-            while not StaticLibFiles.Empty do
-              begin
-                s:=StaticLibFiles.GetFirst;
-                if s<>'' then
-                  Concat('READSTATICLIBRARY '+MaybeQuoted(s));
-              end;
-            While not SharedLibFiles.Empty do
-              begin
-                S:=SharedLibFiles.GetFirst;
-                if FindLibraryFile(s,target_info.staticClibprefix,target_info.staticClibext,s2) then
-                  Concat('READSTATICLIBRARY '+MaybeQuoted(s2))
-                else
-                  Comment(V_Error,'Import library not found for '+S);
-              end;
             if IsSharedLibrary then
               Concat('ISSHAREDLIBRARY');
             ConcatEntryName;