From 7aa3b99fb53a0b0aead5425123969296507de2fa Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Wed, 11 Apr 2012 18:05:50 +0000 Subject: [PATCH] + -CN/{$CHECKLOWADDRLOADS+/-} switch to enable explicit checks for accesses to low addresses in case the target cpu/OS does not support this (enabled for reads on AIX/PPC because on AIX the first 16KB are readable) git-svn-id: trunk@20832 - --- compiler/globtype.pas | 1 + compiler/msg/errore.msg | 1 + compiler/msgidx.inc | 2 +- compiler/msgtxt.inc | 185 +++++++++++++++++++------------------ compiler/options.pas | 5 + compiler/powerpc/cgcpu.pas | 2 + compiler/ppcgen/cgppc.pas | 44 +++++++++ compiler/scandir.pas | 7 ++ rtl/inc/system.inc | 6 ++ 9 files changed, 160 insertions(+), 93 deletions(-) diff --git a/compiler/globtype.pas b/compiler/globtype.pas index 253db31cb8..ee51c37cb5 100644 --- a/compiler/globtype.pas +++ b/compiler/globtype.pas @@ -120,6 +120,7 @@ interface cs_generate_stackframes,cs_do_assertion,cs_generate_rtti, cs_full_boolean_eval,cs_typed_const_writable,cs_allow_enum_calc, cs_do_inline,cs_fpu_fwait,cs_ieee_errors, + cs_check_low_addr_load, { mmx } cs_mmx,cs_mmx_saturation, { parser } diff --git a/compiler/msg/errore.msg b/compiler/msg/errore.msg index 384b41edd0..ed72b84a91 100644 --- a/compiler/msg/errore.msg +++ b/compiler/msg/errore.msg @@ -3223,6 +3223,7 @@ S*2Aas_Assemble using GNU AS **2Ch_ bytes heap (between 1023 and 67107840) **2Ci_IO-checking **2Cn_Omit linking stage +P*2CN_Generate nil-pointer checks (AIX-only) **2Co_Check overflow of integer operations **2CO_Check for possible overflow of integer operations **2Cp_Select instruction set, see fpc -i for possible values diff --git a/compiler/msgidx.inc b/compiler/msgidx.inc index e94049fe2e..a9fdbe25c5 100644 --- a/compiler/msgidx.inc +++ b/compiler/msgidx.inc @@ -925,7 +925,7 @@ const option_info=11024; option_help_pages=11025; - MsgTxtSize = 63667; + MsgTxtSize = 63712; MsgIdxMax : array[1..20] of longint=( 26,90,315,112,85,55,116,26,202,63, diff --git a/compiler/msgtxt.inc b/compiler/msgtxt.inc index 674045ecca..afd0b07968 100644 --- a/compiler/msgtxt.inc +++ b/compiler/msgtxt.inc @@ -1195,151 +1195,152 @@ const msgtxt : array[0..000265,1..240] of char=( '**2Ch_ bytes heap (between 1023 and 67107840)'#010+ '**2Ci_IO-checking'#010+ '**2Cn_Omit linki','ng stage'#010+ + 'P*2CN_Generate nil-pointer checks (AIX-only)'#010+ '**2Co_Check overflow of integer operations'#010+ '**2CO_Check for possible overflow of integer operations'#010+ '**2Cp_Select instruction set, see fpc -i for possible values'#010+ - '**2CP=_ packing settings'#010+ - '**3CPPACKSET=_ set allocation:',' 0, 1 or DEFAULT or NORMAL, 2, '+ - '4 and 8'#010+ + '**2CP=_ packing s','ettings'#010+ + '**3CPPACKSET=_ set allocation: 0, 1 or DEFAULT or NORMAL, 2, 4 '+ + 'and 8'#010+ '**2Cr_Range checking'#010+ '**2CR_Verify object method call validity'#010+ '**2Cs_Set stack checking size to '#010+ '**2Ct_Stack checking (for testing only, see manual)'#010+ - '**2CX_Create also smartlinked library'#010+ - '**1d_D','efines the symbol '#010+ + '**','2CX_Create also smartlinked library'#010+ + '**1d_Defines the symbol '#010+ '**1D_Generate a DEF file'#010+ '**2Dd_Set description to '#010+ '**2Dv_Set DLL version to '#010+ '*O2Dw_PM application'#010+ '**1e_Set path to executable'#010+ '**1E_Same as -Cn'#010+ - '**1fPIC_Same as -Cg'#010+ + '**1fPIC_Same as',' -Cg'#010+ '**1F_Set file names and paths:'#010+ - '**2Fa<','x>[,y]_(for a program) load units and [y] before uses is p'+ - 'arsed'#010+ + '**2Fa[,y]_(for a program) load units and [y] before uses is par'+ + 'sed'#010+ '**2Fc_Set input codepage to '#010+ '**2FC_Set RC compiler binary name to '#010+ - '**2Fd_Disable the compiler'#039's internal directory cache'#010+ - '**2FD_Set the directory where to sea','rch for compiler utilities'#010+ + '**2Fd_Disable the compiler'#039's internal directory ','cache'#010+ + '**2FD_Set the directory where to search for compiler utilities'#010+ '**2Fe_Redirect error output to '#010+ '**2Ff_Add to framework path (Darwin only)'#010+ '**2FE_Set exe/unit output path to '#010+ '**2Fi_Add to include path'#010+ - '**2Fl_Add to library path'#010+ - '**2FL_Use as',' dynamic linker'#010+ + '**2Fl_Add to library path'#010+ + '**2FL_Use as dynamic linker'#010+ '**2Fm_Load unicode conversion table from .txt in the compiler di'+ 'r'#010+ '**2Fo_Add to object path'#010+ '**2Fr_Load error message file '#010+ - '**2FR_Set resource (.res) linker to '#010+ + '**2FR_Set resource (.res) linker to',' '#010+ '**2Fu_Add to unit path'#010+ - '**2FU_S','et unit output path to , overrides -FE'#010+ + '**2FU_Set unit output path to , overrides -FE'#010+ '**2FW_Store generated whole-program optimization feedback in '#010+ '**2Fw_Load previously stored whole-program optimization feedback fr'+ 'om '#010+ - '*g1g_Generate debug information (default format for t','arget)'#010+ + '*g1g_Gen','erate debug information (default format for target)'#010+ '*g2gc_Generate checks for pointers'#010+ '*g2gh_Use heaptrace unit (for memory leak/corruption debugging)'#010+ '*g2gl_Use line info unit (show more info with backtraces)'#010+ - '*g2go_Set debug information options'#010+ - '*g3godwarfsets_ Enable DWARF '#039'set'#039' ty','pe debug information (b'+ - 'reaks gdb < 6.5)'#010+ + '*g2go_Set debug information ','options'#010+ + '*g3godwarfsets_ Enable DWARF '#039'set'#039' type debug information (bre'+ + 'aks gdb < 6.5)'#010+ '*g3gostabsabsincludes_ Store absolute/full include file paths in Stabs'+ #010+ '*g3godwarfmethodclassprefix_ Prefix method names in DWARF with class n'+ 'ame'#010+ - '*g2gp_Preserve case in stabs symbol names'#010+ - '*g2gs_Generat','e Stabs debug information'#010+ + '*g2gp_Pres','erve case in stabs symbol names'#010+ + '*g2gs_Generate Stabs debug information'#010+ '*g2gt_Trash local variables (to detect uninitialized uses)'#010+ '*g2gv_Generates programs traceable with Valgrind'#010+ '*g2gw_Generate DWARFv2 debug information (same as -gw2)'#010+ - '*g2gw2_Generate DWARFv2 debug information'#010+ - '*g2gw3_G','enerate DWARFv3 debug information'#010+ + '*g2gw','2_Generate DWARFv2 debug information'#010+ + '*g2gw3_Generate DWARFv3 debug information'#010+ '*g2gw4_Generate DWARFv4 debug information (experimental)'#010+ '**1i_Information'#010+ '**2iD_Return compiler date'#010+ '**2iV_Return short compiler version'#010+ - '**2iW_Return full compiler version'#010+ + '**2iW_Return full compil','er version'#010+ '**2iSO_Return compiler OS'#010+ - '**2iSP_R','eturn compiler host processor'#010+ + '**2iSP_Return compiler host processor'#010+ '**2iTO_Return target OS'#010+ '**2iTP_Return target processor'#010+ '**1I_Add to include path'#010+ '**1k_Pass to the linker'#010+ '**1l_Write logo'#010+ - '**1M_Set language mode to '#010+ + '**1M_Set language mode to '#010+ '**2Mfpc_Free Pascal dialect (default)'#010+ - '**2Mo','bjfpc_FPC mode with Object Pascal support'#010+ + '**2Mobjfpc_FPC mode with Object Pascal support'#010+ '**2Mdelphi_Delphi 7 compatibility mode'#010+ '**2Mtp_TP/BP 7.0 compatibility mode'#010+ '**2Mmacpas_Macintosh Pascal dialects compatibility mode'#010+ - '**1n_Do not read the default config files'#010+ - '**1N_Node tree optimiz','ations'#010+ + '**1n_Do not read the d','efault config files'#010+ + '**1N_Node tree optimizations'#010+ '**2Nu_Unroll loops'#010+ '**1o_Change the name of the executable produced to '#010+ '**1O_Optimizations:'#010+ '**2O-_Disable optimizations'#010+ '**2O1_Level 1 optimizations (quick and debugger friendly)'#010+ - '**2O2_Level 2 optimizations (-O1 + quick optimi','zations)'#010+ + '**','2O2_Level 2 optimizations (-O1 + quick optimizations)'#010+ '**2O3_Level 3 optimizations (-O2 + slow optimizations)'#010+ '**2Oa=_Set alignment'#010+ '**2Oo[NO]_Enable or disable optimizations, see fpc -i for possible '+ 'values'#010+ - '**2Op_Set target cpu for optimizing, see fpc -i for possible values'+ - #010+ - '*','*2OW_Generate whole-program optimization feedback for optimizati'+ - 'on , see fpc -i for possible values'#010+ + '**2Op_Set target cpu for',' optimizing, see fpc -i for possible valu'+ + 'es'#010+ + '**2OW_Generate whole-program optimization feedback for optimization'+ + ' , see fpc -i for possible values'#010+ '**2Ow_Perform whole-program optimization , see fpc -i for possib'+ 'le values'#010+ - '**2Os_Optimize for size rather than speed'#010+ - '**1pg_Genera','te profile code for gprof (defines FPC_PROFILE)'#010+ + '**2Os_Opt','imize for size rather than speed'#010+ + '**1pg_Generate profile code for gprof (defines FPC_PROFILE)'#010+ 'F*1P_Target CPU / compiler related options:'#010+ 'F*2PB_Show default compiler binary'#010+ 'F*2PP_Show default target cpu'#010+ - 'F*2P_Set target CPU (arm,i386,m68k,mips,mipsel,powerpc,powerpc64,sp'+ - 'arc,x86_64',#010+ + 'F*2P_Set target CPU (arm,i386,m6','8k,mips,mipsel,powerpc,powerpc64,'+ + 'sparc,x86_64'#010+ '**1R_Assembler reading style:'#010+ '**2Rdefault_Use default assembler for target'#010+ '3*2Ratt_Read AT&T style assembler'#010+ '3*2Rintel_Read Intel style assembler'#010+ '6*2RMOT_Read motorola style assembler'#010+ - '**1S_Syntax options:'#010+ + '**1S','_Syntax options:'#010+ '**2S2_Same as -Mobjfpc'#010+ - '**2Sc','_Support operators like C (*=,+=,/= and -=)'#010+ + '**2Sc_Support operators like C (*=,+=,/= and -=)'#010+ '**2Sa_Turn on assertions'#010+ '**2Sd_Same as -Mdelphi'#010+ '**2Se_Error options. is a combination of the following:'#010+ - '**3*_ : Compiler halts after the errors (default is 1)'#010+ - '**3*_w : Compiler also ','halts after warnings'#010+ + '**3*_ : Compiler halts after the ','errors (default is 1)'#010+ + '**3*_w : Compiler also halts after warnings'#010+ '**3*_n : Compiler also halts after notes'#010+ '**3*_h : Compiler also halts after hints'#010+ '**2Sg_Enable LABEL and GOTO (default in -Mtp and -Mdelphi)'#010+ - '**2Sh_Use ansistrings by default instead of shortstrings'#010+ - '**2Si_Turn on inlinin','g of procedures/functions declared as "inline"'#010+ + '**2Sh_Use ansistrings by default ','instead of shortstrings'#010+ + '**2Si_Turn on inlining of procedures/functions declared as "inline"'#010+ '**2Sk_Load fpcylix unit'#010+ '**2SI_Set interface style to '#010+ '**3SIcom_COM compatible interface (default)'#010+ '**3SIcorba_CORBA compatible interface'#010+ - '**2Sm_Support macros like C (global)'#010+ - '**2So_Same as ','-Mtp'#010+ + '**2Sm_','Support macros like C (global)'#010+ + '**2So_Same as -Mtp'#010+ '**2Ss_Constructor name must be init (destructor must be done)'#010+ '**2Sx_Enable exception keywords (default in Delphi/ObjFPC modes)'#010+ '**2Sy_@ returns a typed pointer, same as $T+'#010+ - '**1s_Do not call assembler and linker'#010+ - '**2sh_Generate s','cript to link on host'#010+ + '**1s_Do n','ot call assembler and linker'#010+ + '**2sh_Generate script to link on host'#010+ '**2st_Generate script to link on target'#010+ '**2sr_Skip register allocation phase (use with -alr)'#010+ '**1T_Target operating system:'#010+ '3*2Tdarwin_Darwin/Mac OS X'#010+ - '3*2Temx_OS/2 via EMX (including EMX/RSX extender)'#010+ - '3*2Tfreebsd_Fre','eBSD'#010+ + '3*2Temx_OS/2 via EMX',' (including EMX/RSX extender)'#010+ + '3*2Tfreebsd_FreeBSD'#010+ '3*2Tgo32v2_Version 2 of DJ Delorie DOS extender'#010+ '3*2Tiphonesim_ iPhoneSimulator from iOS SDK 3.2+ (older versions: -Tda'+ 'rwin)'#010+ '3*2Tlinux_Linux'#010+ '3*2Tnetbsd_NetBSD'#010+ - '3*2Tnetware_Novell Netware Module (clib)'#010+ - '3*2Tnetwlibc_Novell Netware Module (','libc)'#010+ + '3*2Tnetware_Novell Netware Modul','e (clib)'#010+ + '3*2Tnetwlibc_Novell Netware Module (libc)'#010+ '3*2Topenbsd_OpenBSD'#010+ '3*2Tos2_OS/2 / eComStation'#010+ '3*2Tsunos_SunOS/Solaris'#010+ @@ -1347,19 +1348,19 @@ const msgtxt : array[0..000265,1..240] of char=( '3*2Tsolaris_Solaris'#010+ '3*2Twatcom_Watcom compatible DOS extender'#010+ '3*2Twdosx_WDOSX DOS extender'#010+ - '3*2Twin32_Windows 32 Bit'#010+ + '3*2T','win32_Windows 32 Bit'#010+ '3*2Twince_Windows CE'#010+ - '4*2','Tdarwin_Darwin/Mac OS X'#010+ + '4*2Tdarwin_Darwin/Mac OS X'#010+ '4*2Tlinux_Linux'#010+ '4*2Twin64_Win64 (64 bit Windows systems)'#010+ '6*2Tamiga_Commodore Amiga'#010+ '6*2Tatari_Atari ST/STe/TT'#010+ '6*2Tlinux_Linux'#010+ '6*2Tpalmos_PalmOS'#010+ - 'A*2Tdarwin_Darwin/iPhoneOS/iOS'#010+ + 'A*2Tdarwin_Darwin/iPhoneOS/i','OS'#010+ 'A*2Tlinux_Linux'#010+ 'A*2Twince_Windows CE'#010+ - 'P*2Ta','miga_AmigaOS'#010+ + 'P*2Tamiga_AmigaOS'#010+ 'P*2Tdarwin_Darwin/Mac OS X'#010+ 'P*2Tlinux_Linux'#010+ 'P*2Tmacos_Mac OS (classic)'#010+ @@ -1368,112 +1369,112 @@ const msgtxt : array[0..000265,1..240] of char=( 'S*2Tlinux_Linux'#010+ '**1u_Undefines the symbol '#010+ '**1U_Unit options:'#010+ - '**2Un_Do not check where the unit name matches th','e file name'#010+ + '**2U','n_Do not check where the unit name matches the file name'#010+ '**2Ur_Generate release unit files (never automatically recompiled)'#010+ '**2Us_Compile a system unit'#010+ '**1v_Be verbose. is a combination of the following letters:'#010+ - '**2*_e : Show errors (default) 0 : Show nothing (except erro','rs'+ + '**2*_e : Show errors ','(default) 0 : Show nothing (except errors'+ ')'#010+ '**2*_w : Show warnings u : Show unit info'#010+ '**2*_n : Show notes t : Show tried/used files'#010+ '**2*_h : Show hints c : Show conditionals'#010+ - '**2*_i : Show general info d : Show debug info'#010+ - '*','*2*_l : Show linenumbers r : Rhide/GCC compatibility mod'+ - 'e'#010+ + '**2*_i : Show',' general info d : Show debug info'#010+ + '**2*_l : Show linenumbers r : Rhide/GCC compatibility mode'#010+ '**2*_s : Show time stamps q : Show message numbers'#010+ - '**2*_a : Show everything x : Executable info (Win32 only)'#010+ - '**2*_b : Write file names messages p ',': Write tree.log with parse t'+ - 'ree'#010+ + '**2*_a : Show everything x : Executable info (Win32 ','only'+ + ')'#010+ + '**2*_b : Write file names messages p : Write tree.log with parse tre'+ + 'e'#010+ '**2*_ with full path v : Write fpcdebug.txt with'#010+ '**2*_ lots of debugging info'#010+ - '**2*_m, : Don'#039't show messages numbered and '#010+ - 'F*1V_Append '#039'-'#039,' to the used compiler binary name (e.g. '+ - 'for version)'#010+ + '**2*_m, : Don'#039't show messag','es numbered and '#010+ + 'F*1V_Append '#039'-'#039' to the used compiler binary name (e.g. f'+ + 'or version)'#010+ '**1W_Target-specific options (targets)'#010+ '3*2WA_Specify native type application (Windows)'#010+ '4*2WA_Specify native type application (Windows)'#010+ - 'A*2WA_Specify native type application (Windows)'#010+ - '3','*2Wb_Create a bundle instead of a library (Darwin)'#010+ + 'A*2W','A_Specify native type application (Windows)'#010+ + '3*2Wb_Create a bundle instead of a library (Darwin)'#010+ 'P*2Wb_Create a bundle instead of a library (Darwin)'#010+ 'p*2Wb_Create a bundle instead of a library (Darwin)'#010+ - 'A*2Wb_Create a bundle instead of a library (Darwin)'#010+ - '4*2Wb_Create a bundle instead of ','a library (Darwin)'#010+ + 'A*2Wb_Create a bundle instead of a libra','ry (Darwin)'#010+ + '4*2Wb_Create a bundle instead of a library (Darwin)'#010+ '3*2WB_Create a relocatable image (Windows, Symbian)'#010+ '3*2WBxxxx_Set image base to xxxx (Windows, Symbian)'#010+ '4*2WB_Create a relocatable image (Windows)'#010+ - '4*2WBxxxx_Set image base to xxxx (Windows)'#010+ - 'A*2WB_Create a relocatable imag','e (Windows, Symbian)'#010+ + '4*2WBxxxx_Set image base to x','xxx (Windows)'#010+ + 'A*2WB_Create a relocatable image (Windows, Symbian)'#010+ 'A*2WBxxxx_Set image base to xxxx (Windows, Symbian)'#010+ '3*2WC_Specify console type application (EMX, OS/2, Windows)'#010+ '4*2WC_Specify console type application (EMX, OS/2, Windows)'#010+ - 'A*2WC_Specify console type application (Windows',')'#010+ + 'A*','2WC_Specify console type application (Windows)'#010+ 'P*2WC_Specify console type application (Classic Mac OS)'#010+ '3*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+ '4*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+ - 'A*2WD_Use DEFFILE to export functions of DLL or EXE (Windo','ws)'#010+ + 'A*2WD_Use DEF','FILE to export functions of DLL or EXE (Windows)'#010+ '3*2We_Use external resources (Darwin)'#010+ '4*2We_Use external resources (Darwin)'#010+ 'A*2We_Use external resources (Darwin)'#010+ 'P*2We_Use external resources (Darwin)'#010+ 'p*2We_Use external resources (Darwin)'#010+ - '3*2WF_Specify full-screen type application (EM','X, OS/2)'#010+ + '3','*2WF_Specify full-screen type application (EMX, OS/2)'#010+ '3*2WG_Specify graphic type application (EMX, OS/2, Windows)'#010+ '4*2WG_Specify graphic type application (EMX, OS/2, Windows)'#010+ 'A*2WG_Specify graphic type application (Windows)'#010+ - 'P*2WG_Specify graphic type application (Classic Mac OS)'#010+ - '3*2Wi_','Use internal resources (Darwin)'#010+ + 'P*2WG_Specify gra','phic type application (Classic Mac OS)'#010+ + '3*2Wi_Use internal resources (Darwin)'#010+ '4*2Wi_Use internal resources (Darwin)'#010+ 'A*2Wi_Use internal resources (Darwin)'#010+ 'P*2Wi_Use internal resources (Darwin)'#010+ 'p*2Wi_Use internal resources (Darwin)'#010+ - '3*2WI_Turn on/off the usage of import sections (Windows)',#010+ + '3*2WI_Turn ','on/off the usage of import sections (Windows)'#010+ '4*2WI_Turn on/off the usage of import sections (Windows)'#010+ 'A*2WI_Turn on/off the usage of import sections (Windows)'#010+ '3*2WM_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Darwi'+ 'n)'#010+ - '4*2WM_Minimum Mac OS X deployment version: 10.4, ','10.5.1, ... (Dar'+ + '4*2WM_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Dar'+ 'win)'#010+ 'p*2WM_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Darwi'+ 'n)'#010+ 'P*2WM_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Darwi'+ 'n)'#010+ - '3*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+ - '4*2','WN_Do not generate relocation code, needed for debugging (Windows'+ + '3*2WN_Do not generate reloca','tion code, needed for debugging (Windows'+ ')'#010+ + '4*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+ 'A*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+ - 'A*2Wpxxxx_Specify the controller type, see fpc -i for possible values'#010+ - 'V*2Wpxxxx_Specify the controller ','type, see fpc -i for possible value'+ + 'A*2Wpxxxx_Specify the controller type, see fpc -i for poss','ible value'+ 's'#010+ + 'V*2Wpxxxx_Specify the controller type, see fpc -i for possible values'#010+ '3*2WP_Minimum iOS deployment version: 3.0, 5.0.1, ... (iphonesim)'#010+ 'A*2WP_Minimum iOS deployment version: 3.0, 5.0.1, ... (Darwin)'#010+ - '3*2WR_Generate relocation code (Windows)'#010+ - '4*2WR_Generate relocation c','ode (Windows)'#010+ + '3*2WR_Generate relocati','on code (Windows)'#010+ + '4*2WR_Generate relocation code (Windows)'#010+ 'A*2WR_Generate relocation code (Windows)'#010+ 'P*2WT_Specify MPW tool type application (Classic Mac OS)'#010+ '**2WX_Enable executable stack (Linux)'#010+ '**1X_Executable options:'#010+ - '**2Xc_Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD',', L'+ + '**2Xc_Pass --shared/','-dynamic to the linker (BeOS, Darwin, FreeBSD, L'+ 'inux)'#010+ '**2Xd_Do not use standard library search path (needed for cross compil'+ 'e)'#010+ '**2Xe_Use external linker'#010+ '**2Xg_Create debuginfo in a separate file and add a debuglink section '+ 'to executable'#010+ - '**2XD_Try to link units dynamically (define','s FPC_LINK_DYNAMIC)'#010+ + '**2','XD_Try to link units dynamically (defines FPC_LINK_DYNAMIC)'#010+ '**2Xi_Use internal linker'#010+ '**2Xm_Generate link map'#010+ '**2XM_Set the name of the '#039'main'#039' program routine (default i'+ 's '#039'main'#039')'#010+ - 'F*2Xp_First search for the compiler binary in the directory '#010+ - '**2XP_Prepend the binutils n','ames with the prefix '#010+ + 'F*2Xp_First search for the compiler binary in the ','directory '#010+ + '**2XP_Prepend the binutils names with the prefix '#010+ '**2Xr_Set the linker'#039's rlink-path to (needed for cross comp'+ 'ile, see the ld manual for more information) (BeOS, Linux)'#010+ - '**2XR_Prepend to all linker search paths (BeOS, Darwin, FreeBSD'+ - ', Linux, Mac OS, Sol','aris)'#010+ + '**2XR_Prepend to all linker search pat','hs (BeOS, Darwin, FreeB'+ + 'SD, Linux, Mac OS, Solaris)'#010+ '**2Xs_Strip all symbols from executable'#010+ '**2XS_Try to link units statically (default, defines FPC_LINK_STATIC)'#010+ '**2Xt_Link with static libraries (-static is passed to linker)'#010+ - '**2XX_Try to smartlink units (defines FPC_LINK_SM','ART)'#010+ + '**2XX_Try to sma','rtlink units (defines FPC_LINK_SMART)'#010+ '**1*_'#010+ '**1?_Show this help'#010+ '**1h_Shows this help without waiting' diff --git a/compiler/options.pas b/compiler/options.pas index b0411888e6..87a7d903f1 100644 --- a/compiler/options.pas +++ b/compiler/options.pas @@ -853,6 +853,11 @@ begin exclude(init_settings.globalswitches,cs_link_nolink) Else include(init_settings.globalswitches,cs_link_nolink); + 'N' : + If UnsetBool(More, j) then + exclude(init_settings.localswitches,cs_check_low_addr_load) + Else + include(init_settings.localswitches,cs_check_low_addr_load); 'o' : If UnsetBool(More, j) then exclude(init_settings.localswitches,cs_check_overflow) diff --git a/compiler/powerpc/cgcpu.pas b/compiler/powerpc/cgcpu.pas index ccff16f6af..3ea32a42c6 100644 --- a/compiler/powerpc/cgcpu.pas +++ b/compiler/powerpc/cgcpu.pas @@ -284,6 +284,8 @@ const ref2: treference; begin + if target_info.system=system_powerpc_aix then + g_load_check_simple(list,ref,65536); { TODO: optimize/take into consideration fromsize/tosize. Will } { probably only matter for OS_S8 loads though } if not(fromsize in [OS_8,OS_S8,OS_16,OS_S16,OS_32,OS_S32]) then diff --git a/compiler/ppcgen/cgppc.pas b/compiler/ppcgen/cgppc.pas index 7ffa741f8e..338d45c5da 100644 --- a/compiler/ppcgen/cgppc.pas +++ b/compiler/ppcgen/cgppc.pas @@ -68,6 +68,7 @@ unit cgppc; procedure g_stackpointer_alloc(list : TAsmList;localsize : longint);override; function get_aix_toc_sym(const symname: string; const flags: tindsymflags):tasmsymbol; + procedure g_load_check_simple(list: TAsmList; const ref: treference; size: aint); procedure g_external_wrapper(list: TAsmList; pd: TProcDef; const externalname: string); override; protected function get_darwin_call_stub(const s: string; weak: boolean): tasmsymbol; @@ -527,6 +528,8 @@ unit cgppc; ref2: treference; begin + if target_info.system in systems_aix then + g_load_check_simple(list,ref,65536); if not(fromsize in [OS_F32,OS_F64]) or not(tosize in [OS_F32,OS_F64]) then internalerror(200201121); @@ -846,6 +849,47 @@ unit cgppc; end; + procedure tcgppcgen.g_load_check_simple(list: TAsmList; const ref: treference; size: aint); + var + reg: tregister; + lab: tasmlabel; + begin + if not(cs_check_low_addr_load in current_settings.localswitches) then + exit; + { this is mainly for AIX, which does not trap loads from address 0. A + global symbol (if not weak) will always map to a proper address, and + the same goes for stack addresses -> skip } + if assigned(ref.symbol) and + (ref.symbol.bind<>AB_WEAK_EXTERNAL) then + exit; + if (ref.base=NR_STACK_POINTER_REG) or + (ref.index=NR_STACK_POINTER_REG) or + (assigned(current_procinfo) and + ((ref.base=current_procinfo.framepointer) or + (ref.index=current_procinfo.framepointer))) then + exit; + if assigned(ref.symbol) or + (ref.offset<>0) or + ((ref.base<>NR_NO) and (ref.index<>NR_NO)) then + begin + { can't allocate register, also used in wrappers and the like } + reg:=NR_R0; + a_reg_alloc(list,reg); + a_loadaddr_ref_reg(list,ref,reg); + end + else if ref.base<>NR_NO then + reg:=ref.base + else + reg:=ref.index; + current_asmdata.getjumplabel(lab); + if reg=NR_R0 then + a_reg_dealloc(list,reg); + a_cmp_const_reg_label(list,OS_ADDR,OC_A,size-1,reg,lab); + a_call_name(list,'FPC_INVALIDPOINTER',false); + a_label(list,lab); + end; + + procedure tcgppcgen.g_external_wrapper(list: TAsmList; pd: TProcDef; const externalname: string); var href : treference; diff --git a/compiler/scandir.pas b/compiler/scandir.pas index 980e786f14..bd8534177c 100644 --- a/compiler/scandir.pas +++ b/compiler/scandir.pas @@ -286,6 +286,12 @@ unit scandir; end; + procedure dir_checklowaddrloads; + begin + do_localswitchdefault(cs_check_low_addr_load); + end; + + procedure dir_checkpointer; begin do_localswitchdefault(cs_checkpointer); @@ -1438,6 +1444,7 @@ unit scandir; AddDirective('BOOLEVAL',directive_all, @dir_booleval); AddDirective('BITPACKING',directive_all, @dir_bitpacking); AddDirective('CALLING',directive_all, @dir_calling); + AddDirective('CHECKLOWADDRLOADS',directive_all, @dir_checklowaddrloads); AddDirective('CHECKPOINTER',directive_all, @dir_checkpointer); AddDirective('CODEALIGN',directive_all, @dir_codealign); AddDirective('CODEPAGE',directive_all, @dir_codepage); diff --git a/rtl/inc/system.inc b/rtl/inc/system.inc index 2c886c2ff1..66e5be7fee 100644 --- a/rtl/inc/system.inc +++ b/rtl/inc/system.inc @@ -683,6 +683,12 @@ begin end; +procedure fpc_invalidpointer; [public,alias:'FPC_INVALIDPOINTER']; +begin + HandleErrorFrame(216,get_frame); +end; + + procedure fpc_iocheck;[public,alias:'FPC_IOCHECK']; compilerproc; var l : longint;