mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 08:19:27 +02:00
* split off sec_rodata_norel from sec_rodata, and only put constant data
without relocations in sec_rodata_norel. It should be possible to make this new section read-only on all platforms, although currently it is only done for darwin, and for non-pic code written using the -Aas assembler writer. Most platforms also have a special section for "constant but with relocations" data, but such a section is currently only used for Darwin (others still use plain .data sections for that, like they did before) git-svn-id: trunk@8650 -
This commit is contained in:
parent
5520a948e5
commit
70c2414daa
@ -60,7 +60,10 @@ interface
|
|||||||
TAsmSectiontype=(sec_none,
|
TAsmSectiontype=(sec_none,
|
||||||
sec_code,
|
sec_code,
|
||||||
sec_data,
|
sec_data,
|
||||||
|
{ read-only, but may contain relocations }
|
||||||
sec_rodata,
|
sec_rodata,
|
||||||
|
{ read-only and cannot contain relocations }
|
||||||
|
sec_rodata_norel,
|
||||||
sec_bss,
|
sec_bss,
|
||||||
sec_threadvar,
|
sec_threadvar,
|
||||||
{ used for wince exception handling }
|
{ used for wince exception handling }
|
||||||
|
@ -253,12 +253,13 @@ implementation
|
|||||||
{ not relocated properly on e.g. linux/ppc64. g++ generates there for a }
|
{ not relocated properly on e.g. linux/ppc64. g++ generates there for a }
|
||||||
{ vtable for a class called Window: }
|
{ vtable for a class called Window: }
|
||||||
{ .section .data.rel.ro._ZTV6Window,"awG",@progbits,_ZTV6Window,comdat }
|
{ .section .data.rel.ro._ZTV6Window,"awG",@progbits,_ZTV6Window,comdat }
|
||||||
{$warning TODO .rodata not yet working}
|
{$warning TODO .data.ro not yet working}
|
||||||
{$if defined(arm) or defined(powerpc)}
|
{$if defined(arm) or defined(powerpc)}
|
||||||
'.rodata',
|
'.rodata',
|
||||||
{$else arm}
|
{$else arm}
|
||||||
'.data',
|
'.data',
|
||||||
{$endif arm}
|
{$endif arm}
|
||||||
|
'.rodata',
|
||||||
'.bss',
|
'.bss',
|
||||||
'.threadvar',
|
'.threadvar',
|
||||||
'.pdata',
|
'.pdata',
|
||||||
@ -277,6 +278,7 @@ implementation
|
|||||||
'.text',
|
'.text',
|
||||||
'.data.rel',
|
'.data.rel',
|
||||||
'.data.rel',
|
'.data.rel',
|
||||||
|
'.data.rel',
|
||||||
'.bss',
|
'.bss',
|
||||||
'.threadvar',
|
'.threadvar',
|
||||||
'.pdata',
|
'.pdata',
|
||||||
@ -600,12 +602,12 @@ implementation
|
|||||||
begin
|
begin
|
||||||
if (target_info.system in systems_darwin) then
|
if (target_info.system in systems_darwin) then
|
||||||
begin
|
begin
|
||||||
{On Mac OS X you can't have common symbols in a shared
|
{ On Mac OS X you can't have common symbols in a shared library
|
||||||
library, since those are in the TEXT section and the text section is
|
since those are in the TEXT section and the text section is
|
||||||
read-only in shared libraries (so it can be shared among different
|
read-only in shared libraries (so it can be shared among different
|
||||||
processes). The alternate code creates some kind of common symbols in
|
processes). The alternate code creates some kind of common symbols
|
||||||
the data segment. The generic code no longer uses common symbols, but
|
in the data segment.
|
||||||
this doesn't work on Mac OS X as well.}
|
}
|
||||||
if tai_datablock(hp).is_global then
|
if tai_datablock(hp).is_global then
|
||||||
begin
|
begin
|
||||||
asmwrite('.globl ');
|
asmwrite('.globl ');
|
||||||
@ -733,7 +735,7 @@ implementation
|
|||||||
{ Values with symbols are written on a single line to improve
|
{ Values with symbols are written on a single line to improve
|
||||||
reading of the .s file (PFV) }
|
reading of the .s file (PFV) }
|
||||||
if assigned(tai_const(hp).sym) or
|
if assigned(tai_const(hp).sym) or
|
||||||
not(CurrSecType in [sec_data,sec_rodata]) or
|
not(CurrSecType in [sec_data,sec_rodata,sec_rodata_norel]) or
|
||||||
(l>line_length) or
|
(l>line_length) or
|
||||||
(hp.next=nil) or
|
(hp.next=nil) or
|
||||||
(tai(hp.next).typ<>ait_const) or
|
(tai(hp.next).typ<>ait_const) or
|
||||||
@ -1116,6 +1118,11 @@ implementation
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
sec_rodata:
|
sec_rodata:
|
||||||
|
begin
|
||||||
|
result := '.const_data';
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
sec_rodata_norel:
|
||||||
begin
|
begin
|
||||||
result := '.const';
|
result := '.const';
|
||||||
exit;
|
exit;
|
||||||
@ -1142,6 +1149,7 @@ implementation
|
|||||||
sec_code,
|
sec_code,
|
||||||
sec_data,
|
sec_data,
|
||||||
sec_data (* sec_rodata *),
|
sec_data (* sec_rodata *),
|
||||||
|
sec_data (* sec_rodata_norel *),
|
||||||
sec_bss,
|
sec_bss,
|
||||||
sec_data (* sec_threadvar *),
|
sec_data (* sec_threadvar *),
|
||||||
{ used for wince exception handling }
|
{ used for wince exception handling }
|
||||||
|
@ -458,6 +458,7 @@ interface
|
|||||||
secnames : array[TAsmSectiontype] of string[17] = ('',
|
secnames : array[TAsmSectiontype] of string[17] = ('',
|
||||||
'.text',
|
'.text',
|
||||||
'.data',
|
'.data',
|
||||||
|
'.data',
|
||||||
'.rodata',
|
'.rodata',
|
||||||
'.bss',
|
'.bss',
|
||||||
'.tbss',
|
'.tbss',
|
||||||
|
@ -167,7 +167,7 @@ implementation
|
|||||||
current_asmdata.getdatalabel(lastlabel);
|
current_asmdata.getdatalabel(lastlabel);
|
||||||
lab_real:=lastlabel;
|
lab_real:=lastlabel;
|
||||||
maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
|
maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
|
||||||
new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata,lastlabel.name,const_align(resultdef.size));
|
new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,lastlabel.name,const_align(resultdef.size));
|
||||||
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
|
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
|
||||||
case realait of
|
case realait of
|
||||||
ait_real_32bit :
|
ait_real_32bit :
|
||||||
@ -413,7 +413,11 @@ implementation
|
|||||||
current_asmdata.getdatalabel(lastlabel);
|
current_asmdata.getdatalabel(lastlabel);
|
||||||
lab_str:=lastlabel;
|
lab_str:=lastlabel;
|
||||||
maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
|
maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
|
||||||
new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata,lastlabel.name,const_align(sizeof(aint)));
|
if (len=0) or
|
||||||
|
not(cst_type in [cst_ansistring,cst_widestring]) then
|
||||||
|
new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,lastlabel.name,const_align(sizeof(aint)))
|
||||||
|
else
|
||||||
|
new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata,lastlabel.name,const_align(sizeof(aint)));
|
||||||
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
|
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
|
||||||
{ generate an ansi string ? }
|
{ generate an ansi string ? }
|
||||||
case cst_type of
|
case cst_type of
|
||||||
@ -617,7 +621,7 @@ implementation
|
|||||||
current_asmdata.getdatalabel(lastlabel);
|
current_asmdata.getdatalabel(lastlabel);
|
||||||
lab_set:=lastlabel;
|
lab_set:=lastlabel;
|
||||||
maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
|
maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
|
||||||
new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata,lastlabel.name,const_align(sizeof(aint)));
|
new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,lastlabel.name,const_align(sizeof(aint)));
|
||||||
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
|
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
|
||||||
{ already handled at the start of this method?? (JM)
|
{ already handled at the start of this method?? (JM)
|
||||||
if tsetdef(resultdef).settype=smallset then
|
if tsetdef(resultdef).settype=smallset then
|
||||||
|
@ -799,6 +799,7 @@ implementation
|
|||||||
secnames : array[TAsmSectiontype] of string[16] = ('',
|
secnames : array[TAsmSectiontype] of string[16] = ('',
|
||||||
'code',
|
'code',
|
||||||
'Data',
|
'Data',
|
||||||
|
'Data',
|
||||||
'roData',
|
'roData',
|
||||||
'bss',
|
'bss',
|
||||||
'threadvar',
|
'threadvar',
|
||||||
@ -838,8 +839,10 @@ implementation
|
|||||||
secoptions : array[TAsmSectiontype] of TObjSectionOptions = ([],
|
secoptions : array[TAsmSectiontype] of TObjSectionOptions = ([],
|
||||||
{code} [oso_Data,oso_load,oso_readonly,oso_executable,oso_keep],
|
{code} [oso_Data,oso_load,oso_readonly,oso_executable,oso_keep],
|
||||||
{Data} [oso_Data,oso_load,oso_write,oso_keep],
|
{Data} [oso_Data,oso_load,oso_write,oso_keep],
|
||||||
{$warning TODO Fix roData be read-only}
|
{$warning TODO Fix sec_rodata be read-only-with-relocs}
|
||||||
{roData} [oso_Data,oso_load,oso_write,oso_keep],
|
{roData} [oso_Data,oso_load,oso_write,oso_keep],
|
||||||
|
{$warning TODO Fix sec_rodata_norel be read-only/constant}
|
||||||
|
{roData_norel} [oso_Data,oso_load,oso_write,oso_keep],
|
||||||
{bss} [oso_load,oso_write,oso_keep],
|
{bss} [oso_load,oso_write,oso_keep],
|
||||||
{threadvar} [oso_load,oso_write],
|
{threadvar} [oso_load,oso_write],
|
||||||
{pdata} [oso_load,oso_readonly,oso_keep],
|
{pdata} [oso_load,oso_readonly,oso_keep],
|
||||||
|
@ -477,7 +477,7 @@ implementation
|
|||||||
StrsMaxGrow = 8192;
|
StrsMaxGrow = 8192;
|
||||||
|
|
||||||
coffsecnames : array[TAsmSectiontype] of string[17] = ('',
|
coffsecnames : array[TAsmSectiontype] of string[17] = ('',
|
||||||
'.text','.data','.data','.bss','.tls',
|
'.text','.data','.data','.data','.bss','.tls',
|
||||||
'.text',
|
'.text',
|
||||||
'.pdata',
|
'.pdata',
|
||||||
'.stab','.stabstr',
|
'.stab','.stabstr',
|
||||||
|
@ -571,9 +571,9 @@ implementation
|
|||||||
const
|
const
|
||||||
secnames : array[TAsmSectiontype] of string[13] = ('',
|
secnames : array[TAsmSectiontype] of string[13] = ('',
|
||||||
{$ifdef userodata}
|
{$ifdef userodata}
|
||||||
'.text','.data','.rodata','.bss','.threadvar',
|
'.text','.data','.data','.rodata','.bss','.threadvar',
|
||||||
{$else userodata}
|
{$else userodata}
|
||||||
'.text','.data','.data','.bss','.threadvar',
|
'.text','.data','.data','.data','.bss','.threadvar',
|
||||||
{$endif userodata}
|
{$endif userodata}
|
||||||
'.pdata',
|
'.pdata',
|
||||||
'.text', { darwin stubs }
|
'.text', { darwin stubs }
|
||||||
@ -590,6 +590,7 @@ implementation
|
|||||||
'.text',
|
'.text',
|
||||||
'.data.rel',
|
'.data.rel',
|
||||||
'.data.rel',
|
'.data.rel',
|
||||||
|
'.data.rel',
|
||||||
'.bss',
|
'.bss',
|
||||||
'.threadvar',
|
'.threadvar',
|
||||||
'.pdata',
|
'.pdata',
|
||||||
|
@ -72,6 +72,7 @@ interface
|
|||||||
'csect', {code}
|
'csect', {code}
|
||||||
'csect', {data}
|
'csect', {data}
|
||||||
'csect', {read only data}
|
'csect', {read only data}
|
||||||
|
'csect', {read only data - no relocations}
|
||||||
'csect', {bss} 'csect', '',
|
'csect', {bss} 'csect', '',
|
||||||
'csect','csect','csect','csect',
|
'csect','csect','csect','csect',
|
||||||
'','','','','','','','','','','','','',''
|
'','','','','','','','','','','','','',''
|
||||||
|
@ -60,7 +60,7 @@ implementation
|
|||||||
line_length = 70;
|
line_length = 70;
|
||||||
|
|
||||||
secnames : array[TAsmSectiontype] of string[4] = ('',
|
secnames : array[TAsmSectiontype] of string[4] = ('',
|
||||||
'CODE','DATA','DATA','BSS','',
|
'CODE','DATA','DATA','DATA','BSS','',
|
||||||
'','','','','','',
|
'','','','','','',
|
||||||
'','','','',
|
'','','','',
|
||||||
'',
|
'',
|
||||||
@ -72,7 +72,7 @@ implementation
|
|||||||
);
|
);
|
||||||
|
|
||||||
secnamesml64 : array[TAsmSectiontype] of string[7] = ('',
|
secnamesml64 : array[TAsmSectiontype] of string[7] = ('',
|
||||||
'_TEXT','_DATE','_DATA','_BSS','',
|
'_TEXT','_DATE','_DATA','_DATA','_BSS','',
|
||||||
'','','','',
|
'','','','',
|
||||||
'idata$2','idata$4','idata$5','idata$6','idata$7','edata',
|
'idata$2','idata$4','idata$5','idata$6','idata$7','edata',
|
||||||
'',
|
'',
|
||||||
|
Loading…
Reference in New Issue
Block a user