mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-01 03:50:35 +02:00
* record symbols that need to remain in their original order, and on Darwin
pass them to the linker so it does not reorder them o fixes resource strings on Darwin when using LTO (this used to reorder the resource string symbols, so they no longer all appeared between the START and END symbols for their compilation module) git-svn-id: trunk@41907 -
This commit is contained in:
parent
33d57ac646
commit
d150869dea
@ -1115,6 +1115,7 @@ implementation
|
|||||||
secname:=make_mangledname(basename,st,'2_'+itemname);
|
secname:=make_mangledname(basename,st,'2_'+itemname);
|
||||||
exclude(options,tcalo_vectorized_dead_strip_item);
|
exclude(options,tcalo_vectorized_dead_strip_item);
|
||||||
end;
|
end;
|
||||||
|
current_module.linkorderedsymbols.concat(sym.Name);
|
||||||
finalize_asmlist(sym,def,sectype,secname,alignment,options);
|
finalize_asmlist(sym,def,sectype,secname,alignment,options);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -120,6 +120,7 @@ const
|
|||||||
ibwpofile = 84;
|
ibwpofile = 84;
|
||||||
ibmoduleoptions = 85;
|
ibmoduleoptions = 85;
|
||||||
ibunitimportsyms = 86;
|
ibunitimportsyms = 86;
|
||||||
|
iborderedsymbols = 87;
|
||||||
|
|
||||||
ibmainname = 90;
|
ibmainname = 90;
|
||||||
ibsymtableoptions = 91;
|
ibsymtableoptions = 91;
|
||||||
|
@ -169,7 +169,8 @@ interface
|
|||||||
loaded_from : tmodule;
|
loaded_from : tmodule;
|
||||||
_exports : tlinkedlist;
|
_exports : tlinkedlist;
|
||||||
dllscannerinputlist : TFPHashList;
|
dllscannerinputlist : TFPHashList;
|
||||||
resourcefiles : TCmdStrList;
|
resourcefiles,
|
||||||
|
linkorderedsymbols : TCmdStrList;
|
||||||
linkunitofiles,
|
linkunitofiles,
|
||||||
linkunitstaticlibs,
|
linkunitstaticlibs,
|
||||||
linkunitsharedlibs,
|
linkunitsharedlibs,
|
||||||
@ -564,6 +565,7 @@ implementation
|
|||||||
used_units:=TLinkedList.Create;
|
used_units:=TLinkedList.Create;
|
||||||
dependent_units:=TLinkedList.Create;
|
dependent_units:=TLinkedList.Create;
|
||||||
resourcefiles:=TCmdStrList.Create;
|
resourcefiles:=TCmdStrList.Create;
|
||||||
|
linkorderedsymbols:=TCmdStrList.Create;
|
||||||
linkunitofiles:=TLinkContainer.Create;
|
linkunitofiles:=TLinkContainer.Create;
|
||||||
linkunitstaticlibs:=TLinkContainer.Create;
|
linkunitstaticlibs:=TLinkContainer.Create;
|
||||||
linkunitsharedlibs:=TLinkContainer.Create;
|
linkunitsharedlibs:=TLinkContainer.Create;
|
||||||
@ -685,6 +687,7 @@ implementation
|
|||||||
used_units.free;
|
used_units.free;
|
||||||
dependent_units.free;
|
dependent_units.free;
|
||||||
resourcefiles.Free;
|
resourcefiles.Free;
|
||||||
|
linkorderedsymbols.Free;
|
||||||
linkunitofiles.Free;
|
linkunitofiles.Free;
|
||||||
linkunitstaticlibs.Free;
|
linkunitstaticlibs.Free;
|
||||||
linkunitsharedlibs.Free;
|
linkunitsharedlibs.Free;
|
||||||
@ -841,6 +844,8 @@ implementation
|
|||||||
dependent_units:=TLinkedList.Create;
|
dependent_units:=TLinkedList.Create;
|
||||||
resourcefiles.Free;
|
resourcefiles.Free;
|
||||||
resourcefiles:=TCmdStrList.Create;
|
resourcefiles:=TCmdStrList.Create;
|
||||||
|
linkorderedsymbols.Free;
|
||||||
|
linkorderedsymbols:=TCmdStrList.Create;;
|
||||||
pendingspecializations.free;
|
pendingspecializations.free;
|
||||||
pendingspecializations:=tfphashobjectlist.create(false);
|
pendingspecializations:=tfphashobjectlist.create(false);
|
||||||
if assigned(waitingforunit) and
|
if assigned(waitingforunit) and
|
||||||
|
@ -96,6 +96,7 @@ interface
|
|||||||
procedure writederefdata;
|
procedure writederefdata;
|
||||||
procedure writeImportSymbols;
|
procedure writeImportSymbols;
|
||||||
procedure writeResources;
|
procedure writeResources;
|
||||||
|
procedure writeOrderedSymbols;
|
||||||
procedure writeunitimportsyms;
|
procedure writeunitimportsyms;
|
||||||
procedure writeasmsyms(kind:tunitasmlisttype;list:tfphashobjectlist);
|
procedure writeasmsyms(kind:tunitasmlisttype;list:tfphashobjectlist);
|
||||||
procedure writeextraheader;
|
procedure writeextraheader;
|
||||||
@ -106,6 +107,7 @@ interface
|
|||||||
procedure readderefdata;
|
procedure readderefdata;
|
||||||
procedure readImportSymbols;
|
procedure readImportSymbols;
|
||||||
procedure readResources;
|
procedure readResources;
|
||||||
|
procedure readOrderedSymbols;
|
||||||
procedure readwpofile;
|
procedure readwpofile;
|
||||||
procedure readunitimportsyms;
|
procedure readunitimportsyms;
|
||||||
procedure readasmsyms;
|
procedure readasmsyms;
|
||||||
@ -946,6 +948,20 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tppumodule.writeOrderedSymbols;
|
||||||
|
var
|
||||||
|
res : TCmdStrListItem;
|
||||||
|
begin
|
||||||
|
res:=TCmdStrListItem(linkorderedsymbols.First);
|
||||||
|
while res<>nil do
|
||||||
|
begin
|
||||||
|
ppufile.putstring(res.FPStr);
|
||||||
|
res:=TCmdStrListItem(res.Next);
|
||||||
|
end;
|
||||||
|
ppufile.writeentry(iborderedsymbols);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure tppumodule.writeunitimportsyms;
|
procedure tppumodule.writeunitimportsyms;
|
||||||
var
|
var
|
||||||
i : longint;
|
i : longint;
|
||||||
@ -1284,6 +1300,13 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tppumodule.readOrderedSymbols;
|
||||||
|
begin
|
||||||
|
while not ppufile.endofentry do
|
||||||
|
linkorderedsymbols.Concat(ppufile.getstring);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure tppumodule.readwpofile;
|
procedure tppumodule.readwpofile;
|
||||||
var
|
var
|
||||||
orgwpofilename: string;
|
orgwpofilename: string;
|
||||||
@ -1430,6 +1453,8 @@ var
|
|||||||
readderefdata;
|
readderefdata;
|
||||||
ibresources:
|
ibresources:
|
||||||
readResources;
|
readResources;
|
||||||
|
iborderedsymbols:
|
||||||
|
readOrderedSymbols;
|
||||||
ibwpofile:
|
ibwpofile:
|
||||||
readwpofile;
|
readwpofile;
|
||||||
ibendinterface :
|
ibendinterface :
|
||||||
@ -1550,6 +1575,7 @@ var
|
|||||||
writelinkcontainer(linkotherframeworks,iblinkotherframeworks,true);
|
writelinkcontainer(linkotherframeworks,iblinkotherframeworks,true);
|
||||||
writeImportSymbols;
|
writeImportSymbols;
|
||||||
writeResources;
|
writeResources;
|
||||||
|
writeOrderedSymbols;
|
||||||
ppufile.do_crc:=true;
|
ppufile.do_crc:=true;
|
||||||
|
|
||||||
{ generate implementation deref data, the interface deref data is
|
{ generate implementation deref data, the interface deref data is
|
||||||
|
@ -55,7 +55,8 @@ interface
|
|||||||
ObjectFiles,
|
ObjectFiles,
|
||||||
SharedLibFiles,
|
SharedLibFiles,
|
||||||
StaticLibFiles,
|
StaticLibFiles,
|
||||||
FrameworkFiles : TCmdStrList;
|
FrameworkFiles,
|
||||||
|
OrderedSymbols: TCmdStrList;
|
||||||
Constructor Create;virtual;
|
Constructor Create;virtual;
|
||||||
Destructor Destroy;override;
|
Destructor Destroy;override;
|
||||||
procedure AddModuleFiles(hp:tmodule);
|
procedure AddModuleFiles(hp:tmodule);
|
||||||
@ -65,6 +66,7 @@ interface
|
|||||||
Procedure AddStaticCLibrary(const S : TCmdStr);
|
Procedure AddStaticCLibrary(const S : TCmdStr);
|
||||||
Procedure AddSharedCLibrary(S : TCmdStr);
|
Procedure AddSharedCLibrary(S : TCmdStr);
|
||||||
Procedure AddFramework(S : TCmdStr);
|
Procedure AddFramework(S : TCmdStr);
|
||||||
|
Procedure AddOrderedSymbol(const s: TCmdStr);
|
||||||
procedure AddImportSymbol(const libname,symname,symmangledname:TCmdStr;OrdNr: longint;isvar:boolean);virtual;
|
procedure AddImportSymbol(const libname,symname,symmangledname:TCmdStr;OrdNr: longint;isvar:boolean);virtual;
|
||||||
Procedure InitSysInitUnitName;virtual;
|
Procedure InitSysInitUnitName;virtual;
|
||||||
Function MakeExecutable:boolean;virtual;
|
Function MakeExecutable:boolean;virtual;
|
||||||
@ -353,6 +355,7 @@ Implementation
|
|||||||
SharedLibFiles:=TCmdStrList.Create_no_double;
|
SharedLibFiles:=TCmdStrList.Create_no_double;
|
||||||
StaticLibFiles:=TCmdStrList.Create_no_double;
|
StaticLibFiles:=TCmdStrList.Create_no_double;
|
||||||
FrameworkFiles:=TCmdStrList.Create_no_double;
|
FrameworkFiles:=TCmdStrList.Create_no_double;
|
||||||
|
OrderedSymbols:=TCmdStrList.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -362,6 +365,8 @@ Implementation
|
|||||||
SharedLibFiles.Free;
|
SharedLibFiles.Free;
|
||||||
StaticLibFiles.Free;
|
StaticLibFiles.Free;
|
||||||
FrameworkFiles.Free;
|
FrameworkFiles.Free;
|
||||||
|
OrderedSymbols.Free;
|
||||||
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -371,6 +376,7 @@ Implementation
|
|||||||
i,j : longint;
|
i,j : longint;
|
||||||
ImportLibrary : TImportLibrary;
|
ImportLibrary : TImportLibrary;
|
||||||
ImportSymbol : TImportSymbol;
|
ImportSymbol : TImportSymbol;
|
||||||
|
cmdstritem: TCmdStrListItem;
|
||||||
begin
|
begin
|
||||||
with hp do
|
with hp do
|
||||||
begin
|
begin
|
||||||
@ -468,6 +474,8 @@ Implementation
|
|||||||
ImportSymbol.MangledName,ImportSymbol.OrdNr,ImportSymbol.IsVar);
|
ImportSymbol.MangledName,ImportSymbol.OrdNr,ImportSymbol.IsVar);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
{ ordered symbols }
|
||||||
|
OrderedSymbols.concatList(linkorderedsymbols);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -536,6 +544,12 @@ Implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TLinker.AddOrderedSymbol(const s: TCmdStr);
|
||||||
|
begin
|
||||||
|
OrderedSymbols.Concat(s);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure TLinker.AddStaticCLibrary(const S:TCmdStr);
|
Procedure TLinker.AddStaticCLibrary(const S:TCmdStr);
|
||||||
var
|
var
|
||||||
ns : TCmdStr;
|
ns : TCmdStr;
|
||||||
|
@ -165,7 +165,9 @@ interface
|
|||||||
tf_x86_far_procs_push_odd_bp,
|
tf_x86_far_procs_push_odd_bp,
|
||||||
{ indicates that this target can use dynamic packages otherwise an
|
{ indicates that this target can use dynamic packages otherwise an
|
||||||
error will be generated if a package file is compiled }
|
error will be generated if a package file is compiled }
|
||||||
tf_supports_packages
|
tf_supports_packages,
|
||||||
|
{ supports symbol order file (to ensure symbols in vectorised sections are kept in the correct order) }
|
||||||
|
tf_supports_symbolorderfile
|
||||||
);
|
);
|
||||||
|
|
||||||
psysteminfo = ^tsysteminfo;
|
psysteminfo = ^tsysteminfo;
|
||||||
|
@ -811,7 +811,7 @@ unit i_bsd;
|
|||||||
system : system_i386_darwin;
|
system : system_i386_darwin;
|
||||||
name : 'Darwin for i386';
|
name : 'Darwin for i386';
|
||||||
shortname : 'Darwin';
|
shortname : 'Darwin';
|
||||||
flags : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_uses_got,tf_pic_default,tf_has_winlike_resources];
|
flags : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_uses_got,tf_pic_default,tf_has_winlike_resources,tf_supports_symbolorderfile];
|
||||||
cpu : cpu_i386;
|
cpu : cpu_i386;
|
||||||
unit_env : 'BSDUNITS';
|
unit_env : 'BSDUNITS';
|
||||||
extradefines : 'UNIX;BSD;HASUNIX';
|
extradefines : 'UNIX;BSD;HASUNIX';
|
||||||
@ -947,7 +947,7 @@ unit i_bsd;
|
|||||||
system : system_powerpc64_darwin;
|
system : system_powerpc64_darwin;
|
||||||
name : 'Darwin for PowerPC64';
|
name : 'Darwin for PowerPC64';
|
||||||
shortname : 'Darwin';
|
shortname : 'Darwin';
|
||||||
flags : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources];
|
flags : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources,tf_supports_symbolorderfile];
|
||||||
cpu : cpu_powerpc64;
|
cpu : cpu_powerpc64;
|
||||||
unit_env : 'BSDUNITS';
|
unit_env : 'BSDUNITS';
|
||||||
extradefines : 'UNIX;BSD;HASUNIX';
|
extradefines : 'UNIX;BSD;HASUNIX';
|
||||||
@ -1015,7 +1015,7 @@ unit i_bsd;
|
|||||||
system : system_x86_64_darwin;
|
system : system_x86_64_darwin;
|
||||||
name : 'Darwin for x86_64';
|
name : 'Darwin for x86_64';
|
||||||
shortname : 'Darwin';
|
shortname : 'Darwin';
|
||||||
flags : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources];
|
flags : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources,tf_supports_symbolorderfile];
|
||||||
cpu : cpu_x86_64;
|
cpu : cpu_x86_64;
|
||||||
unit_env : 'BSDUNITS';
|
unit_env : 'BSDUNITS';
|
||||||
extradefines : 'UNIX;BSD;HASUNIX';
|
extradefines : 'UNIX;BSD;HASUNIX';
|
||||||
@ -1149,7 +1149,7 @@ unit i_bsd;
|
|||||||
system : system_arm_darwin;
|
system : system_arm_darwin;
|
||||||
name : 'Darwin for ARM';
|
name : 'Darwin for ARM';
|
||||||
shortname : 'Darwin';
|
shortname : 'Darwin';
|
||||||
flags : [tf_p_ext_support,tf_requires_proper_alignment,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_has_winlike_resources,tf_pic_default];
|
flags : [tf_p_ext_support,tf_requires_proper_alignment,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_has_winlike_resources,tf_pic_default,tf_supports_symbolorderfile];
|
||||||
cpu : cpu_arm;
|
cpu : cpu_arm;
|
||||||
unit_env : 'BSDUNITS';
|
unit_env : 'BSDUNITS';
|
||||||
extradefines : 'UNIX;BSD;HASUNIX;CPUARMEL';
|
extradefines : 'UNIX;BSD;HASUNIX;CPUARMEL';
|
||||||
@ -1217,7 +1217,7 @@ unit i_bsd;
|
|||||||
system : system_aarch64_darwin;
|
system : system_aarch64_darwin;
|
||||||
name : 'Darwin for AArch64';
|
name : 'Darwin for AArch64';
|
||||||
shortname : 'Darwin';
|
shortname : 'Darwin';
|
||||||
flags : [tf_p_ext_support,tf_requires_proper_alignment,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources];
|
flags : [tf_p_ext_support,tf_requires_proper_alignment,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources,tf_supports_symbolorderfile];
|
||||||
cpu : cpu_aarch64;
|
cpu : cpu_aarch64;
|
||||||
unit_env : 'BSDUNITS';
|
unit_env : 'BSDUNITS';
|
||||||
extradefines : 'UNIX;BSD;HASUNIX';
|
extradefines : 'UNIX;BSD;HASUNIX';
|
||||||
|
@ -66,6 +66,7 @@ implementation
|
|||||||
Function WriteResponseFile(isdll:boolean) : Boolean;
|
Function WriteResponseFile(isdll:boolean) : Boolean;
|
||||||
function GetDarwinCrt1ObjName(isdll: boolean): TCmdStr;
|
function GetDarwinCrt1ObjName(isdll: boolean): TCmdStr;
|
||||||
Function GetDarwinPrtobjName(isdll: boolean): TCmdStr;
|
Function GetDarwinPrtobjName(isdll: boolean): TCmdStr;
|
||||||
|
Function WriteSymbolOrderFile: TCmdStr;
|
||||||
public
|
public
|
||||||
constructor Create;override;
|
constructor Create;override;
|
||||||
procedure SetDefaultInfo;override;
|
procedure SetDefaultInfo;override;
|
||||||
@ -173,8 +174,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
if not(target_info.system in systems_darwin) then
|
if not(target_info.system in systems_darwin) then
|
||||||
begin
|
begin
|
||||||
ExeCmd[1]:='ld $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -L. -o $EXE $CATRES $FILELIST';
|
ExeCmd[1]:='ld $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $ORDERSYMS -L. -o $EXE $CATRES $FILELIST';
|
||||||
DllCmd[1]:='ld $TARGET $EMUL $OPT $MAP -shared -L. -o $EXE $CATRES $FILELIST'
|
DllCmd[1]:='ld $TARGET $EMUL $OPT $MAP $ORDERSYMS -shared -L. -o $EXE $CATRES $FILELIST'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -193,22 +194,22 @@ begin
|
|||||||
programs with problems that require Valgrind will have more
|
programs with problems that require Valgrind will have more
|
||||||
than 60KB of data (first 4KB of address space is always invalid)
|
than 60KB of data (first 4KB of address space is always invalid)
|
||||||
}
|
}
|
||||||
ExeCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST';
|
ExeCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $ORDERSYMS -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST';
|
||||||
if not(cs_gdb_valgrind in current_settings.globalswitches) then
|
if not(cs_gdb_valgrind in current_settings.globalswitches) then
|
||||||
ExeCmd[1]:=ExeCmd[1]+' -pagezero_size 0x10000';
|
ExeCmd[1]:=ExeCmd[1]+' -pagezero_size 0x10000';
|
||||||
{$else ndef cpu64bitaddr}
|
{$else ndef cpu64bitaddr}
|
||||||
ExeCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST';
|
ExeCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $ORDERSYMS -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST';
|
||||||
{$endif ndef cpu64bitaddr}
|
{$endif ndef cpu64bitaddr}
|
||||||
if (apptype<>app_bundle) then
|
if (apptype<>app_bundle) then
|
||||||
DllCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $GCSECTIONS $MAP -dynamic -dylib -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST'
|
DllCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $GCSECTIONS $MAP $ORDERSYMS -dynamic -dylib -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST'
|
||||||
else
|
else
|
||||||
DllCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $GCSECTIONS $MAP -dynamic -bundle -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST'
|
DllCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $GCSECTIONS $MAP $ORDERSYMS -dynamic -bundle -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
ExeCmd[1]:='ld $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -L. -o $EXE $RES';
|
ExeCmd[1]:='ld $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $ORDERSYMS -L. -o $EXE $RES';
|
||||||
DllCmd[1]:='ld $TARGET $EMUL $OPT $INIT $FINI $SONAME $MAP -shared -L. -o $EXE $RES';
|
DllCmd[1]:='ld $TARGET $EMUL $OPT $INIT $FINI $SONAME $MAP $ORDERSYMS -shared -L. -o $EXE $RES';
|
||||||
end;
|
end;
|
||||||
if not(target_info.system in systems_darwin) then
|
if not(target_info.system in systems_darwin) then
|
||||||
DllCmd[2]:='strip --strip-unneeded $EXE'
|
DllCmd[2]:='strip --strip-unneeded $EXE'
|
||||||
@ -467,6 +468,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function tlinkerbsd.WriteSymbolOrderFile: TCmdStr;
|
||||||
|
var
|
||||||
|
item: TCmdStrListItem;
|
||||||
|
symfile: TScript;
|
||||||
|
begin
|
||||||
|
result:='';
|
||||||
|
{ only for darwin for now; can also enable for other platforms when using
|
||||||
|
the LLVM linker }
|
||||||
|
if (OrderedSymbols.Empty) or
|
||||||
|
not(tf_supports_symbolorderfile in target_info.flags) then
|
||||||
|
exit;
|
||||||
|
symfile:=TScript.Create(outputexedir+'symbol_order.fpc');
|
||||||
|
item:=TCmdStrListItem(OrderedSymbols.First);
|
||||||
|
while assigned(item) do
|
||||||
|
begin
|
||||||
|
symfile.add(item.str);
|
||||||
|
item:=TCmdStrListItem(item.next);
|
||||||
|
end;
|
||||||
|
symfile.WriteToDisk;
|
||||||
|
result:=symfile.fn;
|
||||||
|
symfile.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
|
Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
|
||||||
Var
|
Var
|
||||||
linkres : TLinkRes;
|
linkres : TLinkRes;
|
||||||
@ -777,7 +802,8 @@ var
|
|||||||
targetstr,
|
targetstr,
|
||||||
emulstr,
|
emulstr,
|
||||||
extdbgbinstr,
|
extdbgbinstr,
|
||||||
extdbgcmdstr: TCmdStr;
|
extdbgcmdstr,
|
||||||
|
ordersymfile: TCmdStr;
|
||||||
linkscript: TAsmScript;
|
linkscript: TAsmScript;
|
||||||
DynLinkStr : string[60];
|
DynLinkStr : string[60];
|
||||||
GCSectionsStr,
|
GCSectionsStr,
|
||||||
@ -861,6 +887,9 @@ begin
|
|||||||
{ Write used files and libraries }
|
{ Write used files and libraries }
|
||||||
WriteResponseFile(false);
|
WriteResponseFile(false);
|
||||||
|
|
||||||
|
{ Write symbol order file }
|
||||||
|
ordersymfile:=WriteSymbolOrderFile;
|
||||||
|
|
||||||
{ Call linker }
|
{ Call linker }
|
||||||
SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
|
SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
|
||||||
Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
|
Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
|
||||||
@ -870,6 +899,16 @@ begin
|
|||||||
Replace(cmdstr,'$MAP',mapstr);
|
Replace(cmdstr,'$MAP',mapstr);
|
||||||
Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
|
Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
|
||||||
Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
|
Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
|
||||||
|
if ordersymfile<>'' then
|
||||||
|
begin
|
||||||
|
if target_info.system in systems_darwin then
|
||||||
|
Replace(cmdstr,'$ORDERSYMS','-order_file '+maybequoted(ordersymfile))
|
||||||
|
else
|
||||||
|
Replace(cmdstr,'$ORDERSYMS','--symbol-ordering-file '+maybequoted(ordersymfile))
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Replace(cmdstr,'$ORDERSYMS','');
|
||||||
|
|
||||||
if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
|
if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
|
||||||
Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
|
Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
|
||||||
else
|
else
|
||||||
@ -922,6 +961,8 @@ begin
|
|||||||
if (success) and not(cs_link_nolink in current_settings.globalswitches) then
|
if (success) and not(cs_link_nolink in current_settings.globalswitches) then
|
||||||
begin
|
begin
|
||||||
DeleteFile(outputexedir+Info.ResName);
|
DeleteFile(outputexedir+Info.ResName);
|
||||||
|
if ordersymfile<>'' then
|
||||||
|
DeleteFile(ordersymfile);
|
||||||
if LdSupportsNoResponseFile Then
|
if LdSupportsNoResponseFile Then
|
||||||
begin
|
begin
|
||||||
DeleteFile(linkscript.fn);
|
DeleteFile(linkscript.fn);
|
||||||
@ -946,6 +987,7 @@ var
|
|||||||
binstr,
|
binstr,
|
||||||
cmdstr,
|
cmdstr,
|
||||||
mapstr,
|
mapstr,
|
||||||
|
ordersymfile,
|
||||||
targetstr,
|
targetstr,
|
||||||
emulstr,
|
emulstr,
|
||||||
extdbgbinstr,
|
extdbgbinstr,
|
||||||
@ -964,6 +1006,9 @@ begin
|
|||||||
{ Write used files and libraries }
|
{ Write used files and libraries }
|
||||||
WriteResponseFile(true);
|
WriteResponseFile(true);
|
||||||
|
|
||||||
|
{ Write symbol order file }
|
||||||
|
ordersymfile:=WriteSymbolOrderFile;
|
||||||
|
|
||||||
if (cs_link_smart in current_settings.globalswitches) and
|
if (cs_link_smart in current_settings.globalswitches) and
|
||||||
(tf_smartlink_sections in target_info.flags) then
|
(tf_smartlink_sections in target_info.flags) then
|
||||||
if not(target_info.system in systems_darwin) then
|
if not(target_info.system in systems_darwin) then
|
||||||
@ -1014,6 +1059,15 @@ begin
|
|||||||
Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
|
Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
|
||||||
Replace(cmdstr,'$SONAME',SoNameStr);
|
Replace(cmdstr,'$SONAME',SoNameStr);
|
||||||
Replace(cmdstr,'$MAP',mapstr);
|
Replace(cmdstr,'$MAP',mapstr);
|
||||||
|
if ordersymfile<>'' then
|
||||||
|
begin
|
||||||
|
if target_info.system in systems_darwin then
|
||||||
|
Replace(cmdstr,'$ORDERSYMS','-order_file '+maybequoted(ordersymfile))
|
||||||
|
else
|
||||||
|
Replace(cmdstr,'$ORDERSYMS','--symbol-ordering-file '+maybequoted(ordersymfile))
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Replace(cmdstr,'$ORDERSYMS','');
|
||||||
if (target_info.system in systems_darwin) then
|
if (target_info.system in systems_darwin) then
|
||||||
Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(true));
|
Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(true));
|
||||||
BinStr:=FindUtil(utilsprefix+BinStr);
|
BinStr:=FindUtil(utilsprefix+BinStr);
|
||||||
@ -1080,6 +1134,8 @@ begin
|
|||||||
if (success) and not(cs_link_nolink in current_settings.globalswitches) then
|
if (success) and not(cs_link_nolink in current_settings.globalswitches) then
|
||||||
begin
|
begin
|
||||||
DeleteFile(outputexedir+Info.ResName);
|
DeleteFile(outputexedir+Info.ResName);
|
||||||
|
if ordersymfile<>'' then
|
||||||
|
DeleteFile(ordersymfile);
|
||||||
if LdSupportsNoResponseFile Then
|
if LdSupportsNoResponseFile Then
|
||||||
begin
|
begin
|
||||||
DeleteFile(linkscript.fn);
|
DeleteFile(linkscript.fn);
|
||||||
|
@ -3840,6 +3840,10 @@ begin
|
|||||||
if not silent then
|
if not silent then
|
||||||
ReadContainer('Resource file: ');
|
ReadContainer('Resource file: ');
|
||||||
|
|
||||||
|
iborderedsymbols:
|
||||||
|
if not silent then
|
||||||
|
ReadContainer('Ordered symbol: ');
|
||||||
|
|
||||||
iberror :
|
iberror :
|
||||||
begin
|
begin
|
||||||
WriteError('Error in PPU');
|
WriteError('Error in PPU');
|
||||||
|
Loading…
Reference in New Issue
Block a user