mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-25 18:49:21 +02:00
* Use public/global name 'name' section 'section' without semicolon for Windows TLS support
git-svn-id: trunk@17909 -
This commit is contained in:
parent
372b16b2e6
commit
cfdc7c861d
@ -41,6 +41,8 @@ interface
|
|||||||
|
|
||||||
procedure read_public_and_external(vs: tabstractvarsym);
|
procedure read_public_and_external(vs: tabstractvarsym);
|
||||||
|
|
||||||
|
procedure try_consume_sectiondirective(var asection: ansistring);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -925,7 +927,7 @@ implementation
|
|||||||
is_external_var,
|
is_external_var,
|
||||||
is_weak_external,
|
is_weak_external,
|
||||||
is_public_var : boolean;
|
is_public_var : boolean;
|
||||||
dll_name,
|
dll_name,section_name,
|
||||||
C_name,mangledname : string;
|
C_name,mangledname : string;
|
||||||
begin
|
begin
|
||||||
{ only allowed for one var }
|
{ only allowed for one var }
|
||||||
@ -940,6 +942,7 @@ implementation
|
|||||||
is_cdecl:=false;
|
is_cdecl:=false;
|
||||||
is_external_var:=false;
|
is_external_var:=false;
|
||||||
is_public_var:=false;
|
is_public_var:=false;
|
||||||
|
section_name := '';
|
||||||
C_name:=vs.realname;
|
C_name:=vs.realname;
|
||||||
|
|
||||||
{ macpas specific handling due to some switches}
|
{ macpas specific handling due to some switches}
|
||||||
@ -992,6 +995,10 @@ implementation
|
|||||||
is_public_var:=true;
|
is_public_var:=true;
|
||||||
if try_to_consume(_NAME) then
|
if try_to_consume(_NAME) then
|
||||||
C_name:=get_stringconst;
|
C_name:=get_stringconst;
|
||||||
|
if (target_info.system in systems_allow_section_no_semicolon) and
|
||||||
|
(vs.typ=staticvarsym) and
|
||||||
|
try_to_consume (_SECTION) then
|
||||||
|
section_name:=get_stringconst;
|
||||||
consume(_SEMICOLON);
|
consume(_SEMICOLON);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1000,6 +1007,14 @@ implementation
|
|||||||
(target_info.system in systems_all_windows) then
|
(target_info.system in systems_all_windows) then
|
||||||
include(vs.varoptions,vo_is_dll_var);
|
include(vs.varoptions,vo_is_dll_var);
|
||||||
|
|
||||||
|
{ This can only happen if vs.typ=staticvarsym }
|
||||||
|
if section_name<>'' then
|
||||||
|
begin
|
||||||
|
tstaticvarsym(vs).section:=section_name;
|
||||||
|
include(vs.varoptions,vo_has_section);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ Add C _ prefix }
|
{ Add C _ prefix }
|
||||||
if is_cdecl or
|
if is_cdecl or
|
||||||
(
|
(
|
||||||
@ -1272,7 +1287,7 @@ implementation
|
|||||||
hintsymoptions : tsymoptions;
|
hintsymoptions : tsymoptions;
|
||||||
deprecatedmsg : pshortstring;
|
deprecatedmsg : pshortstring;
|
||||||
old_block_type : tblock_type;
|
old_block_type : tblock_type;
|
||||||
section : ansistring;
|
sectionname : ansistring;
|
||||||
begin
|
begin
|
||||||
old_block_type:=block_type;
|
old_block_type:=block_type;
|
||||||
block_type:=bt_var;
|
block_type:=bt_var;
|
||||||
@ -1415,10 +1430,12 @@ implementation
|
|||||||
read_public_and_external_sc(sc);
|
read_public_and_external_sc(sc);
|
||||||
|
|
||||||
{ try to parse a section directive }
|
{ try to parse a section directive }
|
||||||
if (target_info.system in systems_embedded) and (idtoken=_SECTION) then
|
if (target_info.system in systems_allow_section) and
|
||||||
|
(symtablestack.top.symtabletype in [staticsymtable,globalsymtable]) and
|
||||||
|
(idtoken=_SECTION) then
|
||||||
begin
|
begin
|
||||||
try_consume_sectiondirective(section);
|
try_consume_sectiondirective(sectionname);
|
||||||
if section<>'' then
|
if sectionname<>'' then
|
||||||
begin
|
begin
|
||||||
for i:=0 to sc.count-1 do
|
for i:=0 to sc.count-1 do
|
||||||
begin
|
begin
|
||||||
@ -1427,7 +1444,8 @@ implementation
|
|||||||
Message(parser_e_externals_no_section);
|
Message(parser_e_externals_no_section);
|
||||||
if vs.typ<>staticvarsym then
|
if vs.typ<>staticvarsym then
|
||||||
Message(parser_e_section_no_locals);
|
Message(parser_e_section_no_locals);
|
||||||
tstaticvarsym(vs).section:=section;
|
tstaticvarsym(vs).section:=sectionname;
|
||||||
|
include(vs.varoptions, vo_has_section);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -1437,6 +1437,7 @@ implementation
|
|||||||
storefilepos : tfileposinfo;
|
storefilepos : tfileposinfo;
|
||||||
cursectype : TAsmSectionType;
|
cursectype : TAsmSectionType;
|
||||||
hrec : threc;
|
hrec : threc;
|
||||||
|
section : ansistring;
|
||||||
begin
|
begin
|
||||||
{ mark the staticvarsym as typedconst }
|
{ mark the staticvarsym as typedconst }
|
||||||
include(sym.varoptions,vo_is_typed_const);
|
include(sym.varoptions,vo_is_typed_const);
|
||||||
@ -1481,6 +1482,23 @@ implementation
|
|||||||
) then
|
) then
|
||||||
read_public_and_external(sym);
|
read_public_and_external(sym);
|
||||||
|
|
||||||
|
{ try to parse a section directive }
|
||||||
|
if not in_structure and (target_info.system in systems_allow_section) and
|
||||||
|
(symtablestack.top.symtabletype in [staticsymtable,globalsymtable]) and
|
||||||
|
(idtoken=_SECTION) then
|
||||||
|
begin
|
||||||
|
try_consume_sectiondirective(section);
|
||||||
|
if section<>'' then
|
||||||
|
begin
|
||||||
|
if (sym.varoptions *[vo_is_external,vo_is_weak_external])<>[] then
|
||||||
|
Message(parser_e_externals_no_section);
|
||||||
|
if sym.typ<>staticvarsym then
|
||||||
|
Message(parser_e_section_no_locals);
|
||||||
|
tstaticvarsym(sym).section:=section;
|
||||||
|
include(sym.varoptions, vo_has_section);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ only now add items based on the symbolname, because it may }
|
{ only now add items based on the symbolname, because it may }
|
||||||
{ have been modified by the directives parsed above }
|
{ have been modified by the directives parsed above }
|
||||||
if vo_has_section in sym.varoptions then
|
if vo_has_section in sym.varoptions then
|
||||||
|
@ -1366,33 +1366,8 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
procedure tstaticvarsym.set_mangledname(const s:string);
|
procedure tstaticvarsym.set_mangledname(const s:string);
|
||||||
{$ifdef TEST_TLS_DIRECTORY}
|
|
||||||
{ TLS directory requires some labels in specific sections
|
|
||||||
I implemented this by allowing '.section sec_name mangled_name'
|
|
||||||
for name 'xxxx'; specifier PM 2011-07-01 }
|
|
||||||
var
|
|
||||||
newmangledname : string;
|
|
||||||
p : longint;
|
|
||||||
{$endif TEST_TLS_DIRECTORY}
|
|
||||||
begin
|
begin
|
||||||
stringdispose(_mangledname);
|
stringdispose(_mangledname);
|
||||||
{$ifdef TEST_TLS_DIRECTORY}
|
|
||||||
if copy(s,1,length('.section '))='.section ' then
|
|
||||||
begin
|
|
||||||
newmangledname:=copy(s,length('.section ')+1,length(s));
|
|
||||||
p:=pos(' ',newmangledname);
|
|
||||||
if p<2 then
|
|
||||||
Comment(V_Error,'Invalid C var name '+s)
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
section:=copy(newmangledname,1,p-1);
|
|
||||||
include(varoptions,vo_has_section);
|
|
||||||
newmangledname:=copy(newmangledname,p+1,length(newmangledname));
|
|
||||||
set_mangledname(newmangledname);
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
{$endif TEST_TLS_DIRECTORY}
|
|
||||||
{$ifdef compress}
|
{$ifdef compress}
|
||||||
_mangledname:=stringdup(minilzw_encode(s));
|
_mangledname:=stringdup(minilzw_encode(s));
|
||||||
{$else}
|
{$else}
|
||||||
|
@ -239,6 +239,15 @@ interface
|
|||||||
system_mips_embedded,system_arm_embedded,
|
system_mips_embedded,system_arm_embedded,
|
||||||
system_powerpc64_embedded];
|
system_powerpc64_embedded];
|
||||||
|
|
||||||
|
{ all systems that allow section directive }
|
||||||
|
systems_allow_section = systems_embedded;
|
||||||
|
|
||||||
|
systems_allow_section_no_semicolon = systems_allow_section
|
||||||
|
{$ifdef TEST_TLS_DIRECTORY}
|
||||||
|
+ systems_windows
|
||||||
|
{$endif TEST_TLS_DIRECTORY}
|
||||||
|
;
|
||||||
|
|
||||||
{ all symbian systems }
|
{ all symbian systems }
|
||||||
systems_symbian = [system_i386_symbian,system_arm_symbian];
|
systems_symbian = [system_i386_symbian,system_arm_symbian];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user