Browse Source

+ Add support for x86_64 CPU in the UEFI target

git-svn-id: branches/olivier/uefi@36331 -
olivier 8 years ago
parent
commit
8d2e7fac79

+ 1 - 0
compiler/msg/errore.msg

@@ -3956,6 +3956,7 @@ S*2Tsolaris_Solaris
 S*2Tlinux_Linux
 V*2Tembedded_Embedded
 3*2Tuefi_UEFI
+4*2Tuefi_UEFI (64 bits)
 **1u<x>_Undefines the symbol <x>
 **1U_Unit options:
 **2Un_Do not check where the unit name matches the file name

+ 1 - 1
compiler/msgidx.inc

@@ -1068,7 +1068,7 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 79327;
+  MsgTxtSize = 79351;
 
   MsgIdxMax : array[1..20] of longint=(
     27,102,347,124,96,58,132,33,209,67,

+ 44 - 43
compiler/msgtxt.inc

@@ -1692,142 +1692,143 @@ const msgtxt : array[0..000330,1..240] of char=(
   'S*2Tlinux_Linux'#010+
   'V*2Tembedded_Embedded'#010+
   '3*2Tuefi_UEFI'#010+
-  '**1u<x>_Undefines the symbol <','x>'#010+
+  '4*2Tuefi_UEFI (64 bits)'#010+
+  '**1u<x','>_Undefines the symbol <x>'#010+
   '**1U_Unit options:'#010+
   '**2Un_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<x>_Be verbose. <x> is a combination of the following lett','ers:'#010+
+  '**1v<x>_Be verbose. <x> is a combinati','on of the following letters:'#010+
   '**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*_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 mode'#010+
   '**2*_s : Show time stamps            q : Show message numbers'#010+
-  '**2*_a : Show everything             x',' : Show info about invoked too'+
+  '**2*_a : Show ','everything             x : Show info about invoked too'+
   'ls'#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*_z : Write output to stderr          lots of debugging info'#010+
-  '**2*_m','<x>,<y> : Do not show messages numbered <x> and <y>'#010+
+  '**2*_z : Write output to stderr          lots ','of debugging info'#010+
+  '**2*_m<x>,<y> : Do not show messages numbered <x> and <y>'#010+
   'F*1V<x>_Append '#039'-<x>'#039' to the used compiler binary name (e.g. f'+
   'or version)'#010+
   '**1W<x>_Target-specific options (targets)'#010+
-  '3*2WA_Specify native type application (Windows)'#010+
-  '4*2WA_Specify native typ','e application (Windows)'#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+
   '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+
+  'p*2Wb_Create a bundle instead of a libra','ry (Darwin)'#010+
+  'a*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+
   '3*2WB_Create a relocatable image (Windows, Symbian)'#010+
-  '3*2WB<x>_Set image base to <x> (Windows, Sym','bian)'#010+
+  '3*2WB<x>_Set image b','ase to <x> (Windows, Symbian)'#010+
   '4*2WB_Create a relocatable image (Windows)'#010+
   '4*2WB<x>_Set image base to <x> (Windows)'#010+
   'A*2WB_Create a relocatable image (Windows, Symbian)'#010+
   'A*2WB<x>_Set image base to <x> (Windows, Symbian)'#010+
-  '3*2WC_Specify console type application (EMX, OS/','2, Windows)'#010+
+  '3*2WC_Specify console ty','pe application (EMX, OS/2, Windows)'#010+
   '4*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 DE','FFILE to export functions of DLL or EXE (Windows)'#010+
+  '3*2WD_Use DEFFILE to export functions of DLL or EX','E (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 (Windows)'#010+
   '3*2We_Use external resources (Darwin)'#010+
   '4*2We_Use external resources (Darwin)'#010+
-  'a*2We_Use external resources (Darwin)'#010+
-  'A*2We_Use exte','rnal resources (Darwin)'#010+
+  'a*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 (EMX, OS/2)'#010+
   '3*2WG_Specify graphic type application (EMX, OS/2, Windows)'#010+
-  '4*2WG_Specify graphic typ','e application (Windows)'#010+
+  '4','*2WG_Specify graphic type application (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+
   '4*2Wi_Use internal resources (Darwin)'#010+
-  'a*2Wi_Use internal resources (Darwi','n)'#010+
+  'a*2Wi_Use i','nternal 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+
-  '4*2WI_Turn on/off the usage of import sections (Windows)'#010+
-  'A*2WI_Tur','n on/off the usage of import sections (Windows)'#010+
+  '4*2WI_Turn on/off the usage of import sect','ions (Windows)'#010+
+  'A*2WI_Turn on/off the usage of import sections (Windows)'#010+
   '8*2Wm<x>_Set memory model'#010+
   '8*3WmTiny_Tiny memory model'#010+
   '8*3WmSmall_Small memory model (default)'#010+
   '8*3WmMedium_Medium memory model'#010+
   '8*3WmCompact_Compact memory model'#010+
-  '8*3WmLarge_Large memory model'#010+
-  '8*','3WmHuge_Huge memory model'#010+
+  '8*3WmLar','ge_Large memory model'#010+
+  '8*3WmHuge_Huge memory model'#010+
   '3*2WM<x>_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Darwi'+
   'n)'#010+
   '4*2WM<x>_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Darwi'+
   'n)'#010+
-  'p*2WM<x>_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Dar','w'+
-  'in)'#010+
+  'p*2WM<x>_Minimum Mac OS X deployment version',': 10.4, 10.5.1, ... (Dar'+
+  'win)'#010+
   'P*2WM<x>_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*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
-  'A*2WN_Do not generate ','relocation 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*2Wp<x>_Specify the controller type; see fpc -i or fpc -iu for possib'+
   'le values'#010+
   'm*2Wp<x>_Specify the controller type; see fpc -i or fpc -iu for possib'+
   'le values'#010+
-  'V*2Wp<x>_Specify the controller ','type; see fpc -i or fpc -iu for poss'+
+  'V*2Wp<x>','_Specify the controller type; see fpc -i or fpc -iu for poss'+
   'ible values'#010+
   '3*2WP<x>_Minimum iOS deployment version: 3.0, 5.0.1, ... (iphonesim)'#010+
   '4*2WP<x>_Minimum iOS deployment version: 8.0, 8.0.2, ... (iphonesim)'#010+
-  'a*2WP<x>_Minimum iOS deployment version: 7.0, 7.1.2, .','.. (Darwin)'#010+
+  'a*2WP<x>_Minimum iOS deploymen','t version: 7.0, 7.1.2, ... (Darwin)'#010+
   'A*2WP<x>_Minimum iOS deployment version: 3.0, 5.0.1, ... (Darwin)'#010+
   '3*2WR_Generate relocation code (Windows)'#010+
   '4*2WR_Generate relocation code (Windows)'#010+
   'A*2WR_Generate relocation code (Windows)'#010+
-  '8*2Wt<x>_Set the target executable form','at'#010+
+  '8*2Wt<x>_Set th','e target executable format'#010+
   '8*3Wtexe_Create a DOS .EXE file (default)'#010+
   '8*3Wtcom_Create a DOS .COM file (requires tiny memory model)'#010+
   'P*2WT_Specify MPW tool type application (Classic Mac OS)'#010+
   '**2WX_Enable executable stack (Linux)'#010+
-  '**1X_Executable options:'#010+
-  '**2X9_Generate',' linkerscript for GNU Binutils ld older than version 2'+
-  '.19.1 (Linux)'#010+
+  '**1X_Executable',' options:'#010+
+  '**2X9_Generate linkerscript for GNU Binutils ld older than version 2.1'+
+  '9.1 (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 -X','R)'#010+
+  '-com','piling when not using -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 section '+
   'to executable'#010+
-  '**2XD_Try to link units dynamically      (defines FPC_LINK_DYNAMIC)'#010+
-  '**2','Xi_Use internal linker'#010+
+  '**2XD_Try to link units dynamically      (defin','es FPC_LINK_DYNAMIC)'#010+
+  '**2Xi_Use internal linker'#010+
   '**2XLA_Define library substitutions for linking'#010+
   '**2XLO_Define order of library linking'#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 (de','fault'+
+  '**2XM<x>_Set the name of the '#039'm','ain'#039' program routine (default'+
   ' is '#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 rli','nk-path to <x> (needed for cross co'+
+  '**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+
-  '**2Xs_Strip all symbols from executable'#010+
-  '**2XS_Tr','y to link units statically (default, defines FPC_LINK_STATIC'+
-  ')'#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+
   '**2Xv_Generate table for Virtual Entry calls'#010+
-  '**2XV_Use VLink as external linker       (default on Amiga, MorphOS)'#010+
-  '*','*2XX_Try to smartlink units             (defines FPC_LINK_SMART)'#010+
+  '**2XV_Use VLink as external linker       (defa','ult on Amiga, MorphOS)'+
+  #010+
+  '**2XX_Try to smartlink units             (defines FPC_LINK_SMART)'#010+
   '**1*_'#010+
   '**1?_Show this help'#010+
   '**1h_Shows this help without waiting'

+ 2 - 2
compiler/ogcoff.pas

@@ -2581,7 +2581,7 @@ const pemagic : array[0..3] of byte = (
             else
               if target_info.system in systems_wince then
                 peoptheader.Subsystem:=PE_SUBSYSTEM_WINDOWS_CE_GUI
-              else if target_info.system in [system_i386_uefi] then
+              else if target_info.system in [system_i386_uefi,system_x86_64_uefi] then
                 begin
                   case apptype of
                     app_efi_app :
@@ -3272,7 +3272,7 @@ const pemagic : array[0..3] of byte = (
             idtxt  : 'PECOFF';
             asmbin : '';
             asmcmd : '';
-            supported_targets : [system_x86_64_win64];
+            supported_targets : [system_x86_64_win64,system_x86_64_uefi];
             flags : [af_outputbinary,af_smartlink_sections];
             labelprefix : '.L';
             comment : '';

+ 1 - 2
compiler/options.pas

@@ -769,7 +769,6 @@ begin
   StopOptions(0);
 end;
 
-
 procedure Toption.IllegalPara(const opt:TCmdStr);
 begin
   Message1(option_illegal_para,opt);
@@ -2174,7 +2173,7 @@ begin
                             else
                               SetApptype(app_native);
                           end
-                        else if target_info.system in [system_i386_uefi] then
+                        else if target_info.system in [system_i386_uefi,system_x86_64_uefi] then
                           begin
                             SetApptype(app_efi_app);
                           end                          

+ 2 - 2
compiler/pmodules.pas

@@ -1867,7 +1867,7 @@ type
       begin
          // Under UEFI, an application is technically a dll.
          // So, we build both programs and libraries as libraries
-         if target_info.system in [system_i386_uefi] then
+         if target_info.system in [system_i386_uefi,system_x86_64_uefi] then
            IsLibrary := true;
          Status.IsLibrary:=IsLibrary;
          Status.IsPackage:=false;
@@ -1915,7 +1915,7 @@ type
 
          if islibrary then
            begin
-              if target_info.system in [system_i386_uefi] then
+              if target_info.system in [system_i386_uefi,system_x86_64_uefi] then
                 begin
                   // For UEFI targets, every binaries are libraries.
                   // So, we treat 'program' as 'library' as well.

+ 2 - 1
compiler/systems.inc

@@ -176,7 +176,8 @@
              system_i8086_embedded,     { 90 }
              system_arm_aros,           { 91 }
              system_wasm_wasm32,        { 92 }
-             system_i386_uefi           { 93 }
+             system_i386_uefi,          { 93 }
+             system_x86_64_uefi         { 94 }
        );
 
      type

+ 8 - 0
compiler/systems.pas

@@ -818,6 +818,10 @@ begin
     {$define default_target_set}
     default_target(system_i386_solaris);
    {$endif}
+   {$ifdef uefi}
+    default_target(system_i386_uefi);
+    {$define default_target_set}
+   {$endif}   
   {$endif cpui386}
   { default is linux }
   {$ifndef default_target_set}
@@ -862,6 +866,10 @@ begin
     default_target(system_x86_64_darwin);
     {$define default_target_set}
    {$endif}
+   {$ifdef uefi}
+    default_target(system_x86_64_uefi);
+    {$define default_target_set}
+   {$endif}
   {$endif cpux86_64}
   { default is linux }
   {$ifndef default_target_set}

+ 13 - 18
compiler/systems/i_uefi.pas

@@ -99,18 +99,18 @@ unit i_uefi;
             llvmdatalayout : 'e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S32';
           );
 
-(*       system_x64_uefi64_info : tsysteminfo =
+       system_x86_64_uefi_info : tsysteminfo =
           (
-            system       : system_x86_64_uefi64;
+            system       : system_x86_64_uefi;
             name         : 'UEFI for x86_64';
-            shortname    : 'uefi64';
-            flags        : [tf_files_case_aware,tf_use_function_relative_addresses,tf_smartlink_library
+            shortname    : 'uefi';
+            flags        : [tf_files_case_aware,tf_use_function_relative_addresses
                             ,tf_smartlink_sections{,tf_section_threadvars}{,tf_needs_dwarf_cfi},
                             tf_no_generic_stackcheck{,tf_has_winlike_resources},tf_under_development,
-                            tf_dwarf_only_local_labels{,tf_pic_uses_got}];
+                            tf_dwarf_only_local_labels{,tf_pic_uses_got},tf_pic_default,tf_library_needs_pic];
             cpu          : cpu_x86_64;
             unit_env     : 'UEFIUNITS';
-            extradefines : 'UEFI64,FPC_OS_UNICODE';
+            extradefines : 'UEFI,FPC_OS_UNICODE';
             exeext       : '.exe';
             defext       : '.def';
             scriptext    : '.bat';
@@ -140,14 +140,14 @@ unit i_uefi;
             linkextern   : ld_none;
             ar           : ar_gnu_ar;
             res          : res_gnu_windres;
-            dbg          : dbg_stabs;
+            dbg          : dbg_dwarf2;
             script       : script_dos;
             endian       : endian_little;
             alignment    :
               (
                 procalign       : 16;
                 loopalign       : 8;
-                jumpalign       : 0;
+                jumpalign       : 4;
                 constalignmin   : 0;
                 constalignmax   : 16;
                 varalignmin     : 0;
@@ -163,26 +163,21 @@ unit i_uefi;
             stackalign   : 16;
             abi          : abi_default;
             { note: default LLVM stack alignment is 16 bytes for this target }
-            { TODO : check this... Took from Haiku, but should probably come from Windows ? }
-            llvmdatalayout : 'e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S32';
-          );*)
+            { TODO : check this... Took from Win64 }
+            llvmdatalayout : 'e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128';
+          );
 
   implementation
   
 initialization
 {$ifdef CPUI386}
-//  WriteLn('CPUI386 defined');
   {$ifdef UEFI}
-//    WriteLn('UEFI defined');
     set_source_info(system_i386_uefi_info);
   {$endif UEFI}
 {$endif CPUI386}
 {$ifdef CPUX86_64}
-{ $ifdef x86_64}
-//  WriteLn('CPUX86_64 defined');
-  {$ifdef UEFI64}
-//    WriteLn('UEFI64 defined');
-    set_source_info(system_x64_uefi64_info);
+  {$ifdef UEFI}
+    set_source_info(system_x86_64_uefi_info);
   {$endif UEFI}
 {$endif CPUX86_64}
 

+ 4 - 8
compiler/systems/t_uefi.pas

@@ -87,18 +87,14 @@ initialization
   RegisterLinker(ld_int_uefi,TInternalLinkerUEFI);
 {$ifdef i386}
   { UEFI }
-//  WriteLn('32 UEFI');
   RegisterImport(system_i386_uefi,TImportLibUEFI);
   RegisterExport(system_i386_uefi,TExportLibUEFI);
   RegisterTarget(system_i386_uefi_info);
 {$endif i386}
 {$ifdef x86_64}
-{ $ifdef UEFI64}
-  { UEFI }
-//  WriteLn('64 UEFI');
-  RegisterImport(system_x86_64_uefi64,TImportLibUEFI);
-  RegisterExport(system_x86_64_uefi64,TExportLibUEFI);
-  RegisterTarget(system_x64_uefi64_info);
-{ $endif}
+  { UEFI 64}
+  RegisterImport(system_x86_64_uefi,TImportLibUEFI);
+  RegisterExport(system_x86_64_uefi,TExportLibUEFI);
+  RegisterTarget(system_x86_64_uefi_info);
 {$endif x86_64}
 end.

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

@@ -178,7 +178,8 @@ const
   { 90 }  'Embedded-i8086',
   { 91 }  'AROS-arm',
   { 92 }  'WebAssembly-wasm',
-  { 93 }  'UEFI-i386'
+  { 93 }  'UEFI-i386',
+  { 94 }  'UEFI-x86-64'
   );
 
 const

+ 4 - 0
compiler/x86_64/cputarg.pas

@@ -55,6 +55,10 @@ implementation
     {$ifndef NOTARGETEMBEDDED}
       ,t_embed
     {$endif}
+    {$ifndef NOTTARGETUEFI}
+      ,t_uefi
+    {$endif NOTTARGETUEFI}
+
 
 {**************************************
              Assemblers