mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 17:06:14 +02:00
* Internal linker: made sec_rodata_norel read-only.
* For Win32 and Win64 targets made sec_rodata read-only, too (for these targets it doesn't matter if read-only section contains relocations). git-svn-id: trunk@23025 -
This commit is contained in:
parent
5ee506d64e
commit
0369a30f49
@ -971,10 +971,12 @@ implementation
|
||||
{user} [oso_Data,oso_load,oso_write,oso_keep],
|
||||
{code} [oso_Data,oso_load,oso_executable,oso_keep],
|
||||
{Data} [oso_Data,oso_load,oso_write,oso_keep],
|
||||
{ TODO: Fix sec_rodata be read-only-with-relocs}
|
||||
{ Readonly data with relocations must be initially writable for some targets.
|
||||
Moreover, e.g. for ELF it depends on whether the executable is linked statically or
|
||||
dynamically. Here we declare it writable, target-specific descendants must provide
|
||||
further handling. }
|
||||
{roData} [oso_Data,oso_load,oso_write,oso_keep],
|
||||
{ TODO: Fix sec_rodata_norel be read-only/constant}
|
||||
{roData_norel} [oso_Data,oso_load,oso_write,oso_keep],
|
||||
{roData_norel} [oso_Data,oso_load,oso_keep],
|
||||
{bss} [oso_load,oso_write,oso_keep],
|
||||
{threadvar} [oso_load,oso_write
|
||||
{$ifdef FPC_USE_TLS_DIRECTORY}
|
||||
|
@ -121,6 +121,7 @@ interface
|
||||
constructor createcoff(const n:string;awin32:boolean;acObjSection:TObjSectionClass);
|
||||
procedure CreateDebugSections;override;
|
||||
function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
|
||||
function sectiontype2options(atype:TAsmSectiontype):TObjSectionOptions;override;
|
||||
procedure writereloc(data:aint;len:aword;p:TObjSymbol;reloctype:TObjRelocationType);override;
|
||||
end;
|
||||
|
||||
@ -481,7 +482,7 @@ implementation
|
||||
StrsMaxGrow = 8192;
|
||||
|
||||
coffsecnames : array[TAsmSectiontype] of string[length('__DATA, __datacoal_nt,coalesced')] = ('','',
|
||||
'.text','.data','.data','.data','.bss','.tls',
|
||||
'.text','.data','.rdata','.rdata','.bss','.tls',
|
||||
'.pdata',{pdata}
|
||||
'.text', {stub}
|
||||
'.data',
|
||||
@ -1001,6 +1002,11 @@ const pemagic : array[0..3] of byte = (
|
||||
result:=aname
|
||||
else
|
||||
begin
|
||||
{ non-PECOFF targets lack rodata support.
|
||||
TODO: WinCE likely supports it, but needs testing. }
|
||||
if (atype in [sec_rodata,sec_rodata_norel]) and
|
||||
not (target_info.system in systems_windows) then
|
||||
atype:=sec_data;
|
||||
secname:=coffsecnames[atype];
|
||||
if create_smartlink_sections and
|
||||
(aname<>'') then
|
||||
@ -1021,6 +1027,20 @@ const pemagic : array[0..3] of byte = (
|
||||
end;
|
||||
|
||||
|
||||
function TCoffObjData.sectiontype2options(aType:TAsmSectionType): TObjSectionOptions;
|
||||
begin
|
||||
if (aType in [sec_rodata,sec_rodata_norel]) then
|
||||
begin
|
||||
{ TODO: WinCE needs testing }
|
||||
if (target_info.system in systems_windows) then
|
||||
aType:=sec_rodata_norel
|
||||
else
|
||||
aType:=sec_data;
|
||||
end;
|
||||
result:=inherited sectiontype2options(aType);
|
||||
end;
|
||||
|
||||
|
||||
procedure TCoffObjData.CreateDebugSections;
|
||||
begin
|
||||
if target_dbg.id=dbg_stabs then
|
||||
|
@ -961,11 +961,8 @@ implementation
|
||||
function TElfObjData.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
|
||||
const
|
||||
secnames : array[TAsmSectiontype] of string[length('__DATA, __datacoal_nt,coalesced')] = ('','',
|
||||
{$ifdef userodata}
|
||||
{ TODO: sec_rodata is still writable }
|
||||
'.text','.data','.data','.rodata','.bss','.threadvar',
|
||||
{$else userodata}
|
||||
'.text','.data','.data','.data','.bss','.threadvar',
|
||||
{$endif userodata}
|
||||
'.pdata',
|
||||
'.text', { darwin stubs }
|
||||
'__DATA,__nl_symbol_ptr',
|
||||
|
Loading…
Reference in New Issue
Block a user