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:
authorAlexander Köplinger <alex.koeplinger@outlook.com>2021-07-26 22:40:39 +0300
committerGitHub <noreply@github.com>2021-07-26 22:40:39 +0300
commit3bef7fc7b7910f826790ebfeccb381b76a650571 (patch)
treed3e853251ce50b709b4a3130ad812a32d228837b
parenta27b1fb8b08d412fbed56a053a5c0872ed9dba25 (diff)
parent2f1077d7bb3527c3d821cb726a6d762abaea101a (diff)
Merge pull request #30 from jbevain/master
Bring in latest changes from upstream
-rw-r--r--Directory.Build.props2
-rw-r--r--Mono.Cecil.PE/Image.cs3
-rw-r--r--Mono.Cecil.PE/ImageReader.cs3
-rw-r--r--Mono.Cecil.PE/ImageWriter.cs12
-rw-r--r--Mono.Cecil.nuspec2
-rw-r--r--Mono.Cecil/AssemblyReader.cs4
-rw-r--r--Mono.Cecil/ModuleDefinition.cs2
-rw-r--r--ProjectInfo.cs6
-rw-r--r--Test/Mono.Cecil.Tests/ImageReadTests.cs8
-rw-r--r--Test/Mono.Cecil.Tests/PortablePdbTests.cs17
-rw-r--r--Test/Resources/assemblies/anycpu32bitpreferred.exebin0 -> 3584 bytes
-rw-r--r--Test/Resources/assemblies/empty-str-const.exebin0 -> 4096 bytes
-rw-r--r--Test/Resources/assemblies/empty-str-const.pdbbin0 -> 2668 bytes
13 files changed, 47 insertions, 12 deletions
diff --git a/Directory.Build.props b/Directory.Build.props
index 292c0a1..cb10f01 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -14,7 +14,7 @@
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
- <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net40" Version="1.0.0" />
+ <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net40" Version="1.0.2" />
</ItemGroup>
<ItemGroup Condition="'$(MonoBuild)' != ''">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
diff --git a/Mono.Cecil.PE/Image.cs b/Mono.Cecil.PE/Image.cs
index 1092061..97e69c0 100644
--- a/Mono.Cecil.PE/Image.cs
+++ b/Mono.Cecil.PE/Image.cs
@@ -25,9 +25,10 @@ namespace Mono.Cecil.PE {
public string FileName;
public ModuleKind Kind;
+ public uint Characteristics;
public string RuntimeVersion;
public TargetArchitecture Architecture;
- public ModuleCharacteristics Characteristics;
+ public ModuleCharacteristics DllCharacteristics;
public ushort LinkerVersion;
public ushort SubSystemMajor;
public ushort SubSystemMinor;
diff --git a/Mono.Cecil.PE/ImageReader.cs b/Mono.Cecil.PE/ImageReader.cs
index 84fdeb6..5358129 100644
--- a/Mono.Cecil.PE/ImageReader.cs
+++ b/Mono.Cecil.PE/ImageReader.cs
@@ -88,8 +88,9 @@ namespace Mono.Cecil.PE {
ReadMetadata ();
ReadDebugHeader ();
+ image.Characteristics = characteristics;
image.Kind = GetModuleKind (characteristics, subsystem);
- image.Characteristics = (ModuleCharacteristics) dll_characteristics;
+ image.DllCharacteristics = (ModuleCharacteristics) dll_characteristics;
}
TargetArchitecture ReadArchitecture ()
diff --git a/Mono.Cecil.PE/ImageWriter.cs b/Mono.Cecil.PE/ImageWriter.cs
index 7e5e923..a8a3fa8 100644
--- a/Mono.Cecil.PE/ImageWriter.cs
+++ b/Mono.Cecil.PE/ImageWriter.cs
@@ -194,12 +194,18 @@ namespace Mono.Cecil.PE {
WriteUInt32 (metadata.timestamp);
WriteUInt32 (0); // PointerToSymbolTable
WriteUInt32 (0); // NumberOfSymbols
- WriteUInt16 (SizeOfOptionalHeader ()); // SizeOfOptionalHeader
+ WriteUInt16 (SizeOfOptionalHeader ()); // SizeOfOptionalHeader
- // ExecutableImage | (pe64 ? 32BitsMachine : LargeAddressAware)
- var characteristics = (ushort) (0x0002 | (!pe64 ? 0x0100 : 0x0020));
+ const ushort LargeAddressAware = 0x0020;
+
+ // ExecutableImage | (!pe64 ? 32BitsMachine : LargeAddressAware)
+ var characteristics = (ushort) (0x0002 | (!pe64 ? 0x0100 : LargeAddressAware));
if (module.Kind == ModuleKind.Dll || module.Kind == ModuleKind.NetModule)
characteristics |= 0x2000;
+
+ if (module.Image != null && (module.Image.Characteristics & LargeAddressAware) != 0)
+ characteristics |= LargeAddressAware;
+
WriteUInt16 (characteristics); // Characteristics
}
diff --git a/Mono.Cecil.nuspec b/Mono.Cecil.nuspec
index 7a59bce..626c5ac 100644
--- a/Mono.Cecil.nuspec
+++ b/Mono.Cecil.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Mono.Cecil</id>
- <version>0.11.3.0</version>
+ <version>0.11.4.0</version>
<title>Mono.Cecil</title>
<authors>Jb Evain</authors>
<owners>Jb Evain</owners>
diff --git a/Mono.Cecil/AssemblyReader.cs b/Mono.Cecil/AssemblyReader.cs
index 9fdcf68..b66c162 100644
--- a/Mono.Cecil/AssemblyReader.cs
+++ b/Mono.Cecil/AssemblyReader.cs
@@ -3005,7 +3005,9 @@ namespace Mono.Cecil {
object value;
if (type.etype == ElementType.String) {
- if (signature.buffer [signature.position] != 0xff) {
+ if (!signature.CanReadMore ())
+ value = "";
+ else if (signature.buffer [signature.position] != 0xff) {
var bytes = signature.ReadBytes ((int) (signature.sig_length - (signature.position - signature.start)));
value = Encoding.Unicode.GetString (bytes, 0, bytes.Length);
} else
diff --git a/Mono.Cecil/ModuleDefinition.cs b/Mono.Cecil/ModuleDefinition.cs
index fce2777..84cd969 100644
--- a/Mono.Cecil/ModuleDefinition.cs
+++ b/Mono.Cecil/ModuleDefinition.cs
@@ -615,7 +615,7 @@ namespace Mono.Cecil {
this.RuntimeVersion = image.RuntimeVersion;
this.architecture = image.Architecture;
this.attributes = image.Attributes;
- this.characteristics = image.Characteristics;
+ this.characteristics = image.DllCharacteristics;
this.linker_version = image.LinkerVersion;
this.subsystem_major = image.SubSystemMajor;
this.subsystem_minor = image.SubSystemMinor;
diff --git a/ProjectInfo.cs b/ProjectInfo.cs
index 57fdb1f..fe89134 100644
--- a/ProjectInfo.cs
+++ b/ProjectInfo.cs
@@ -15,6 +15,6 @@ using System.Runtime.InteropServices;
[assembly: ComVisible (false)]
-[assembly: AssemblyVersion ("0.11.3.0")]
-[assembly: AssemblyFileVersion ("0.11.3.0")]
-[assembly: AssemblyInformationalVersion ("0.11.3.0")]
+[assembly: AssemblyVersion ("0.11.4.0")]
+[assembly: AssemblyFileVersion ("0.11.4.0")]
+[assembly: AssemblyInformationalVersion ("0.11.4.0")]
diff --git a/Test/Mono.Cecil.Tests/ImageReadTests.cs b/Test/Mono.Cecil.Tests/ImageReadTests.cs
index de7a2cc..ef6ab06 100644
--- a/Test/Mono.Cecil.Tests/ImageReadTests.cs
+++ b/Test/Mono.Cecil.Tests/ImageReadTests.cs
@@ -101,6 +101,14 @@ namespace Mono.Cecil.Tests {
}
[Test]
+ public void AnyCPU32BitPreferred ()
+ {
+ TestModule ("anycpu32bitpreferred.exe", module => {
+ Assert.AreNotEqual (0, module.Image.Characteristics & 0x0020);
+ });
+ }
+
+ [Test]
public void X64ModuleTextOnlySection ()
{
TestModule ("hello.textonly.x64.exe", module => {
diff --git a/Test/Mono.Cecil.Tests/PortablePdbTests.cs b/Test/Mono.Cecil.Tests/PortablePdbTests.cs
index 43b8cfe..d9786cb 100644
--- a/Test/Mono.Cecil.Tests/PortablePdbTests.cs
+++ b/Test/Mono.Cecil.Tests/PortablePdbTests.cs
@@ -475,6 +475,23 @@ namespace Mono.Cecil.Tests {
}
[Test]
+ public void EmptyStringLocalConstant ()
+ {
+ TestModule ("empty-str-const.exe", module => {
+ var type = module.GetType ("<Program>$");
+ var method = type.GetMethod ("<Main>$");
+ var symbol = method.DebugInformation;
+
+ Assert.IsNotNull (symbol);
+ Assert.AreEqual (1, symbol.Scope.Constants.Count);
+
+ var a = symbol.Scope.Constants [0];
+ Assert.AreEqual ("value", a.Name);
+ Assert.AreEqual ("", a.Value);
+ }, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider));
+ }
+
+ [Test]
public void SourceLink ()
{
TestModule ("TargetLib.dll", module => {
diff --git a/Test/Resources/assemblies/anycpu32bitpreferred.exe b/Test/Resources/assemblies/anycpu32bitpreferred.exe
new file mode 100644
index 0000000..e758a7f
--- /dev/null
+++ b/Test/Resources/assemblies/anycpu32bitpreferred.exe
Binary files differ
diff --git a/Test/Resources/assemblies/empty-str-const.exe b/Test/Resources/assemblies/empty-str-const.exe
new file mode 100644
index 0000000..6cc5128
--- /dev/null
+++ b/Test/Resources/assemblies/empty-str-const.exe
Binary files differ
diff --git a/Test/Resources/assemblies/empty-str-const.pdb b/Test/Resources/assemblies/empty-str-const.pdb
new file mode 100644
index 0000000..723ec4e
--- /dev/null
+++ b/Test/Resources/assemblies/empty-str-const.pdb
Binary files differ