* limit number of possible units with initialization/finalization for a certain architecture to high(aint)

+ give an error if the number of possible units is exceeded

git-svn-id: trunk@30450 -
This commit is contained in:
florian 2015-04-05 21:06:58 +00:00
parent b684719f1e
commit 9ab9e03650
5 changed files with 382 additions and 376 deletions

View File

@ -2443,6 +2443,9 @@ cg_e_function_not_support_by_selected_instruction_set=06056_E_The function used,
% Some functions cannot be implemented efficiently for certain instruction sets, one example is fused multiply/add.
% To avoid very inefficient code, the compiler complains in this case, so either select another instruction set
% or replace the function call by alternative code
cg_f_max_units_reached=06057_F_Maximum number of units ($1) reached for the current target
% Depending of target architecture, the number of units is limited. This limit
% has been reached. A unit counts only if it contains initialization or finalization count.
%
% \end{description}
# EndOfTeX

View File

@ -673,6 +673,7 @@ const
cg_e_mod_only_defined_for_pos_quotient=06054;
cg_d_autoinlining=06055;
cg_e_function_not_support_by_selected_instruction_set=06056;
cg_f_max_units_reached=06057;
asmr_d_start_reading=07000;
asmr_d_finish_reading=07001;
asmr_e_none_label_contain_at=07002;
@ -1007,9 +1008,9 @@ const
option_info=11024;
option_help_pages=11025;
MsgTxtSize = 75323;
MsgTxtSize = 75391;
MsgIdxMax : array[1..20] of longint=(
26,99,341,1000,96,57,126,29,202,64,
26,99,341,1000,96,58,126,29,202,64,
58,20,1,1,1,1,1,1,1,1
);

File diff suppressed because it is too large Load Diff

View File

@ -672,6 +672,8 @@ implementation
{ call the unit init code and make it external }
if (hp.u.flags and (uf_init or uf_finalize))<>0 then
begin
if count=high(aint) then
Message1(cg_f_max_units_reached,tostr(count));
if (hp.u.flags and uf_init)<>0 then
unitinits.concat(Tai_const.Createname(make_mangledname('INIT$',hp.u.globalsymtable,''),AT_FUNCTION,0))
else
@ -701,8 +703,8 @@ implementation
inc(count);
end;
{ Insert TableCount,InitCount at start }
unitinits.insert(Tai_const.Create_pint(0));
unitinits.insert(Tai_const.Create_pint(count));
unitinits.insert(Tai_const.Create_aint(0));
unitinits.insert(Tai_const.Create_aint(count));
{ Add to data segment }
maybe_new_object_file(current_asmdata.asmlists[al_globals]);
new_section(current_asmdata.asmlists[al_globals],sec_data,'INITFINAL',const_align(sizeof(pint)));

View File

@ -859,7 +859,10 @@ type
end;
TInitFinalTable = record
TableCount,
InitCount : {$ifdef VER2_6}longint{$else}sizeint{$endif};
InitCount : {$if defined(VER2)}longint
{$elseif defined(VER3_0)}sizeint
{$else}ALUUInt{$endif}
;
Procs : array[1..maxunits] of TInitFinalRec;
end;
PInitFinalTable = ^TInitFinalTable;
@ -873,7 +876,7 @@ var
procedure fpc_InitializeUnits;[public,alias:'FPC_INITIALIZEUNITS']; compilerproc;
var
i : ObjpasInt;
i : ALUUInt;
{$ifdef DEBUG}
pt : PInitFinalTable;
{$endif}
@ -892,7 +895,7 @@ begin
with InitFinalTable do
{$endif FPC_HAS_INDIRECT_MAIN_INFORMATION}
begin
for i:=1 to TableCount do
for i:=1 to ALUUInt(TableCount) do
begin
if assigned(Procs[i].InitProc) then
Procs[i].InitProc();
@ -1513,9 +1516,6 @@ end;
File Handling
*****************************************************************************}
{$ifdef FPC_HAS_FEATURE_FILEIO}
{ Allow slash and backslash as separators }
procedure DoDirSeparators(var p: pchar; inplace: boolean = true);