Add elf resource support for mips/mipsel CPU

git-svn-id: trunk@22603 -
This commit is contained in:
pierre 2012-10-09 14:08:50 +00:00
parent b11276b34f
commit 5a3078495b
5 changed files with 21 additions and 2 deletions

View File

@ -21,7 +21,8 @@ interface
type type
TElfMachineType = (emtnone, emtsparc, emti386, emtm68k, emtppc, emtppc64, TElfMachineType = (emtnone, emtsparc, emti386, emtm68k, emtppc, emtppc64,
emtarm, emtarmeb, emtia64, emtx86_64, emtalpha); emtarm, emtarmeb, emtia64, emtx86_64, emtalpha,
emtmips, emtmipsel);
const const
ELFMAGIC = chr($7f)+'ELF'; ELFMAGIC = chr($7f)+'ELF';
@ -61,11 +62,14 @@ const
EM_SPARC = 2; EM_SPARC = 2;
EM_386 = 3; EM_386 = 3;
EM_68K = 4; EM_68K = 4;
EM_MIPS = 8; // GNU readelf returns machine name: "MIPS R3000"
EM_MIPS_RS3_LE = 10; // GNU readelf returns machine name: "MIPS R4000 big endian"!
EM_PPC = 20; EM_PPC = 20;
EM_PPC64 = 21; EM_PPC64 = 21;
EM_ARM = 40; EM_ARM = 40;
// EM_OLD_ALPHA = 41; // EM_OLD_ALPHA = 41;
EM_IA_64 = 50; EM_IA_64 = 50;
EM_MIPS_X = 51; // GNU readelf returns machine name "Stanford MIPS-X"
EM_X86_64 = 62; EM_X86_64 = 62;
EM_ALPHA = $9026; //unofficial, but used by gnu toolchain EM_ALPHA = $9026; //unofficial, but used by gnu toolchain
@ -130,6 +134,7 @@ const
R_SPARC_32 = 3; R_SPARC_32 = 3;
R_ALPHA_REFQUAD = 2; R_ALPHA_REFQUAD = 2;
R_IA64_DIR64LSB = $27; R_IA64_DIR64LSB = $27;
R_MIPS_32 = 2;
//fpc resource constants //fpc resource constants

View File

@ -45,6 +45,13 @@
{$IFDEF CPUIA64} {$IFDEF CPUIA64}
fMachineType:=emtia64; fMachineType:=emtia64;
{$ENDIF} {$ENDIF}
{$IFDEF CPUMIPS}
{$IFDEF ENDIAN_LITTLE}
fMachineType:=emtmipsel;
{$ELSE}
fMachineType:=emtmips;
{$ENDIF}
{$ENDIF}
fBits:=ELFCLASSNONE; fBits:=ELFCLASSNONE;
{$IFDEF CPU32} {$IFDEF CPU32}

View File

@ -285,6 +285,10 @@ begin
EM_ALPHA : fMachineType:=emtalpha; EM_ALPHA : fMachineType:=emtalpha;
EM_IA_64 : fMachineType:=emtia64; EM_IA_64 : fMachineType:=emtia64;
EM_X86_64 : fMachineType:=emtx86_64; EM_X86_64 : fMachineType:=emtx86_64;
EM_MIPS : if fOrder=ELFDATA2LSB then
fMachineType:=emtmipsel
else
fMachineType:=emtmips;
end; end;
finally finally
subreader.Free; subreader.Free;

View File

@ -424,6 +424,7 @@ begin
EM_PPC64 : begin RelocType:=R_PPC64_ADDR64; SectionType:=SHT_RELA; end; EM_PPC64 : begin RelocType:=R_PPC64_ADDR64; SectionType:=SHT_RELA; end;
EM_ALPHA : begin RelocType:=R_ALPHA_REFQUAD; SectionType:=SHT_RELA; end; EM_ALPHA : begin RelocType:=R_ALPHA_REFQUAD; SectionType:=SHT_RELA; end;
EM_IA_64 : begin RelocType:=R_IA64_DIR64LSB; SectionType:=SHT_RELA; end; EM_IA_64 : begin RelocType:=R_IA64_DIR64LSB; SectionType:=SHT_RELA; end;
EM_MIPS : begin RelocType:=R_MIPS_32; SectionType:=SHT_RELA; end;
else else
raise EElfResourceWriterUnknownMachineException.Create(''); raise EElfResourceWriterUnknownMachineException.Create('');
end; end;

View File

@ -553,7 +553,9 @@ begin
emtarmeb : begin fMachineTypeInt:=EM_ARM; fBits:=ELFCLASS32; fOrder:=ELFDATA2MSB; end; emtarmeb : begin fMachineTypeInt:=EM_ARM; fBits:=ELFCLASS32; fOrder:=ELFDATA2MSB; end;
emtalpha : begin fMachineTypeInt:=EM_ALPHA; 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; emtia64 : begin fMachineTypeInt:=EM_IA_64; fBits:=ELFCLASS64; fOrder:=ELFDATA2LSB; end;
emtx86_64 : begin fMachineTypeInt:=EM_X86_64; fBits:=ELFCLASS64; fOrder:=ELFDATA2LSB; end emtx86_64 : begin fMachineTypeInt:=EM_X86_64; fBits:=ELFCLASS64; fOrder:=ELFDATA2LSB; end;
emtmips : begin fMachineTypeInt:=EM_MIPS; fBits:=ELFCLASS32; fOrder:=ELFDATA2MSB; end;
emtmipsel : begin fMachineTypeInt:=EM_MIPS; fBits:=ELFCLASS32; fOrder:=ELFDATA2LSB; end
else else
raise EElfResourceWriterUnknownMachineException.Create(''); raise EElfResourceWriterUnknownMachineException.Create('');
end; end;