瀏覽代碼

* the code for determining the code, data and bss sizes in the internal linker
moved to virtual methods, to allow for platform specific overrides (e.g. for
supporting section names, other than '.text', '.data' and '.bss', etc.)

git-svn-id: trunk@31321 -

nickysn 10 年之前
父節點
當前提交
8206c6dbd0
共有 1 個文件被更改,包括 30 次插入9 次删除
  1. 30 9
      compiler/link.pas

+ 30 - 9
compiler/link.pas

@@ -122,6 +122,9 @@ interface
          procedure DefaultLinkScript;virtual;abstract;
          procedure ScriptAddGenericSections(secnames:string);
          procedure ScriptAddSourceStatements(AddSharedAsStatic:boolean);virtual;
+         function GetCodeSize(aExeOutput: TExeOutput): QWord;virtual;
+         function GetDataSize(aExeOutput: TExeOutput): QWord;virtual;
+         function GetBssSize(aExeOutput: TExeOutput): QWord;virtual;
       public
          IsSharedLibrary : boolean;
          UseStabs : boolean;
@@ -983,6 +986,30 @@ Implementation
       end;
 
 
+    function TInternalLinker.GetCodeSize(aExeOutput: TExeOutput): QWord;
+      begin
+        Result:=aExeOutput.findexesection('.text').size;
+      end;
+
+
+    function TInternalLinker.GetDataSize(aExeOutput: TExeOutput): QWord;
+      begin
+        Result:=aExeOutput.findexesection('.data').size;
+      end;
+
+
+    function TInternalLinker.GetBssSize(aExeOutput: TExeOutput): QWord;
+      var
+        bsssec: TExeSection;
+      begin
+        bsssec:=aExeOutput.findexesection('.bss');
+        if assigned(bsssec) then
+          Result:=bsssec.size
+        else
+          Result:=0;
+      end;
+
+
     procedure TInternalLinker.ParseLdScript(src:TScriptLexer);
       var
         asneeded: boolean;
@@ -1420,7 +1447,6 @@ Implementation
         myexit;
       var
         bsssize : aword;
-        bsssec  : TExeSection;
         dbgname : TCmdStr;
       begin
         result:=false;
@@ -1500,14 +1526,9 @@ Implementation
         { Post check that everything was handled }
         ParseScript_PostCheck;
 
-{ TODO: fixed section names}
-        status.codesize:=exeoutput.findexesection('.text').size;
-        status.datasize:=exeoutput.findexesection('.data').size;
-        bsssec:=exeoutput.findexesection('.bss');
-        if assigned(bsssec) then
-          bsssize:=bsssec.size
-        else
-          bsssize:=0;
+        status.codesize:=GetCodeSize(exeoutput);
+        status.datasize:=GetDataSize(exeoutput);
+        bsssize:=GetBssSize(exeoutput);
 
         { Executable info }
         Message1(execinfo_x_codesize,tostr(status.codesize));