Jelajahi Sumber

At least in principle prepare the Mach-O writer for other CPU types.

ogmacho.pas:
  + TMachoObjectOutput: new method current_cpu_type to retrieve the cpu_type_t matching the compiler's target platform
  * TMachoObjectOutput.writedata: initialize cputarget using current_cpu_type and use cputarget instead of CPU_TYPE_I386 in the call to AllocMachoWriter
  * surround the RegisterAssembler call with ifdefs for i386

git-svn-id: trunk@33286 -
svenbarth 9 tahun lalu
induk
melakukan
464941f039
1 mengubah file dengan 24 tambahan dan 2 penghapusan
  1. 24 2
      compiler/ogmacho.pas

+ 24 - 2
compiler/ogmacho.pas

@@ -112,6 +112,7 @@ type
         relcount : integer;
       protected
         procedure TrailZeros;
+        function current_cpu_type: cpu_type_t;inline;
 
         {sections}
         procedure FixSectionRelocs(s: TMachoObjSection);
@@ -1000,6 +1001,25 @@ uses
     end;
 
 
+  function TMachoObjectOutput.current_cpu_type: cpu_type_t;
+    begin
+{$if defined(powerpc)}
+      result:=CPU_TYPE_POWERPC;
+{$elseif defined(powerpc64)}
+      result:=CPU_TYPE_POWERPC64;
+{$elseif defined(i386)}
+      result:=CPU_TYPE_I386;
+{$elseif defined(x86_64)}
+      result:=CPU_TYPE_X86_64;
+{$elseif defined(arm)}
+      result:=CPU_TYPE_ARM;
+{$elseif defined(aarch64)}
+      result:=CPU_TYPE_ARM64;
+{$else}
+      result:=CPU_TYPE_ANY;
+{$endif}
+    end;
+
   function TMachoObjectOutput.writedata(data: TObjData): boolean;
     var
       header  : TMachHeader;
@@ -1020,7 +1040,7 @@ uses
       result:=false;
       machoData:=TMachoObjData(data);
 
-      cputarget:=CPU_TYPE_i386;
+      cputarget:=current_cpu_type;
       segSize:=sizeSegment(cputarget);
       sctSize:=sizeSection(cputarget);
 
@@ -1055,7 +1075,7 @@ uses
       fileofs:=AlignAddr(cputarget, fileofs);
 
       {creating actual mach-o file writer}
-      mfile:=AllocMachoWriter(CPU_TYPE_I386, TMachoRawWriter.Create(writer), true);
+      mfile:=AllocMachoWriter(cputarget, TMachoRawWriter.Create(writer), true);
       {writing macho-o header}
       mfile.WriteHeader(header);
 
@@ -1222,7 +1242,9 @@ uses
       );
 
 initialization
+{$ifdef i386}
   RegisterAssembler(as_i386_darwin_info,TMachoAssembler);
+{$endif i386}
 
 end.