Browse Source

* enable some features for the x86_64 UEFI target, based on the win64 target.

git-svn-id: branches/olivier/uefi@36368 -
olivier 8 years ago
parent
commit
0608468c98

+ 1 - 1
compiler/aasmtai.pas

@@ -1906,7 +1906,7 @@ implementation
             result:=8;
           aitconst_secrel32_symbol,
           aitconst_rva_symbol :
-            if target_info.system=system_x86_64_win64 then
+            if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
               result:=sizeof(longint)
             else
               result:=sizeof(pint);

+ 1 - 1
compiler/assemble.pas

@@ -1899,7 +1899,7 @@ Implementation
                    aitconst_rva_symbol :
                      begin
                        { PE32+? }
-                       if target_info.system=system_x86_64_win64 then
+                       if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
                          ObjData.writereloc(Tai_const(hp).symofs,sizeof(longint),Objdata.SymbolRef(tai_const(hp).sym),RELOC_RVA)
                        else
                          ObjData.writereloc(Tai_const(hp).symofs,sizeof(pint),Objdata.SymbolRef(tai_const(hp).sym),RELOC_RVA);

+ 2 - 2
compiler/entfile.pas

@@ -872,7 +872,7 @@ var
   d : entryreal;
   hd : double;
 begin
-  if target_info.system=system_x86_64_win64 then
+  if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
     begin
       hd:=getrealsize(sizeof(hd));
       getreal:=hd;
@@ -1178,7 +1178,7 @@ procedure tentryfile.putreal(d:entryreal);
 var
   hd : double;
 begin
-  if target_info.system=system_x86_64_win64 then
+  if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
     begin
       hd:=d;
       putdata(hd,sizeof(hd));

+ 9 - 9
compiler/ogcoff.pas

@@ -2184,7 +2184,7 @@ const pemagic : array[0..3] of byte = (
       begin
         inherited create;
         win32:=awin32;
-        if target_info.system in [system_x86_64_win64] then
+        if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
           MaxMemPos:=$FFFFFFFF
         else
           if target_info.system in systems_wince then
@@ -2522,7 +2522,7 @@ const pemagic : array[0..3] of byte = (
         if win32 then
           begin
             header.flag:=PE_FILE_EXECUTABLE_IMAGE or PE_FILE_LINE_NUMS_STRIPPED;
-            if target_info.system in [system_x86_64_win64] then
+            if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
               header.flag:=header.flag or PE_FILE_LARGE_ADDRESS_AWARE
             else
               header.flag:=header.flag or PE_FILE_32BIT_MACHINE;
@@ -2717,7 +2717,7 @@ const pemagic : array[0..3] of byte = (
         objreloc:TObjRelocation;
         i,j:longint;
       begin
-        if target_info.system<>system_x86_64_win64 then
+        if not (target_info.system in [system_x86_64_win64,system_x86_64_uefi]) then
           exit;
         exesec:=FindExeSection('.pdata');
         if exesec=nil then
@@ -2778,11 +2778,11 @@ const pemagic : array[0..3] of byte = (
         begin
           { idata4 }
           idata4objsection.writezeros(sizeof(longint));
-          if target_info.system=system_x86_64_win64 then
+          if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
             idata4objsection.writezeros(sizeof(longint));
           { idata5 }
           idata5objsection.writezeros(sizeof(longint));
-          if target_info.system=system_x86_64_win64 then
+          if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
             idata5objsection.writezeros(sizeof(longint));
         end;
 
@@ -2809,14 +2809,14 @@ const pemagic : array[0..3] of byte = (
             if AOrdNr <= 0 then
               begin
                 objsec.writereloc_internal(idata6objsection,idata6objsection.size,sizeof(longint),RELOC_RVA);
-                if target_info.system=system_x86_64_win64 then
+                if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
                   objsec.writezeros(sizeof(longint));
               end
             else
               begin
                 { import by ordinal }
                 ordint:=AOrdNr;
-                if target_info.system=system_x86_64_win64 then
+                if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
                   begin
                     objsec.write(ordint,sizeof(ordint));
                     ordint:=$80000000;
@@ -3117,14 +3117,14 @@ const pemagic : array[0..3] of byte = (
         result:=false;
         fillchar(sechdr,sizeof(sechdr),0);
 {$ifdef win32}
-        if (target_info.system=system_x86_64_win64) and
+        if (target_info.system in [system_x86_64_win64,system_x86_64_uefi]) and
           assigned(Wow64DisableWow64FsRedirection) then
           Wow64DisableWow64FsRedirection(p);
 {$endif win32}
         DLLReader:=TObjectReader.Create;
         DLLReader.OpenFile(dllname);
 {$ifdef win32}
-        if (target_info.system=system_x86_64_win64) and
+        if (target_info.system in [system_x86_64_win64,system_x86_64_uefi]) and
           assigned(Wow64RevertWow64FsRedirection) then
           Wow64RevertWow64FsRedirection(p);
 {$endif win32}

+ 8 - 8
compiler/systems/i_uefi.pas

@@ -38,8 +38,8 @@ unit i_uefi;
             shortname    : 'uefi';
             flags        : [tf_files_case_aware,tf_use_function_relative_addresses,tf_smartlink_library
                             ,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_no_generic_stackcheck{,tf_has_winlike_resources},tf_under_development//,
+                            {tf_dwarf_only_local_labels}{,tf_pic_uses_got}];
             cpu          : cpu_i386;
             unit_env     : 'UEFIUNITS';
             extradefines : 'UEFI,FPC_OS_UNICODE';
@@ -104,14 +104,14 @@ unit i_uefi;
             system       : system_x86_64_uefi;
             name         : 'UEFI for x86_64';
             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_pic_default,tf_library_needs_pic];
+            flags        : [tf_files_case_aware,tf_use_function_relative_addresses,tf_smartlink_library
+                            ,tf_smartlink_sections{,tf_section_threadvars}{,tf_needs_dwarf_cfi},{tf_dwarf_relative_addresses,}
+                            tf_no_generic_stackcheck{,tf_has_winlike_resources},tf_under_development,{tf_no_pic_supported,}
+                            tf_dwarf_only_local_labels{,tf_pic_uses_got}{,tf_pic_default,tf_library_needs_pic}];
             cpu          : cpu_x86_64;
             unit_env     : 'UEFIUNITS';
             extradefines : 'UEFI,FPC_OS_UNICODE';
-            exeext       : '.exe';
+            exeext       : '.efi';
             defext       : '.def';
             scriptext    : '.bat';
             smartext     : '.sl';
@@ -140,7 +140,7 @@ unit i_uefi;
             linkextern   : ld_none;
             ar           : ar_gnu_ar;
             res          : res_gnu_windres;
-            dbg          : dbg_dwarf2;
+            dbg          : dbg_stabs;
             script       : script_dos;
             endian       : endian_little;
             alignment    :

+ 9 - 9
compiler/systems/t_win.pas

@@ -251,12 +251,12 @@ implementation
           { idata4 }
           objdata.SetSection(idata4objsection);
           objdata.writebytes(emptyint,sizeof(emptyint));
-          if target_info.system=system_x86_64_win64 then
+          if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
             objdata.writebytes(emptyint,sizeof(emptyint));
           { idata5 }
           objdata.SetSection(idata5objsection);
           objdata.writebytes(emptyint,sizeof(emptyint));
-          if target_info.system=system_x86_64_win64 then
+          if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
             objdata.writebytes(emptyint,sizeof(emptyint));
           { idata7 }
           objdata.SetSection(idata7objsection);
@@ -311,14 +311,14 @@ implementation
               begin
                 { import by name }
                 objdata.writereloc(0,sizeof(longint),idata6label,RELOC_RVA);
-                if target_info.system=system_x86_64_win64 then
+                if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
                   objdata.writebytes(emptyint,sizeof(emptyint));
               end
             else
               begin
                 { import by ordinal }
                 ordint:=ordnr;
-                if target_info.system=system_x86_64_win64 then
+                if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
                   begin
                     objdata.writebytes(ordint,sizeof(ordint));
                     ordint:=$80000000;
@@ -487,12 +487,12 @@ implementation
                 if ImportSymbol.Name<>'' then
                   begin
                     current_asmdata.asmlists[al_imports].concat(Tai_const.Create_rva_sym(TAsmLabel(ImportLabels[j])));
-                    if target_info.system=system_x86_64_win64 then
+                    if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
                       current_asmdata.asmlists[al_imports].concat(Tai_const.Create_32bit(0));
                   end
                 else
                   begin
-                    if target_info.system=system_x86_64_win64 then
+                    if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
                       current_asmdata.asmlists[al_imports].concat(Tai_const.Create_64bit(int64($8000000000000000) or ImportSymbol.ordnr))
                     else
                       current_asmdata.asmlists[al_imports].concat(Tai_const.Create_32bit(longint($80000000) or ImportSymbol.ordnr));
@@ -500,7 +500,7 @@ implementation
               end;
             { finalize the names ... }
             current_asmdata.asmlists[al_imports].concat(Tai_const.Create_32bit(0));
-            if target_info.system=system_x86_64_win64 then
+            if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
               current_asmdata.asmlists[al_imports].concat(Tai_const.Create_32bit(0));
 
             { then the addresses and create also the indirect jump }
@@ -573,12 +573,12 @@ implementation
                 else
                   current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(ImportSymbol.MangledName,AT_DATA,0,voidpointertype));
                 current_asmdata.asmlists[al_imports].concat(Tai_const.Create_rva_sym(TAsmLabel(Importlabels[j])));
-                if target_info.system=system_x86_64_win64 then
+                if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
                   current_asmdata.asmlists[al_imports].concat(Tai_const.Create_32bit(0));
               end;
             { finalize the addresses }
             current_asmdata.asmlists[al_imports].concat(Tai_const.Create_32bit(0));
-            if target_info.system=system_x86_64_win64 then
+            if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
               current_asmdata.asmlists[al_imports].concat(Tai_const.Create_32bit(0));
 
             { finally the import information }

+ 2 - 0
compiler/x86/aasmcpu.pas

@@ -3428,7 +3428,9 @@ implementation
                            currabsreloc:=RELOC_ABSOLUTE
                          else
 {$endif i8086}
+							begin
                              currabsreloc:=RELOC_ABSOLUTE32;
+                            end;
 
                            if (currabsreloc in [RELOC_ABSOLUTE32{$ifdef i8086},RELOC_ABSOLUTE{$endif}]) and
                             (Assigned(oper[opidx]^.ref^.relsymbol)) then

+ 1 - 1
compiler/x86/cgx86.pas

@@ -529,7 +529,7 @@ unit cgx86;
               end
             else
               { Always use RIP relative symbol addressing for Windows and Darwin targets. }
-              if (target_info.system in (systems_all_windows+[system_x86_64_darwin,system_x86_64_iphonesim])) and (ref.base<>NR_RIP) then
+              if (target_info.system in (systems_all_windows+[system_x86_64_darwin,system_x86_64_iphonesim,system_x86_64_uefi])) and (ref.base<>NR_RIP) then
                 begin
                   if (ref.refaddr=addr_no) and (ref.base=NR_NO) and (ref.index=NR_NO) then
                     begin

+ 1 - 1
compiler/x86/nx86ld.pas

@@ -59,7 +59,7 @@ implementation
         handled:=false;
         if (tf_section_threadvars in target_info.flags) then
           begin
-            if target_info.system in [system_i386_win32,system_x86_64_win64] then
+            if target_info.system in [system_i386_win32,system_x86_64_win64,system_x86_64_uefi] then
               begin
                 paraloc1.init;
                 pd:=search_system_proc('fpc_tls_add');

+ 3 - 3
compiler/x86_64/cgcpu.pas

@@ -158,7 +158,7 @@ unit cgcpu;
         i: longint;
       begin
         result:=0;
-        if (target_info.system<>system_x86_64_win64) or
+        if (not(target_info.system in [system_x86_64_win64,system_x86_64_uefi])) or
            (not uses_registers(R_MMREGISTER)) then
           exit;
         for i:=low(saved_mm_registers) to high(saved_mm_registers) do
@@ -397,7 +397,7 @@ unit cgcpu;
                 if (current_procinfo.procdef.proctypeoption=potype_exceptfilter) then
                   list.concat(Taicpu.op_reg(A_POP,tcgsize2opsize[OS_ADDR],NR_FRAME_POINTER_REG));
               end
-            else if (target_info.system=system_x86_64_win64) then
+            else if (target_info.system in [system_x86_64_win64,system_x86_64_uefi]) then
               begin
                 { Comply with Win64 unwinding mechanism, which only recognizes
                   'add $constant,%rsp' and 'lea offset(FPREG),%rsp' as belonging to
@@ -516,7 +516,7 @@ unit cgcpu;
         if assigned(current_procinfo) then
           use_ms_abi:=x86_64_use_ms_abi(current_procinfo.procdef.proccalloption)
         else
-          use_ms_abi:=target_info.system=system_x86_64_win64;
+          use_ms_abi:=target_info.system in [system_x86_64_win64,system_x86_64_uefi];
       end;
 
 

+ 3 - 3
compiler/x86_64/cpupi.pas

@@ -68,7 +68,7 @@ implementation
 
     procedure tcpuprocinfo.set_first_temp_offset;
       begin
-        if target_info.system=system_x86_64_win64 then
+        if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
           begin
             { Fixes the case when there are calls done by low-level means
               (cg.a_call_name) but no child callnode }
@@ -89,7 +89,7 @@ implementation
     procedure tcpuprocinfo.generate_parameter_info;
       begin
         inherited generate_parameter_info;
-        if target_info.system=system_x86_64_win64 then
+        if target_info.system in [system_x86_64_win64,system_x86_64_uefi] then
           para_stack_size:=0;
       end;
 
@@ -171,7 +171,7 @@ implementation
     function x86_64_use_ms_abi(proccall: tproccalloption): boolean;
       begin
         result:=
-           ((target_info.system=system_x86_64_win64) and
+           ((target_info.system in [system_x86_64_win64,system_x86_64_uefi]) and
             not(proccall in [pocall_sysv_abi_default,pocall_sysv_abi_cdecl])) or
            (proccall in [pocall_ms_abi_default,pocall_ms_abi_cdecl]);
       end;

+ 7 - 7
compiler/x86_64/nx64flw.pas

@@ -72,7 +72,7 @@ function tx64raisenode.pass_1 : tnode;
     raisenode : tcallnode;
   begin
     { difference from generic code is that address stack is not popped on reraise }
-    if (target_info.system<>system_x86_64_win64) or assigned(left) then
+    if (not(target_info.system in [system_x86_64_win64,system_x86_64_uefi])) or assigned(left) then
       result:=inherited pass_1
     else
       begin
@@ -89,7 +89,7 @@ procedure tx64onnode.pass_generate_code;
   var
     exceptvarsym : tlocalvarsym;
   begin
-    if (target_info.system<>system_x86_64_win64) then
+    if (not(target_info.system in [system_x86_64_win64,system_x86_64_uefi])) then
       begin
         inherited pass_generate_code;
         exit;
@@ -153,7 +153,7 @@ function copy_parasize(var n: tnode; arg: pointer): foreachnoderesult;
 constructor tx64tryfinallynode.create(l, r: TNode);
   begin
     inherited create(l,r);
-    if (target_info.system=system_x86_64_win64) and
+    if (target_info.system in [system_x86_64_win64,system_x86_64_uefi]) and
       { Don't create child procedures for generic methods, their nested-like
         behavior causes compilation errors because real nested procedures
         aren't allowed for generics. Not creating them doesn't harm because
@@ -179,7 +179,7 @@ constructor tx64tryfinallynode.create(l, r: TNode);
 constructor tx64tryfinallynode.create_implicit(l, r, _t1: TNode);
   begin
     inherited create_implicit(l, r, _t1);
-    if (target_info.system=system_x86_64_win64) then
+    if (target_info.system in [system_x86_64_win64,system_x86_64_uefi]) then
       begin
         if df_generic in current_procinfo.procdef.defoptions then
           InternalError(2013012501);
@@ -202,7 +202,7 @@ constructor tx64tryfinallynode.create_implicit(l, r, _t1: TNode);
 function tx64tryfinallynode.simplify(forinline: boolean): tnode;
   begin
     result:=inherited simplify(forinline);
-    if (target_info.system<>system_x86_64_win64) then
+    if (not(target_info.system in [system_x86_64_win64,system_x86_64_uefi])) then
       exit;
     if (result=nil) then
       begin
@@ -243,7 +243,7 @@ procedure tx64tryfinallynode.pass_generate_code;
     oldflowcontrol: tflowcontrol;
     catch_frame: boolean;
   begin
-    if (target_info.system<>system_x86_64_win64) then
+    if (not(target_info.system in [system_x86_64_win64,system_x86_64_uefi])) then
       begin
         inherited pass_generate_code;
         exit;
@@ -372,7 +372,7 @@ procedure tx64tryexceptnode.pass_generate_code;
   label
     errorexit;
   begin
-    if (target_info.system<>system_x86_64_win64) then
+    if (not(target_info.system in [system_x86_64_win64,system_x86_64_uefi])) then
       begin
         inherited pass_generate_code;
         exit;

+ 1 - 1
compiler/x86_64/rax64att.pas

@@ -74,7 +74,7 @@ Unit rax64att;
         i: TAsmSehDirective;
       begin
         result:=false;
-        if target_info.system<>system_x86_64_win64 then
+        if not(target_info.system in [system_x86_64_win64,system_x86_64_uefi]) then
           exit;
 
         for i:=low(TAsmSehDirective) to high(TAsmSehDirective) do