Browse Source

+ ELF/AArch64 resource handling support (patch by Edmund Grimley Evans)

git-svn-id: trunk@30896 -
Jonas Maebe 10 năm trước cách đây
mục cha
commit
41e4f7a55a

+ 3 - 1
packages/fcl-res/src/elfconsts.pp

@@ -22,7 +22,7 @@ interface
 type
   TElfMachineType = (emtnone, emtsparc, emti386, emtm68k, emtppc, emtppc64,
                      emtarm, emtarmeb, emtia64, emtx86_64, emtalpha,
-                     emtmips, emtmipsel, emtppc64le);
+                     emtmips, emtmipsel, emtppc64le, emtaarch64);
 const
   ELFMAGIC     = chr($7f)+'ELF';
 
@@ -71,6 +71,7 @@ const
   EM_IA_64       = 50;
   EM_MIPS_X      = 51; // GNU readelf returns machine name "Stanford MIPS-X"
   EM_X86_64      = 62;
+  EM_AARCH64     = 183;
   EM_ALPHA       = $9026; //unofficial, but used by gnu toolchain
   
   //machine-specific flags
@@ -130,6 +131,7 @@ const
   R_PPC_ADDR32    =   1;
   R_PPC64_ADDR64  =  38;
   R_ARM_ABS32     =   2;
+  R_AARCH64_ABS64 = 257;
   R_68K_32        =   1;
   R_SPARC_32      =   3;
   R_ALPHA_REFQUAD =   2;

+ 3 - 0
packages/fcl-res/src/elfdefaulttarget.inc

@@ -37,6 +37,9 @@
     fMachineType:=emtarmeb;
     {$ENDIF}
   {$ENDIF}
+  {$IFDEF CPUAARCH64}
+  fMachineType:=emtaarch64;
+  {$ENDIF}
   {$IFDEF CPU68K}
   fMachineType:=emtm68k;
   {$ENDIF}

+ 1 - 0
packages/fcl-res/src/elfreader.pp

@@ -282,6 +282,7 @@ begin
                     fMachineType:=emtarm
                   else
                     fMachineType:=emtarmeb;
+      EM_AARCH64: fMachineType:=emtaarch64;
       EM_ALPHA  : fMachineType:=emtalpha;
       EM_IA_64  : fMachineType:=emtia64;
       EM_X86_64 : fMachineType:=emtx86_64;

+ 1 - 0
packages/fcl-res/src/elfsubwriter.inc

@@ -418,6 +418,7 @@ begin
       EM_386    : begin RelocType:=R_386_32;        SectionType:=SHT_REL;  end;
       EM_PPC    : begin RelocType:=R_PPC_ADDR32;    SectionType:=SHT_RELA; end;
       EM_ARM    : begin RelocType:=R_ARM_ABS32;     SectionType:=SHT_REL;  end;
+      EM_AARCH64: begin RelocType:=R_AARCH64_ABS64; SectionType:=SHT_RELA; end;
       EM_68K    : begin RelocType:=R_68K_32;        SectionType:=SHT_RELA; end;
       EM_SPARC  : begin RelocType:=R_SPARC_32;      SectionType:=SHT_RELA; end;
       EM_X86_64 : begin RelocType:=R_x86_64_64;     SectionType:=SHT_RELA; end;

+ 1 - 0
packages/fcl-res/src/elfwriter.pp

@@ -552,6 +552,7 @@ begin
     emtppc64le: begin fMachineTypeInt:=EM_PPC64; fBits:=ELFCLASS64;fOrder:=ELFDATA2LSB; end;
     emtarm    : begin fMachineTypeInt:=EM_ARM; fBits:=ELFCLASS32; fOrder:=ELFDATA2LSB; end;
     emtarmeb  : begin fMachineTypeInt:=EM_ARM; fBits:=ELFCLASS32; fOrder:=ELFDATA2MSB; end;
+    emtaarch64: begin fMachineTypeInt:=EM_AARCH64; fBits:=ELFCLASS64; fOrder:=ELFDATA2LSB; end;
     emtalpha  : begin fMachineTypeInt:=EM_ALPHA; fBits:=ELFCLASS64; fOrder:=ELFDATA2LSB; end;
     emtia64   : begin fMachineTypeInt:=EM_IA_64; fBits:=ELFCLASS64; fOrder:=ELFDATA2LSB; end;
     emtx86_64 : begin fMachineTypeInt:=EM_X86_64; fBits:=ELFCLASS64; fOrder:=ELFDATA2LSB; end;

+ 1 - 0
utils/fpcres/fpcres.pas

@@ -253,6 +253,7 @@ begin
     mtmips : Result.MachineType:=emtmips;
     mtmipsel : Result.MachineType:=emtmipsel;
     mtppc64le : Result.MachineType:=emtppc64le;
+    mtaarch64 : Result.MachineType:=emtaarch64;
   end;
 end;
 

+ 2 - 2
utils/fpcres/target.pas

@@ -83,7 +83,7 @@ var
     (name : 'ia64';         formats : [ofElf]),                   //mtia64
     (name : 'mips';         formats : [ofElf]; alias : 'mipseb'), //mtmips
     (name : 'mipsel';       formats : [ofElf]),                   //mtmipsel
-    (name : 'aarch64';      formats : [ofMachO]),                 //mtaarch64
+    (name : 'aarch64';      formats : [ofElf, ofMachO]),          //mtaarch64
     (name : 'powerpc64le';  formats : [ofElf]),                   //mtppc64le
     (name : 'bigendian';    formats : [ofExt]),                   //mtBigEndian
     (name : 'littleendian'; formats : [ofExt])                    //mtLittleEndian
@@ -102,7 +102,7 @@ var
                                                      mtppc64,mtarm,mtarmeb,
                                                      mtm68k,mtsparc,mtalpha,
                                                      mtia64,mtmips,mtmipsel,
-                                                     mtppc64le]),
+                                                     mtppc64le,mtaarch64]),
     (name : 'coff';     ext : '.o';      machines : [mti386,mtx86_64,mtarm,
                                                      mtppc,mtppc64]),
     (name : 'xcoff';    ext : '.o';      machines : [mtppc{,mtppc64}]),