* 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 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));