Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for writing ARMv7 binaries

  • Loading branch information...
commit 9bfe76be006fbf8cd2dc4df20b00764e8faecfc7 1 parent 0a618a3
@jbevain authored
Showing with 10 additions and 6 deletions.
  1. +10 −6 Mono.Cecil.PE/ImageWriter.cs
View
16 Mono.Cecil.PE/ImageWriter.cs
@@ -58,6 +58,7 @@ sealed class ImageWriter : BinaryStreamWriter {
internal const RVA text_rva = 0x2000;
readonly bool pe64;
+ readonly bool has_reloc;
readonly uint time_stamp;
internal Section text;
@@ -71,11 +72,12 @@ sealed class ImageWriter : BinaryStreamWriter {
{
this.module = module;
this.metadata = metadata;
- this.pe64 = module.Architecture != TargetArchitecture.I386;
+ this.pe64 = module.Architecture == TargetArchitecture.AMD64 || module.Architecture == TargetArchitecture.IA64;
+ this.has_reloc = module.Architecture == TargetArchitecture.I386;
this.GetDebugHeader ();
this.GetWin32Resources ();
this.text_map = BuildTextMap ();
- this.sections = (ushort) (pe64 ? 1 : 2); // text + reloc
+ this.sections = (ushort) (has_reloc ? 2 : 1); // text + reloc?
this.time_stamp = (uint) DateTime.UtcNow.Subtract (new DateTime (1970, 1, 1)).TotalSeconds;
}
@@ -133,7 +135,7 @@ void BuildSections ()
previous = rsrc;
}
- if (!pe64)
+ if (has_reloc)
reloc = CreateSection (".reloc", 12u, previous);
}
@@ -213,6 +215,8 @@ ushort GetMachine ()
return 0x8664;
case TargetArchitecture.IA64:
return 0x0200;
+ case TargetArchitecture.ARMv7:
+ return 0x01c4;
}
throw new NotSupportedException ();
@@ -398,7 +402,7 @@ void WriteText ()
// ImportAddressTable
- if (!pe64) {
+ if (has_reloc) {
WriteRVA (text_map.GetRVA (TextSegment.ImportHintNameTable));
WriteRVA (0);
}
@@ -453,7 +457,7 @@ void WriteText ()
WriteDebugDirectory ();
}
- if (pe64)
+ if (!has_reloc)
return;
// ImportDirectory
@@ -696,7 +700,7 @@ TextMap BuildTextMap ()
map.AddMap (TextSegment.DebugDirectory, debug_dir_len, 4);
- if (pe64) {
+ if (!has_reloc) {
var start = map.GetNextRVA (TextSegment.DebugDirectory);
map.AddMap (TextSegment.ImportDirectory, new Range (start, 0));
map.AddMap (TextSegment.ImportHintNameTable, new Range (start, 0));
Please sign in to comment.
Something went wrong with that request. Please try again.