* cleaned up segmented thread variables

git-svn-id: trunk@2135 -
This commit is contained in:
florian 2006-01-03 12:49:29 +00:00
parent 3ccec3fbdd
commit 61e3b70cfa
12 changed files with 94 additions and 58 deletions

View File

@ -235,6 +235,10 @@ implementation
else else
secname:=secnames[atype]; secname:=secnames[atype];
if (atype=sec_threadvar) and
(target_info.system=system_i386_win32) then
secname:='.tls';
if use_smartlink_section and if use_smartlink_section and
(aname<>'') then (aname<>'') then
result:=secname+'.'+aname result:=secname+'.'+aname

View File

@ -1412,9 +1412,8 @@ Implementation
exclude(to_do,al_exports); exclude(to_do,al_exports);
{$warning TODO internal writer support for dwarf} {$warning TODO internal writer support for dwarf}
exclude(to_do,al_dwarf); exclude(to_do,al_dwarf);
{$ifndef segment_threadvars} if not(tf_section_threadvars in target_info.flags) then
exclude(to_do,al_threadvars); exclude(to_do,al_threadvars);
{$endif}
for i:=low(Tasmlist) to high(Tasmlist) do for i:=low(Tasmlist) to high(Tasmlist) do
if (i in to_do) and (asmlist[i]<>nil) then if (i in to_do) and (asmlist[i]<>nil) then
addlist(asmlist[i]); addlist(asmlist[i]);

View File

@ -208,10 +208,8 @@ unit cgcpu;
begin begin
with r do with r do
begin begin
{$ifndef segment_threadvars}
if (segment<>NR_NO) then if (segment<>NR_NO) then
cgmessage(cg_e_cant_use_far_pointer_there); cgmessage(cg_e_cant_use_far_pointer_there);
{$endif}
if use_push(cgpara) then if use_push(cgpara) then
begin begin
cgpara.check_simple_location; cgpara.check_simple_location;

View File

@ -134,9 +134,9 @@ implementation
cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,location.reference,hregister); cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,location.reference,hregister);
reference_reset_base(location.reference,hregister,0); reference_reset_base(location.reference,hregister,0);
end end
{$ifndef segment_threadvars}
{ Thread variable } { Thread variable }
else if (vo_is_thread_var in tabstractvarsym(symtableentry).varoptions) then else if (vo_is_thread_var in tabstractvarsym(symtableentry).varoptions) and
not(tf_section_threadvars in target_info.flags) then
begin begin
{ {
Thread var loading is optimized to first check if Thread var loading is optimized to first check if
@ -181,7 +181,6 @@ implementation
cg.a_label(exprasmlist,endrelocatelab); cg.a_label(exprasmlist,endrelocatelab);
location.reference.base:=hregister; location.reference.base:=hregister;
end end
{$endif}
{ Nested variable } { Nested variable }
else if assigned(left) then else if assigned(left) then
begin begin
@ -233,10 +232,18 @@ implementation
reference_reset_symbol(location.reference,objectlibrary.newasmsymbol(tglobalvarsym(symtableentry).mangledname,AB_EXTERNAL,AT_DATA),0) reference_reset_symbol(location.reference,objectlibrary.newasmsymbol(tglobalvarsym(symtableentry).mangledname,AB_EXTERNAL,AT_DATA),0)
else else
location:=tglobalvarsym(symtableentry).localloc; location:=tglobalvarsym(symtableentry).localloc;
{$ifdef segment_threadvars} {$ifdef i386}
if (vo_is_thread_var in tabstractvarsym(symtableentry).varoptions) then if (tf_section_threadvars in target_info.flags) and
location.reference.segment:=NR_GS; (vo_is_thread_var in tabstractvarsym(symtableentry).varoptions) then
{$endif} begin
case target_info.system of
system_i386_linux:
location.reference.segment:=NR_GS;
system_i386_win32:
location.reference.segment:=NR_FS;
end;
end;
{$endif i386}
end; end;
else else
internalerror(200305102); internalerror(200305102);

View File

@ -1940,23 +1940,26 @@ implementation
storefilepos:=aktfilepos; storefilepos:=aktfilepos;
aktfilepos:=sym.fileinfo; aktfilepos:=sym.fileinfo;
l:=sym.getsize; l:=sym.getsize;
{$ifndef segment_threadvars} if tf_section_threadvars in target_info.flags then
if (vo_is_thread_var in sym.varoptions) then
inc(l,sizeof(aint));
list:=asmlist[al_globals];
sectype:=sec_bss;
{$else}
if (vo_is_thread_var in sym.varoptions) then
begin begin
list:=asmlist[al_threadvars]; if (vo_is_thread_var in sym.varoptions) then
sectype:=sec_threadvar; begin
list:=asmlist[al_threadvars];
sectype:=sec_threadvar;
end
else
begin
list:=asmlist[al_globals];
sectype:=sec_bss;
end;
end end
else else
begin begin
if (vo_is_thread_var in sym.varoptions) then
inc(l,sizeof(aint));
list:=asmlist[al_globals]; list:=asmlist[al_globals];
sectype:=sec_bss; sectype:=sec_bss;
end; end;
{$endif}
varalign:=var_align(l); varalign:=var_align(l);
maybe_new_object_file(list); maybe_new_object_file(list);
new_section(list,sectype,lower(sym.mangledname),varalign); new_section(list,sectype,lower(sym.mangledname),varalign);
@ -2065,8 +2068,8 @@ implementation
staticsymtable : staticsymtable :
begin begin
{ PIC, DLL and Threadvar need extra code and are handled in ncgld } { PIC, DLL and Threadvar need extra code and are handled in ncgld }
if not(vo_is_dll_var in varoptions) {$ifndef segment_threadvars} and if not(vo_is_dll_var in varoptions) and ((tf_section_threadvars in target_info.flags) or
not(vo_is_thread_var in varoptions) {$endif} then not(vo_is_thread_var in varoptions)) then
reference_reset_symbol(localloc.reference,objectlibrary.newasmsymbol(mangledname,AB_EXTERNAL,AT_DATA),0); reference_reset_symbol(localloc.reference,objectlibrary.newasmsymbol(mangledname,AB_EXTERNAL,AT_DATA),0);
end; end;
else else

View File

@ -553,7 +553,7 @@ const go32v2stub : array[0..2047] of byte=(
function TCoffObjectData.sectionname(atype:tasmsectiontype;const aname:string):string; function TCoffObjectData.sectionname(atype:tasmsectiontype;const aname:string):string;
const const
secnames : array[tasmsectiontype] of string[16] = ('', secnames : array[tasmsectiontype] of string[16] = ('',
'.text','.data','.data','.bss','.threadvar', '.text','.data','.data','.bss','.tls',
'common', 'common',
'.note', '.note',
'.text', '.text',

View File

@ -320,9 +320,8 @@ implementation
createsection(sec_code,'',0,[]); createsection(sec_code,'',0,[]);
createsection(sec_data,'',0,[]); createsection(sec_data,'',0,[]);
createsection(sec_bss,'',0,[]); createsection(sec_bss,'',0,[]);
{$ifdef segment_threadvars} if tf_section_threadvars in target_info.flags then
createsection(sec_threadvar,'',0,[]); createsection(sec_threadvar,'',0,[]);
{$endif}
{ create stabs sections if debugging } { create stabs sections if debugging }
if (cs_debuginfo in aktmoduleswitches) then if (cs_debuginfo in aktmoduleswitches) then
begin begin

View File

@ -143,7 +143,6 @@ implementation
end; end;
{$ifndef segment_threadvars}
procedure InsertThreadvarTablesTable; procedure InsertThreadvarTablesTable;
var var
hp : tused_unit; hp : tused_unit;
@ -219,7 +218,7 @@ implementation
end; end;
ltvTable.Free; ltvTable.Free;
end; end;
{$endif}
Procedure InsertResourceInfo; Procedure InsertResourceInfo;
@ -1189,9 +1188,8 @@ implementation
gen_pic_helpers(asmlist[al_procedures]); gen_pic_helpers(asmlist[al_procedures]);
{ generate a list of threadvars } { generate a list of threadvars }
{$ifndef segment_threadvars} if not(tf_section_threadvars in target_info.flags) then
InsertThreadvars; InsertThreadvars;
{$endif}
{ generate imports } { generate imports }
if current_module.uses_imports then if current_module.uses_imports then
@ -1512,10 +1510,10 @@ implementation
{ generate pic helpers to load eip if necessary } { generate pic helpers to load eip if necessary }
gen_pic_helpers(asmlist[al_procedures]); gen_pic_helpers(asmlist[al_procedures]);
{$ifndef segment_threadvars}
{ generate a list of threadvars } { generate a list of threadvars }
InsertThreadvars; if not(tf_section_threadvars in target_info.flags) then
{$endif} InsertThreadvars;
{ generate imports } { generate imports }
if current_module.uses_imports then if current_module.uses_imports then
@ -1525,9 +1523,9 @@ implementation
exportlib.generatelib; exportlib.generatelib;
{ insert Tables and StackLength } { insert Tables and StackLength }
{$ifndef segment_threadvars} if not(tf_section_threadvars in target_info.flags) then
insertThreadVarTablesTable; insertThreadVarTablesTable;
{$endif}
insertResourceTablesTable; insertResourceTablesTable;
insertinitfinaltable; insertinitfinaltable;
insertmemorysizes; insertmemorysizes;

View File

@ -248,15 +248,18 @@ interface
tsystemflags = (tf_none, tsystemflags = (tf_none,
tf_under_development, tf_under_development,
tf_need_export,tf_needs_isconsole, tf_need_export,
tf_code_small,tf_static_reg_based, tf_needs_isconsole,
tf_code_small,
tf_static_reg_based,
tf_needs_symbol_size, tf_needs_symbol_size,
tf_smartlink_sections, tf_smartlink_sections,
tf_needs_dwarf_cfi, tf_needs_dwarf_cfi,
tf_use_8_3, tf_use_8_3,
tf_pic_uses_got, tf_pic_uses_got,
tf_library_needs_pic, tf_library_needs_pic,
tf_needs_symbol_type tf_needs_symbol_type,
tf_section_threadvars
); );
psysteminfo = ^tsysteminfo; psysteminfo = ^tsysteminfo;

View File

@ -46,7 +46,11 @@ unit i_linux;
system : system_i386_LINUX; system : system_i386_LINUX;
name : 'Linux for i386'; name : 'Linux for i386';
shortname : 'Linux'; shortname : 'Linux';
flags : [tf_needs_symbol_size,tf_pic_uses_got{,tf_smartlink_sections},tf_needs_symbol_type]; flags : [tf_needs_symbol_size,tf_pic_uses_got{,tf_smartlink_sections},
{$ifdef segment_threadvars}
tf_section_threadvars,
{$endif segment_threadvars}
tf_needs_symbol_type];
cpu : cpu_i386; cpu : cpu_i386;
unit_env : 'LINUXUNITS'; unit_env : 'LINUXUNITS';
extradefines : 'UNIX;HASUNIX'; extradefines : 'UNIX;HASUNIX';

View File

@ -32,7 +32,7 @@ unit i_win;
system : system_i386_WIN32; system : system_i386_WIN32;
name : 'Win32 for i386'; name : 'Win32 for i386';
shortname : 'Win32'; shortname : 'Win32';
flags : []; flags : [{tf_section_threadvars}];
cpu : cpu_i386; cpu : cpu_i386;
unit_env : 'WIN32UNITS'; unit_env : 'WIN32UNITS';
extradefines : 'MSWINDOWS'; extradefines : 'MSWINDOWS';

View File

@ -766,20 +766,41 @@ unit cgx86;
make_simple_ref(list,tmpref); make_simple_ref(list,tmpref);
list.concat(Taicpu.op_ref_reg(A_LEA,tcgsize2opsize[OS_ADDR],tmpref,r)); list.concat(Taicpu.op_ref_reg(A_LEA,tcgsize2opsize[OS_ADDR],tmpref,r));
end; end;
if (segment<>NR_NO) then if segment<>NR_NO then
if segment=NR_GS then begin
begin if (tf_section_threadvars in target_info.flags) then
{$ifdef segment_threadvars} begin
{Convert thread local address to a process global addres { Convert thread local address to a process global addres
as we cannot handle far pointers.} as we cannot handle far pointers.}
reference_reset_symbol(tmpref,objectlibrary.newasmsymbol( case target_info.system of
'___fpc_threadvar_offset',AB_EXTERNAL,AT_DATA),0); system_i386_linux:
tmpref.segment:=NR_GS; if segment=NR_GS then
list.concat(Taicpu.op_ref_reg(A_ADD,tcgsize2opsize[OS_ADDR],tmpref,r)); begin
{$endif} reference_reset_symbol(tmpref,objectlibrary.newasmsymbol(
end '___fpc_threadvar_offset',AB_EXTERNAL,AT_DATA),0);
else tmpref.segment:=NR_GS;
cgmessage(cg_e_cant_use_far_pointer_there); list.concat(Taicpu.op_ref_reg(A_ADD,tcgsize2opsize[OS_ADDR],tmpref,r));
end
else
cgmessage(cg_e_cant_use_far_pointer_there);
system_i386_win32:
if segment=NR_FS then
begin
allocallcpuregisters(list);
a_call_name(list,'GetTls');
deallocallcpuregisters(list);
list.concat(Taicpu.op_reg_reg(A_ADD,tcgsize2opsize[OS_ADDR],NR_EAX,r));
end
else
cgmessage(cg_e_cant_use_far_pointer_there);
else
cgmessage(cg_e_cant_use_far_pointer_there);
end;
end
else
cgmessage(cg_e_cant_use_far_pointer_there);
end;
end; end;
end; end;