瀏覽代碼

fcl-res: fpcres: add support for aarch64-coff

git-svn-id: trunk@47288 -
Marc Weustink 4 年之前
父節點
當前提交
4e03876083

+ 22 - 0
packages/fcl-res/src/coffconsts.pp

@@ -56,6 +56,7 @@ const
   IMAGE_FILE_MACHINE_EBC             = $0EBC;  // EFI Byte Code
   IMAGE_FILE_MACHINE_EBC             = $0EBC;  // EFI Byte Code
 }
 }
   IMAGE_FILE_MACHINE_AMD64           = $8664;  // AMD64 (K8)
   IMAGE_FILE_MACHINE_AMD64           = $8664;  // AMD64 (K8)
+  IMAGE_FILE_MACHINE_ARM64           = $aa64;  // ARM64 little endian
 {
 {
   IMAGE_FILE_MACHINE_M32R            = $9041;  // M32R little-endian
   IMAGE_FILE_MACHINE_M32R            = $9041;  // M32R little-endian
   IMAGE_FILE_MACHINE_CEE             = $C0EE;
   IMAGE_FILE_MACHINE_CEE             = $C0EE;
@@ -159,6 +160,27 @@ const
   IMAGE_REL_AMD64_PAIR          = $000F;
   IMAGE_REL_AMD64_PAIR          = $000F;
   IMAGE_REL_AMD64_SSPAN32       = $0010;  // 32 bit signed span-dependent value applied at link time
   IMAGE_REL_AMD64_SSPAN32       = $0010;  // 32 bit signed span-dependent value applied at link time
 
 
+// aarch64 relocation types
+
+  IMAGE_REL_ARM64_ABSOLUTE      = $0000;  // The relocation is ignored.
+  IMAGE_REL_ARM64_ADDR32        = $0001;  // The 32-bit VA of the target.
+  IMAGE_REL_ARM64_ADDR32NB      = $0002;  // The 32-bit RVA of the target.
+  IMAGE_REL_ARM64_BRANCH26      = $0003;  // The 26-bit relative displacement to the target, for B and BL instructions.
+  IMAGE_REL_ARM64_PAGEBASE_REL21= $0004;  // The page base of the target, for ADRP instruction.
+  IMAGE_REL_ARM64_REL21         = $0005;  // The 12-bit relative displacement to the target, for instruction ADR
+  IMAGE_REL_ARM64_PAGEOFFSET_12A= $0006;  // The 12-bit page offset of the target, for instructions ADD/ADDS (immediate) with zero shift.
+  IMAGE_REL_ARM64_PAGEOFFSET_12L= $0007;  // The 12-bit page offset of the target, for instruction LDR (indexed, unsigned immediate).
+  IMAGE_REL_ARM64_SECREL        = $0008;  // The 32-bit offset of the target from the beginning of its section. This is used to support debugging information and static thread local storage.
+  IMAGE_REL_ARM64_SECREL_LOW12A = $0009;  // Bit 0:11 of section offset of the target, for instructions ADD/ADDS (immediate) with zero shift.
+  IMAGE_REL_ARM64_SECREL_HIGH12A= $000A;  // Bit 12:23 of section offset of the target, for instructions ADD/ADDS (immediate) with zero shift.
+  IMAGE_REL_ARM64_SECREL_LOW12L = $000B;  // Bit 0:11 of section offset of the target, for instruction LDR (indexed, unsigned immediate).
+  IMAGE_REL_ARM64_TOKEN         = $000C;  // CLR token.
+  IMAGE_REL_ARM64_SECTION       = $000D;  // The 16-bit section index of the section that contains the target. This is used to support debugging information.
+  IMAGE_REL_ARM64_ADDR64        = $000E;  // The 64-bit VA of the relocation target.
+  IMAGE_REL_ARM64_BRANCH19      = $000F;  // The 19-bit offset to the relocation target, for conditional B instruction.
+  IMAGE_REL_ARM64_BRANCH14      = $0010;  // The 14-bit offset to the relocation target, for instructions TBZ and TBNZ.
+  IMAGE_REL_ARM64_REL32         = $0011;  // The 32-bit relative address from the byte following the relocation.
+
 // AIX PPC32/PPC64 relocation types.
 // AIX PPC32/PPC64 relocation types.
 
 
   IMAGE_REL_PPC_POS             = $1F00;  // A(sym) Positive Relocation
   IMAGE_REL_PPC_POS             = $1F00;  // A(sym) Positive Relocation

+ 1 - 1
packages/fcl-res/src/cofftypes.pp

@@ -20,7 +20,7 @@ unit cofftypes;
 interface
 interface
 
 
 type
 type
-  TCoffMachineType = (cmti386, cmtarm, cmtx8664, cmtppc32aix, cmtppc64aix);
+  TCoffMachineType = (cmti386, cmtarm, cmtx8664, cmtppc32aix, cmtppc64aix, cmtaarch64);
 
 
 type
 type
   TSectionName = array [0..7] of char;
   TSectionName = array [0..7] of char;

+ 5 - 2
packages/fcl-res/src/coffwriter.pp

@@ -452,6 +452,7 @@ begin
     cmti386     : Result.machine:=IMAGE_FILE_MACHINE_I386;
     cmti386     : Result.machine:=IMAGE_FILE_MACHINE_I386;
     cmtarm      : Result.machine:=IMAGE_FILE_MACHINE_ARM;
     cmtarm      : Result.machine:=IMAGE_FILE_MACHINE_ARM;
     cmtx8664    : Result.machine:=IMAGE_FILE_MACHINE_AMD64;
     cmtx8664    : Result.machine:=IMAGE_FILE_MACHINE_AMD64;
+    cmtaarch64  : Result.machine:=IMAGE_FILE_MACHINE_ARM64;
     cmtppc32aix : Result.machine:=IMAGE_FILE_MACHINE_POWERPC32_AIX;
     cmtppc32aix : Result.machine:=IMAGE_FILE_MACHINE_POWERPC32_AIX;
     cmtppc64aix : Result.machine:=IMAGE_FILE_MACHINE_POWERPC64_AIX;
     cmtppc64aix : Result.machine:=IMAGE_FILE_MACHINE_POWERPC64_AIX;
   end;
   end;
@@ -527,7 +528,7 @@ procedure TCoffResourceWriter.SetMachineType(AValue: TCoffMachineType);
 begin
 begin
   fMachineType:=AValue;
   fMachineType:=AValue;
 {$IFDEF ENDIAN_BIG}
 {$IFDEF ENDIAN_BIG}
-  if fMachineType in [cmti386,cmtx8664,cmtarm] then
+  if fMachineType in [cmti386,cmtx8664,cmtarm,cmtaarch64] then
     fOppositeEndianess:=true;
     fOppositeEndianess:=true;
 {$ELSE}
 {$ELSE}
   if fMachineType in [cmtppc32aix,cmtppc64aix] then
   if fMachineType in [cmtppc32aix,cmtppc64aix] then
@@ -536,7 +537,8 @@ begin
   case fMachineType of
   case fMachineType of
     cmti386,
     cmti386,
     cmtx8664,
     cmtx8664,
-    cmtarm:
+    cmtarm,
+    cmtaarch64:
       fSymStorageClass:=IMAGE_SYM_CLASS_STATIC;
       fSymStorageClass:=IMAGE_SYM_CLASS_STATIC;
     cmtppc32aix,
     cmtppc32aix,
     cmtppc64aix:
     cmtppc64aix:
@@ -737,6 +739,7 @@ begin
     cmti386     : reloctype:=IMAGE_REL_I386_DIR32NB;
     cmti386     : reloctype:=IMAGE_REL_I386_DIR32NB;
     cmtarm      : reloctype:=IMAGE_REL_ARM_ADDR32NB;
     cmtarm      : reloctype:=IMAGE_REL_ARM_ADDR32NB;
     cmtx8664    : reloctype:=IMAGE_REL_AMD64_ADDR32NB;
     cmtx8664    : reloctype:=IMAGE_REL_AMD64_ADDR32NB;
+    cmtaarch64  : reloctype:=IMAGE_REL_ARM64_ADDR32NB;
     cmtppc32aix : reloctype:=IMAGE_REL_PPC_POS;
     cmtppc32aix : reloctype:=IMAGE_REL_PPC_POS;
     cmtppc64aix : reloctype:=IMAGE_REL_PPC_POS;
     cmtppc64aix : reloctype:=IMAGE_REL_PPC_POS;
   end;
   end;

+ 1 - 0
utils/fpcres/fpcres.pas

@@ -274,6 +274,7 @@ begin
     mti386 : Result.MachineType:=cmti386;
     mti386 : Result.MachineType:=cmti386;
     mtarm : Result.MachineType:=cmtarm;
     mtarm : Result.MachineType:=cmtarm;
     mtx86_64 : Result.MachineType:=cmtx8664;
     mtx86_64 : Result.MachineType:=cmtx8664;
+    mtaarch64 : Result.MachineType:=cmtaarch64;
   end;
   end;
 end;
 end;
 
 

+ 2 - 2
utils/fpcres/target.pas

@@ -85,7 +85,7 @@ var
     (name : 'ia64';         formats : [ofElf]),                   //mtia64
     (name : 'ia64';         formats : [ofElf]),                   //mtia64
     (name : 'mips';         formats : [ofElf]; alias : 'mipseb'), //mtmips
     (name : 'mips';         formats : [ofElf]; alias : 'mipseb'), //mtmips
     (name : 'mipsel';       formats : [ofElf]),                   //mtmipsel
     (name : 'mipsel';       formats : [ofElf]),                   //mtmipsel
-    (name : 'aarch64';      formats : [ofElf, ofMachO]),          //mtaarch64
+    (name : 'aarch64';      formats : [ofElf, ofCoff, ofMachO]),  //mtaarch64
     (name : 'powerpc64le';  formats : [ofElf]),                   //mtppc64le
     (name : 'powerpc64le';  formats : [ofElf]),                   //mtppc64le
     (name : 'riscv32';      formats : [ofElf]),                   //mtriscv32
     (name : 'riscv32';      formats : [ofElf]),                   //mtriscv32
     (name : 'riscv64';      formats : [ofElf]),                   //mtriscv64
     (name : 'riscv64';      formats : [ofElf]),                   //mtriscv64
@@ -109,7 +109,7 @@ var
                                                      mtppc64le,mtaarch64,
                                                      mtppc64le,mtaarch64,
                                                      mtriscv32,mtriscv64]),
                                                      mtriscv32,mtriscv64]),
     (name : 'coff';     ext : '.o';      machines : [mti386,mtx86_64,mtarm,
     (name : 'coff';     ext : '.o';      machines : [mti386,mtx86_64,mtarm,
-                                                     mtppc,mtppc64]),
+                                                     mtaarch64,mtppc,mtppc64]),
     (name : 'xcoff';    ext : '.o';      machines : [mtppc{,mtppc64}]),
     (name : 'xcoff';    ext : '.o';      machines : [mtppc{,mtppc64}]),
     (name : 'mach-o';   ext : '.or';     machines : [mti386,mtx86_64,mtppc,
     (name : 'mach-o';   ext : '.or';     machines : [mti386,mtx86_64,mtppc,
                                                      mtppc64,mtarm,mtaarch64]),
                                                      mtppc64,mtarm,mtaarch64]),