mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 13:09:32 +02:00
* msdos: Implemented library based smartlinking of the dead stripable vectorized lists. It is enabled for the internal linker and wlink. These linkers sort sections by name by default.
git-svn-id: trunk@46480 -
This commit is contained in:
parent
764227193a
commit
c75953c12b
@ -36,7 +36,8 @@ implementation
|
||||
cutils,cfileutl,cclasses,
|
||||
globtype,globals,systems,verbose,cscript,
|
||||
fmodule,i_msdos,
|
||||
link,aasmbase,cpuinfo,
|
||||
link,cpuinfo,
|
||||
aasmbase,aasmcnst,symbase,symdef,
|
||||
omfbase,ogbase,ogomf,owomflib;
|
||||
|
||||
type
|
||||
@ -85,6 +86,51 @@ implementation
|
||||
constructor create;override;
|
||||
end;
|
||||
|
||||
{ tmsdostai_typedconstbuilder }
|
||||
|
||||
tmsdostai_typedconstbuilder = class(ttai_lowleveltypedconstbuilder)
|
||||
protected
|
||||
procedure add_link_ordered_symbol(sym: tasmsymbol; const secname: TSymStr); override;
|
||||
public
|
||||
class function get_vectorized_dead_strip_custom_section_name(const basename: TSymStr; st: tsymtable; options: ttcasmlistoptions; out secname: TSymStr): boolean; override;
|
||||
class function is_smartlink_vectorized_dead_strip: boolean; override;
|
||||
end;
|
||||
|
||||
{****************************************************************************
|
||||
tmsdostai_typedconstbuilder
|
||||
****************************************************************************}
|
||||
|
||||
procedure tmsdostai_typedconstbuilder.add_link_ordered_symbol(sym: tasmsymbol; const secname: TSymStr);
|
||||
begin
|
||||
with current_module.linkorderedsymbols do
|
||||
if (Last=nil) or (TCmdStrListItem(Last).Str<>secname) then
|
||||
current_module.linkorderedsymbols.concat(secname);
|
||||
end;
|
||||
|
||||
class function tmsdostai_typedconstbuilder.get_vectorized_dead_strip_custom_section_name(const basename: TSymStr; st: tsymtable; options: ttcasmlistoptions; out secname: TSymStr): boolean;
|
||||
begin
|
||||
result:=is_smartlink_vectorized_dead_strip;
|
||||
if not result then
|
||||
exit;
|
||||
if tcalo_vectorized_dead_strip_start in options then
|
||||
secname:='1_START'
|
||||
else
|
||||
if tcalo_vectorized_dead_strip_end in options then
|
||||
secname:='3_END'
|
||||
else
|
||||
if tcalo_vectorized_dead_strip_item in options then
|
||||
secname:='2_ITEM';
|
||||
secname:=make_mangledname(basename,st,secname);
|
||||
end;
|
||||
|
||||
class function tmsdostai_typedconstbuilder.is_smartlink_vectorized_dead_strip: boolean;
|
||||
begin
|
||||
{$ifdef USE_LINKER_WLINK}
|
||||
result:=true;
|
||||
{$else}
|
||||
result:=not (cs_link_extern in current_settings.globalswitches);
|
||||
{$endif USE_LINKER_WLINK}
|
||||
end;
|
||||
|
||||
{****************************************************************************
|
||||
TExternalLinkerMsDosTLink
|
||||
@ -529,6 +575,7 @@ end;
|
||||
*****************************************************************************}
|
||||
|
||||
initialization
|
||||
ctai_typedconstbuilder:=tmsdostai_typedconstbuilder;
|
||||
RegisterLinker(ld_int_msdos,TInternalLinkerMsDos);
|
||||
{$if defined(USE_LINKER_TLINK)}
|
||||
RegisterLinker(ld_msdos,TExternalLinkerMsDosTLink);
|
||||
|
@ -572,14 +572,14 @@ interface
|
||||
if (atype in [sec_rodata,sec_rodata_norel]) and
|
||||
(target_info.system=system_i386_go32v2) then
|
||||
writer.AsmWrite('.data')
|
||||
else if (atype=sec_user) then
|
||||
writer.AsmWrite(aname)
|
||||
else if (atype=sec_threadvar) and
|
||||
(target_info.system in (systems_windows+systems_wince)) then
|
||||
writer.AsmWrite('.tls'#9'bss')
|
||||
else if target_info.system in [system_i8086_msdos,system_i8086_win16,system_i8086_embedded] then
|
||||
begin
|
||||
if secnames[atype]='.text' then
|
||||
if (atype=sec_user) then
|
||||
secname:=aname
|
||||
else if secnames[atype]='.text' then
|
||||
secname:=CodeSectionName(aname)
|
||||
else if omf_segclass(atype)='FAR_DATA' then
|
||||
secname:=current_module.modulename^ + '_DATA'
|
||||
@ -604,6 +604,8 @@ interface
|
||||
AddSegmentToGroup(secgroup,secname);
|
||||
end;
|
||||
end
|
||||
else if (atype=sec_user) then
|
||||
writer.AsmWrite(aname)
|
||||
else if secnames[atype]='.text' then
|
||||
writer.AsmWrite(CodeSectionName(aname))
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user