mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 20:49:26 +02:00
A unit's threadvar list needs to be indirectly referenced by the THREADVARLIST as well.
compiler/ngenutil.pas, tnodeutils: * InsertThreadvarTablesTable: reference a unit's (and the program's) threadvar table using a indirect symbol * InsertThreadvars: generate an indirect symbol for the threadvar table rtl/inc/threadvr.inc: * TltvInitTablesTable: add an additional indirection for the tables field git-svn-id: trunk@34043 -
This commit is contained in:
parent
c335a3ea6e
commit
72be688a8c
@ -1037,8 +1037,9 @@ implementation
|
|||||||
begin
|
begin
|
||||||
if (hp.u.flags and uf_threadvars)=uf_threadvars then
|
if (hp.u.flags and uf_threadvars)=uf_threadvars then
|
||||||
begin
|
begin
|
||||||
|
sym:=current_asmdata.RefAsmSymbol(make_mangledname('THREADVARLIST',hp.u.globalsymtable,''),AT_DATA,true);
|
||||||
tcb.emit_tai(
|
tcb.emit_tai(
|
||||||
tai_const.Createname(make_mangledname('THREADVARLIST',hp.u.globalsymtable,''),0),
|
tai_const.Create_sym(sym),
|
||||||
voidpointertype);
|
voidpointertype);
|
||||||
inc(count);
|
inc(count);
|
||||||
end;
|
end;
|
||||||
@ -1047,8 +1048,9 @@ implementation
|
|||||||
{ Add program threadvars, if any }
|
{ Add program threadvars, if any }
|
||||||
if (current_module.flags and uf_threadvars)=uf_threadvars then
|
if (current_module.flags and uf_threadvars)=uf_threadvars then
|
||||||
begin
|
begin
|
||||||
|
sym:=current_asmdata.RefAsmSymbol(make_mangledname('THREADVARLIST',current_module.localsymtable,''),AT_DATA,true);
|
||||||
tcb.emit_tai(
|
tcb.emit_tai(
|
||||||
Tai_const.Createname(make_mangledname('THREADVARLIST',current_module.localsymtable,''),0),
|
Tai_const.Create_sym(sym),
|
||||||
voidpointertype);
|
voidpointertype);
|
||||||
inc(count);
|
inc(count);
|
||||||
end;
|
end;
|
||||||
@ -1094,6 +1096,7 @@ implementation
|
|||||||
tcb: ttai_typedconstbuilder;
|
tcb: ttai_typedconstbuilder;
|
||||||
sym: tasmsymbol;
|
sym: tasmsymbol;
|
||||||
tabledef: trecorddef;
|
tabledef: trecorddef;
|
||||||
|
add : boolean;
|
||||||
begin
|
begin
|
||||||
if (tf_section_threadvars in target_info.flags) then
|
if (tf_section_threadvars in target_info.flags) then
|
||||||
exit;
|
exit;
|
||||||
@ -1108,15 +1111,28 @@ implementation
|
|||||||
{ terminator }
|
{ terminator }
|
||||||
tcb.emit_tai(tai_const.Create_nil_dataptr,voidpointertype);
|
tcb.emit_tai(tai_const.Create_nil_dataptr,voidpointertype);
|
||||||
tcb.end_anonymous_record;
|
tcb.end_anonymous_record;
|
||||||
if trecordsymtable(tabledef.symtable).datasize<>0 then
|
add:=trecordsymtable(tabledef.symtable).datasize<>0;
|
||||||
|
if add then
|
||||||
begin
|
begin
|
||||||
s:=make_mangledname('THREADVARLIST',current_module.localsymtable,'');
|
s:=make_mangledname('THREADVARLIST',current_module.localsymtable,'');
|
||||||
sym:=current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA);
|
sym:=current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA);
|
||||||
current_asmdata.asmlists[al_globals].concatlist(
|
current_asmdata.asmlists[al_globals].concatlist(
|
||||||
tcb.get_final_asmlist(sym,tabledef,sec_data,s,sizeof(pint)));
|
tcb.get_final_asmlist(sym,tabledef,sec_data,s,sizeof(pint)));
|
||||||
current_module.flags:=current_module.flags or uf_threadvars;
|
current_module.flags:=current_module.flags or uf_threadvars;
|
||||||
end;
|
end
|
||||||
|
else
|
||||||
|
s:='';
|
||||||
tcb.Free;
|
tcb.Free;
|
||||||
|
if add then
|
||||||
|
begin
|
||||||
|
{ write indirect symbol }
|
||||||
|
tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]);
|
||||||
|
sym:=current_asmdata.DefineAsmSymbol(s,AB_INDIRECT,AT_DATA);
|
||||||
|
tcb.emit_tai(Tai_const.Create_sym(current_asmdata.RefAsmSymbol(s,AT_DATA,false)),voidpointertype);
|
||||||
|
current_asmdata.AsmLists[al_globals].concatList(
|
||||||
|
tcb.get_final_asmlist(sym,voidpointertype,sec_rodata,sym.name,const_align(sizeof(pint))));
|
||||||
|
tcb.free;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
type
|
type
|
||||||
pltvInitEntry = ^ltvInitEntry;
|
pltvInitEntry = ^ltvInitEntry;
|
||||||
|
ppltvInitEntry = ^pltvInitEntry;
|
||||||
ltvInitEntry = packed record
|
ltvInitEntry = packed record
|
||||||
varaddr : {$ifdef cpu16}pword{$else}pdword{$endif};
|
varaddr : {$ifdef cpu16}pword{$else}pdword{$endif};
|
||||||
size : longint;
|
size : longint;
|
||||||
@ -29,7 +30,7 @@ type
|
|||||||
|
|
||||||
TltvInitTablesTable = packed record
|
TltvInitTablesTable = packed record
|
||||||
count : dword;
|
count : dword;
|
||||||
tables : packed array [1..{$ifdef cpu16}16{$else}32767{$endif}] of pltvInitEntry;
|
tables : packed array [1..{$ifdef cpu16}16{$else}32767{$endif}] of {$ifdef ver3_0}pltvInitEntry{$else}ppltvInitEntry{$endif};
|
||||||
end;
|
end;
|
||||||
PltvInitTablesTable = ^TltvInitTablesTable;
|
PltvInitTablesTable = ^TltvInitTablesTable;
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ begin
|
|||||||
WriteLn ('init_all_unit_threadvars (',count,') units');
|
WriteLn ('init_all_unit_threadvars (',count,') units');
|
||||||
{$endif}
|
{$endif}
|
||||||
for i := 1 to count do
|
for i := 1 to count do
|
||||||
init_unit_threadvars (tables[i]);
|
init_unit_threadvars (tables[i]{$ifndef ver3_0}^{$endif});
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ begin
|
|||||||
WriteLn ('copy_all_unit_threadvars (',count,') units');
|
WriteLn ('copy_all_unit_threadvars (',count,') units');
|
||||||
{$endif}
|
{$endif}
|
||||||
for i := 1 to count do
|
for i := 1 to count do
|
||||||
copy_unit_threadvars (tables[i]);
|
copy_unit_threadvars (tables[i]{$ifndef ver3_0}^{$endif});
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user