summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2018-03-06 16:37:51 -0800
committerGitHub <noreply@github.com>2018-03-06 16:37:51 -0800
commit47bef69b68a35eafa069d08187727684a5f47901 (patch)
tree2fd0158bbc56718f43d0a9666c7223b7b2d94b9d
parent964fa6861dab06933d3983671ce90c8bf96690f7 (diff)
downloadcoreclr-47bef69b68a35eafa069d08187727684a5f47901.tar.gz
coreclr-47bef69b68a35eafa069d08187727684a5f47901.tar.bz2
coreclr-47bef69b68a35eafa069d08187727684a5f47901.zip
Revert "Fix handling of incorrect assemblies on Unix (#16747)" (#16790)
This reverts commit 383736b96b643ba46ad290fc86601fc2d62a9436.
-rw-r--r--src/debug/daccess/nidump.cpp2
-rw-r--r--src/inc/pedecoder.h2
-rw-r--r--src/inc/pedecoder.inl2
-rw-r--r--src/utilcode/pedecoder.cpp3
-rw-r--r--src/vm/peimage.cpp7
-rw-r--r--tests/src/Loader/regressions/GitHub_15544/main.cs37
-rw-r--r--tests/src/Loader/regressions/GitHub_15544/main.csproj31
7 files changed, 7 insertions, 77 deletions
diff --git a/src/debug/daccess/nidump.cpp b/src/debug/daccess/nidump.cpp
index e948687c0e..45320dca7f 100644
--- a/src/debug/daccess/nidump.cpp
+++ b/src/debug/daccess/nidump.cpp
@@ -720,7 +720,7 @@ NativeImageDumper::DumpNativeImage()
for (COUNT_T i = 0; i < m_decoder.GetNumberOfSections(); i++)
{
- PTR_IMAGE_SECTION_HEADER section = m_decoder.FindFirstSection() + i;
+ PTR_IMAGE_SECTION_HEADER section = dptr_add(m_decoder.FindFirstSection(), i);
m_display->Section(reinterpret_cast<char *>(section->Name),
section->VirtualAddress,
section->SizeOfRawData);
diff --git a/src/inc/pedecoder.h b/src/inc/pedecoder.h
index 8163ffff35..01375e6d88 100644
--- a/src/inc/pedecoder.h
+++ b/src/inc/pedecoder.h
@@ -182,7 +182,7 @@ class PEDecoder
UINT32 GetWin32VersionValue() const;
COUNT_T GetNumberOfRvaAndSizes() const;
COUNT_T GetNumberOfSections() const;
- PTR_IMAGE_SECTION_HEADER FindFirstSection() const;
+ IMAGE_SECTION_HEADER *FindFirstSection() const;
IMAGE_SECTION_HEADER *FindSection(LPCSTR sectionName) const;
DWORD GetImageIdentity() const;
diff --git a/src/inc/pedecoder.inl b/src/inc/pedecoder.inl
index c8400af46a..7f3c79ba59 100644
--- a/src/inc/pedecoder.inl
+++ b/src/inc/pedecoder.inl
@@ -1178,7 +1178,7 @@ inline DWORD PEDecoder::GetImageIdentity() const
}
-inline PTR_IMAGE_SECTION_HEADER PEDecoder::FindFirstSection() const
+inline IMAGE_SECTION_HEADER *PEDecoder::FindFirstSection() const
{
CONTRACT(IMAGE_SECTION_HEADER *)
{
diff --git a/src/utilcode/pedecoder.cpp b/src/utilcode/pedecoder.cpp
index e5e8ddce67..ddd65d390d 100644
--- a/src/utilcode/pedecoder.cpp
+++ b/src/utilcode/pedecoder.cpp
@@ -445,7 +445,6 @@ BOOL PEDecoder::HasWriteableSections() const
CONTRACT_CHECK
{
INSTANCE_CHECK;
- PRECONDITION(CheckNTHeaders());
PRECONDITION(CheckFormat());
NOTHROW;
GC_NOTRIGGER;
@@ -454,7 +453,7 @@ BOOL PEDecoder::HasWriteableSections() const
}
CONTRACT_CHECK_END;
- PTR_IMAGE_SECTION_HEADER pSection = FindFirstSection();
+ PTR_IMAGE_SECTION_HEADER pSection = FindFirstSection(FindNTHeaders());
_ASSERTE(pSection != NULL);
PTR_IMAGE_SECTION_HEADER pSectionEnd = pSection + VAL16(FindNTHeaders()->FileHeader.NumberOfSections);
diff --git a/src/vm/peimage.cpp b/src/vm/peimage.cpp
index 83989f0e4d..3536b08361 100644
--- a/src/vm/peimage.cpp
+++ b/src/vm/peimage.cpp
@@ -1029,9 +1029,7 @@ PTR_PEImageLayout PEImage::CreateLayoutFlat(BOOL bPermitWriteableSections)
PTR_PEImageLayout pFlatLayout = PEImageLayout::LoadFlat(GetFileHandle(),this);
- if (!bPermitWriteableSections
- && pFlatLayout->CheckNTHeaders()
- && pFlatLayout->HasWriteableSections())
+ if (!bPermitWriteableSections && pFlatLayout->HasWriteableSections())
{
pFlatLayout->Release();
@@ -1116,7 +1114,8 @@ void PEImage::Load()
#ifdef PLATFORM_UNIX
if (m_pLayouts[IMAGE_FLAT] != NULL
- && m_pLayouts[IMAGE_FLAT]->CheckILOnlyFormat()
+ && m_pLayouts[IMAGE_FLAT]->CheckFormat()
+ && m_pLayouts[IMAGE_FLAT]->IsILOnly()
&& !m_pLayouts[IMAGE_FLAT]->HasWriteableSections())
{
// IL-only images with writeable sections are mapped in general way,
diff --git a/tests/src/Loader/regressions/GitHub_15544/main.cs b/tests/src/Loader/regressions/GitHub_15544/main.cs
deleted file mode 100644
index 25e7d79e41..0000000000
--- a/tests/src/Loader/regressions/GitHub_15544/main.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-using System;
-using System.IO;
-using System.Reflection;
-
-public class CMain{
- public static int Main(String[] args) {
- string tempFileName = Path.GetTempFileName();
-
- bool isThrown = false;
-
- try
- {
- AssemblyName.GetAssemblyName(tempFileName);
- }
- catch (BadImageFormatException)
- {
- isThrown = true;
- }
-
- File.Delete(tempFileName);
-
- if (isThrown) {
- Console.WriteLine("PASS");
-
- return 100;
- } else {
- Console.WriteLine("FAIL");
-
- return 101;
- }
- }
-}
diff --git a/tests/src/Loader/regressions/GitHub_15544/main.csproj b/tests/src/Loader/regressions/GitHub_15544/main.csproj
deleted file mode 100644
index e46a44ce52..0000000000
--- a/tests/src/Loader/regressions/GitHub_15544/main.csproj
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{AC75380E-F196-4F32-9BCF-F0589AF864E6}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="main.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- </ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
-</Project>