Sergei Gorelkin wrote:
Attached is a one-line fix that makes programs a couple of bytes smaller by preventing creation of empty threadvar tables when threadvars are not actually used. The condition "Assigned(TAsmList.First)" always evaluates to True because the list contains at least one marker item.
Whoops, not that easy. It appears that Tresourcestrings.CreateResourceStringData does not create new section in current_asmdata.asmlists[al_const] and therefore it depends on the state in which that asmlist was left by the previously executed code. Hence, compiling a unit that does not have threadvars but has resourcestrings ends up in an IE.
Attached a corrected patch. The section prefix 'RESSTRTABLE' is my wild guess, so it may need to be changed.
Regards, Sergei
Index: cresstr.pas =================================================================== --- cresstr.pas (revision 13026) +++ cresstr.pas (working copy) @@ -162,6 +162,7 @@ makes the linking too dependent on the linker script requiring a SORT(*) for the data sections } maybe_new_object_file(current_asmdata.asmlists[al_const]); + new_section(current_asmdata.asmlists[al_const],sec_data,make_mangledname('RESSTRTABLE',current_module.localsymtable,''),sizeof(pint)); maybe_new_object_file(current_asmdata.asmlists[al_resourcestrings]); new_section(current_asmdata.asmlists[al_resourcestrings],sec_data,make_mangledname('RESSTR',current_module.localsymtable,'1_START'),sizeof(pint)); current_asmdata.AsmLists[al_resourcestrings].concat(tai_symbol.createname_global( Index: pmodules.pas =================================================================== --- pmodules.pas (revision 13026) +++ pmodules.pas (working copy) @@ -219,7 +219,7 @@ if assigned(current_module.globalsymtable) then current_module.globalsymtable.SymList.ForEachCall(@AddToThreadvarList,ltvTable); current_module.localsymtable.SymList.ForEachCall(@AddToThreadvarList,ltvTable); - if ltvTable.first<>nil then + if not ltvTable.empty then begin s:=make_mangledname('THREADVARLIST',current_module.localsymtable,''); { end of the list marker }
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel