* 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 -
This commit is contained in:
nickysn 2015-08-13 15:07:24 +00:00
parent e59c164844
commit 8206c6dbd0

View File

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