فهرست منبع

+ -Xa option: generate code which allows to use more than 2 GB of static data on 64 Bit targets
+ implemented support for x86-64
* more than 2 GB static data requires to use the --no-relax option on linux

git-svn-id: trunk@47651 -

florian 4 سال پیش
والد
کامیت
792b629aa6

+ 4 - 1
compiler/globtype.pas

@@ -230,7 +230,10 @@ interface
          cs_link_vlink,
          { disable LTO for the system unit (needed to work around linker bugs on macOS) }
          cs_lto_nosystem,
-	 cs_assemble_on_target
+         cs_assemble_on_target,
+         { use a memory model which allows large data structures, e.g. > 2 GB static data on x86-64 targets
+           this not supported on all OSes }
+         cs_large
        );
        tglobalswitches = set of tglobalswitch;
 

+ 1 - 0
compiler/msg/errore.msg

@@ -4325,6 +4325,7 @@ P*2WT_Specify MPW tool type application (Classic Mac OS)
 **2WX_Enable executable stack (Linux)
 **1X_Executable options:
 **2X9_Generate linkerscript for GNU Binutils ld older than version 2.19.1 (Linux)
+**2Xa_Generate code which allows to use more than 2 GB static data on 64 Bit targets (Linux)
 **2Xc_Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Linux)
 **2Xd_Do not search default library path (sometimes required for cross-compiling when not using -XR)
 **2Xe_Use external linker

+ 1 - 1
compiler/msgidx.inc

@@ -1135,7 +1135,7 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 86754;
+  MsgTxtSize = 86847;
 
   MsgIdxMax : array[1..20] of longint=(
     28,107,360,130,99,63,145,36,223,68,

+ 20 - 19
compiler/msgtxt.inc

@@ -1967,39 +1967,40 @@ const msgtxt : array[0..000361,1..240] of char=(
   '**1X_Executable options:'#010+
   '**2X9_Generate linkerscript for GNU Binutils ld older than version 2.1'+
   '9.1 (Linux)'#010+
-  '**2Xc_Pass --share','d/-dynamic to the linker (BeOS, Darwin, FreeBSD, L'+
-  'inux)'#010+
+  '**2Xa_Generate cod','e which allows to use more than 2 GB static data o'+
+  'n 64 Bit targets (Linux)'#010+
+  '**2Xc_Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Lin'+
+  'ux)'#010+
   '**2Xd_Do not search default library path (sometimes required for cross'+
-  '-compiling when not using -XR)'#010+
+  '-compiling when not u','sing -XR)'#010+
   '**2Xe_Use external linker'#010+
   '**2Xf_Substitute pthread library name for linking (BSD)'#010+
-  '*','*2Xg_Create debuginfo in a separate file and add a debuglink sectio'+
-  'n to executable'#010+
-  '**2XD_Try to link units dynamically      (defines FPC_LINK_DYNAMIC)'#010+
+  '**2Xg_Create debuginfo in a separate file and add a debuglink section '+
+  'to executable'#010+
+  '**2XD_Try to link units dynamically      (defines FPC_LINK_DYNAM','IC)'#010+
   '**2Xi_Use internal linker'#010+
-  'L*2XlS<x>_LLVM utilties suffix (e.g. -7 in case clang is called',' clan'+
-  'g-7)'#010+
+  'L*2XlS<x>_LLVM utilties suffix (e.g. -7 in case clang is called clang-'+
+  '7)'#010+
   '**2XLA_Define library substitutions for linking'#010+
   '**2XLO_Define order of library linking'#010+
-  '**2XLD_Exclude default order of standard libraries'#010+
+  '**2XLD_Exclude default order of standard libraries',#010+
   '**2Xm_Generate link map'#010+
   '**2XM<x>_Set the name of the '#039'main'#039' program routine (default i'+
-  's '#039'mai','n'#039')'#010+
+  's '#039'main'#039')'#010+
   '**2Xn_Use target system native linker instead of GNU ld (Solaris, AIX)'+
   #010+
   'F*2Xp<x>_First search for the compiler binary in the directory <x>'#010+
-  '**2XP<x>_Prepend the binutils names with the prefix <x>'#010+
-  '**2Xr<x>_Set the linker'#039's rlink-path to <x','> (needed for cross co'+
-  'mpile, see the ld manual for more information) (BeOS, Linux)'#010+
-  '**2XR<x>_Prepend <x> to all linker search paths (BeOS, Darwin, FreeBSD'+
-  ', Linux, Mac OS, Solaris)'#010+
+  '**2XP','<x>_Prepend the binutils names with the prefix <x>'#010+
+  '**2Xr<x>_Set the linker'#039's rlink-path to <x> (needed for cross comp'+
+  'ile, see the ld manual for more information) (BeOS, Linux)'#010+
+  '**2XR<x>_Prepend <x> to all linker search paths (BeOS, Darwin, F','reeB'+
+  'SD, Linux, Mac OS, Solaris)'#010+
   '**2Xs_Strip all symbols from executable'#010+
-  '**2XS_Try to link uni','ts statically (default, defines FPC_LINK_STATIC'+
-  ')'#010+
+  '**2XS_Try to link units statically (default, defines FPC_LINK_STATIC)'#010+
   '**2Xt_Link with static libraries (-static is passed to linker)'#010+
-  '**2Xv_Generate table for Virtual Entry calls'#010+
+  '**2Xv_Generate table for Virtual En','try calls'#010+
   '**2XV_Use VLink as external linker       (default on Amiga, MorphOS)'#010+
-  '**2XX_Try to s','martlink units             (defines FPC_LINK_SMART)'#010+
+  '**2XX_Try to smartlink units             (defines FPC_LINK_SMART)'#010+
   '**1*_'#010+
   '**1?_Show this help'#010+
   '**1h_Shows this help without waiting'

+ 7 - 0
compiler/options.pas

@@ -2695,6 +2695,13 @@ begin
                         else
                           IllegalPara(opt);
                       end;
+                    'a' :
+                      begin
+                        If UnsetBool(More, j, opt, false) then
+                          exclude(init_settings.globalswitches,cs_large)
+                        else
+                          include(init_settings.globalswitches,cs_large);
+                      end;
                     'c' : Cshared:=TRUE;
                     'd' : Dontlinkstdlibpath:=TRUE;
                     'e' :

+ 3 - 0
compiler/systems/t_linux.pas

@@ -788,6 +788,9 @@ begin
   if tf_use_psabieh in target_info.flags then
     cmdstr:=cmdstr+ ' --eh-frame-hdr';
 
+  if cs_large in current_settings.globalswitches then
+    cmdstr:=cmdstr+' --no-relax';
+
   success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false);
 
   { Create external .dbg file with debuginfo }

+ 2 - 1
compiler/utils/ppuutils/ppudump.pp

@@ -2300,7 +2300,8 @@ const
         'Link for GNU linker version <=2.19', {cs_link_pre_binutils_2_19}
         'Link using vlink', {cs_link_vlink}
         'Link-Time Optimization disabled for system unit', {cs_lto_nosystem}
-        'Assemble on target OS' {cs_asemble_on_target}
+        'Assemble on target OS', {cs_asemble_on_target}
+        'Use a memory model to support >2GB static data on 64 Bit target' {cs_large}
        );
     localswitchname : array[tlocalswitch] of string[50] =
        { Switches which can be changed locally }

+ 8 - 1
compiler/x86/cgx86.pas

@@ -468,12 +468,19 @@ unit cgx86;
           members aren't known until link time, ABIs place very pessimistic limits
           on offset values, e.g. SysV AMD64 allows +/-$1000000 (16 megabytes) }
         if ((ref.offset<low(longint)) or (ref.offset>high(longint))) or
+           ((cs_large in current_settings.globalswitches) and assigned(ref.symbol)) or
            { absolute address is not a common thing in x64, but nevertheless a possible one }
            ((ref.base=NR_NO) and (ref.index=NR_NO) and (ref.symbol=nil)) then
           begin
             { Load constant value to register }
             hreg:=GetAddressRegister(list);
-            list.concat(taicpu.op_const_reg(A_MOV,S_Q,ref.offset,hreg));
+            if (cs_large in current_settings.globalswitches) and assigned(ref.symbol) then
+              begin
+                list.concat(taicpu.op_sym_ofs_reg(A_MOVABS,S_Q,ref.symbol,ref.offset+10,hreg));
+                ref.symbol:=nil;
+              end
+            else
+              list.concat(taicpu.op_const_reg(A_MOV,S_Q,ref.offset,hreg));
             ref.offset:=0;
             {if assigned(ref.symbol) then
               begin

+ 2 - 0
tests/tbs/tb0528.pp

@@ -1,5 +1,7 @@
 {%CPU=x86_64,powerpc64}
 {%skiptarget=darwin,aix,win64}
+{ %opt=-Xa }  { use the large option }
+
 
 { darwin limits statically declared data structures to 32 bit for efficiency reasons }
 { the aix assembler cannot deal with the way we declare these arrays in assembler code }

+ 1 - 0
tests/webtbs/tw17236.pp

@@ -1,5 +1,6 @@
 { %target=linux,darwin,freebsd,netbsd,openbsd,sunos,beos,haiku }
 { %cpu=x86_64,powerpc64,mips64,sparc64,ia64,alpha }
+{ %opt=-Xa }
 
 { windows does not support statics > 2GB }
 var