+ Support library grouping in internal linker script, use it to load C libraries.

git-svn-id: trunk@22962 -
This commit is contained in:
sergei 2012-11-09 14:38:11 +00:00
parent 8ff1d76239
commit 49501413e1
2 changed files with 29 additions and 4 deletions

View File

@ -99,6 +99,8 @@ interface
FGroupStack : TFPObjectList;
procedure Load_ReadObject(const para:TCmdStr);
procedure Load_ReadStaticLibrary(const para:TCmdStr);
procedure Load_Group;
procedure Load_EndGroup;
procedure ParseScript_Handle;
procedure ParseScript_PostCheck;
procedure ParseScript_Load;
@ -1055,6 +1057,22 @@ Implementation
end;
procedure TInternalLinker.Load_Group;
var
group: TStaticLibrary;
begin
group:=TStaticLibrary.create_group;
TFPObjectList(FGroupStack.Last).Add(group);
FGroupStack.Add(group.GroupMembers);
end;
procedure TInternalLinker.Load_EndGroup;
begin
FGroupStack.Delete(FGroupStack.Count-1);
end;
procedure TInternalLinker.ParseScript_Handle;
var
s, para, keyword : String;
@ -1093,7 +1111,9 @@ Implementation
(keyword<>'EXESECTION') and
(keyword<>'ENDEXESECTION') and
(keyword<>'OBJSECTION') and
(keyword<>'HEADER')
(keyword<>'HEADER') and
(keyword<>'GROUP') and
(keyword<>'ENDGROUP')
then
Comment(V_Warning,'Unknown keyword "'+keyword+'" in "'+hp.str
+'" internal linker script');
@ -1179,6 +1199,10 @@ Implementation
UseStabs:=true
else if keyword='READSTATICLIBRARY' then
Load_ReadStaticLibrary(para)
else if keyword='GROUP' then
Load_Group
else if keyword='ENDGROUP' then
Load_EndGroup
else
handled:=false;
if handled then
@ -1353,11 +1377,11 @@ Implementation
Message1(exec_i_linking,outputname);
FlushOutput;
exeoutput:=CExeOutput.Create;
{ TODO: Load custom linker script}
DefaultLinkScript;
exeoutput:=CExeOutput.Create;
if (cs_link_map in current_settings.globalswitches) then
exemap:=texemap.create(current_module.mapfilename);

View File

@ -238,7 +238,6 @@ end;
function ModulesLinkToLibc:boolean;
var
hp: tmodule;
i: tlinkcontaineritem;
begin
{ This is called very early, ImportLibraryList is not yet merged into linkothersharedlibs.
The former contains library names qualified with prefix and suffix (coming from
@ -1270,6 +1269,7 @@ begin
if (cs_link_staticflag in current_settings.globalswitches) or
(linklibc and not reorder) then
begin
LinkScript.Concat('GROUP');
if (cs_link_staticflag in current_settings.globalswitches) then
begin
AddLibraryStatement('gcc');
@ -1277,6 +1277,7 @@ begin
end;
if linklibc and not reorder then
AddLibraryStatement('c');
LinkScript.Concat('ENDGROUP');
end;
{ objects which must be at the end }