Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitek Karas <10670590+vitek-karas@users.noreply.github.com>2022-01-20 02:58:10 +0300
committerGitHub <noreply@github.com>2022-01-20 02:58:10 +0300
commit79b43e8e72866f450dee8b59510cb5767b1491ec (patch)
treed1f2230a0dff3f9f925bd4b85b45a3944256c3df /Mono.Cecil.PE
parent8b593d5fb0c5d7ead5636d59f77eed55689cbc40 (diff)
Fix deterministic MVID and add PdbChecksum (#810)
* Fix deterministic MVID and add PdbChecksum (#31) * Fix how pdb path is calculated in the tests * Fix portable PDB stamp in CodeView header (#32) * Introduce ISymbolWriter.Write This mostly cleans up the code to make it easier to understand. `ISymbolWriter.GetDebugHeader` no longer actually writes the symbols, there's a new `Write` method for just that. The assembly writer calls `Write` first and then the image writer calls `GetDebugHeader` when it's needed. This is partially taken from https://github.com/jbevain/cecil/pull/617.
Diffstat (limited to 'Mono.Cecil.PE')
-rw-r--r--Mono.Cecil.PE/ImageReader.cs5
-rw-r--r--Mono.Cecil.PE/ImageWriter.cs12
2 files changed, 12 insertions, 5 deletions
diff --git a/Mono.Cecil.PE/ImageReader.cs b/Mono.Cecil.PE/ImageReader.cs
index 5358129..a34e64d 100644
--- a/Mono.Cecil.PE/ImageReader.cs
+++ b/Mono.Cecil.PE/ImageReader.cs
@@ -27,6 +27,7 @@ namespace Mono.Cecil.PE {
DataDirectory metadata;
uint table_heap_offset;
+ uint pdb_heap_offset;
public ImageReader (Disposable<Stream> stream, string file_name)
: base (stream.value)
@@ -400,6 +401,7 @@ namespace Mono.Cecil.PE {
break;
case "#Pdb":
image.PdbHeap = new PdbHeap (data);
+ pdb_heap_offset = offset;
break;
}
}
@@ -768,7 +770,7 @@ namespace Mono.Cecil.PE {
}
}
- public static Image ReadPortablePdb (Disposable<Stream> stream, string file_name)
+ public static Image ReadPortablePdb (Disposable<Stream> stream, string file_name, out uint pdb_heap_offset)
{
try {
var reader = new ImageReader (stream, file_name);
@@ -785,6 +787,7 @@ namespace Mono.Cecil.PE {
reader.metadata = new DataDirectory (0, length);
reader.ReadMetadata ();
+ pdb_heap_offset = reader.pdb_heap_offset;
return reader.image;
} catch (EndOfStreamException e) {
throw new BadImageFormatException (stream.value.GetFileName (), e);
diff --git a/Mono.Cecil.PE/ImageWriter.cs b/Mono.Cecil.PE/ImageWriter.cs
index d6fb363..c2eb97a 100644
--- a/Mono.Cecil.PE/ImageWriter.cs
+++ b/Mono.Cecil.PE/ImageWriter.cs
@@ -48,6 +48,8 @@ namespace Mono.Cecil.PE {
ushort sections;
+ internal long debug_header_entries_position;
+
ImageWriter (ModuleDefinition module, string runtime_version, MetadataBuilder metadata, Disposable<Stream> stream, bool metadataOnly = false)
: base (stream.value)
{
@@ -64,7 +66,7 @@ namespace Mono.Cecil.PE {
this.GetDebugHeader ();
this.GetWin32Resources ();
this.BuildTextMap ();
- this.sections = (ushort) (has_reloc ? 2 : 1); // text + reloc?
+ this.sections = (ushort)(has_reloc ? 2 : 1); // text + reloc?
}
void GetDebugHeader ()
@@ -98,7 +100,7 @@ namespace Mono.Cecil.PE {
public static ImageWriter CreateWriter (ModuleDefinition module, MetadataBuilder metadata, Disposable<Stream> stream)
{
- var writer = new ImageWriter (module, module.runtime_version, metadata, stream);
+ var writer = new ImageWriter (module, module.runtime_version, metadata, stream, metadataOnly: false);
writer.BuildSections ();
return writer;
}
@@ -379,7 +381,7 @@ namespace Mono.Cecil.PE {
BaseStream.Seek (GetRVAFileOffset (section, rva), SeekOrigin.Begin);
}
- void MoveToRVA (TextSegment segment)
+ internal void MoveToRVA (TextSegment segment)
{
MoveToRVA (text, text_map.GetRVA (segment));
}
@@ -600,7 +602,9 @@ namespace Mono.Cecil.PE {
data_start += entry.Data.Length;
}
-
+
+ debug_header_entries_position = BaseStream.Position;
+
for (var i = 0; i < debug_header.Entries.Length; i++) {
var entry = debug_header.Entries [i];
WriteBytes (entry.Data);