Commit 732841e7 authored by Richard Townsend's avatar Richard Townsend Committed by Commit Bot

fix: PEImage support for Windows on Arm

Checks in the arm64 variant of the test DLL. Values in the unit test
have been updated using the output from dumpbin.

Bug: 925584, 893460
Change-Id: Iab41f94283d88d39a986ca100c9538b4ba61228f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1599594Reviewed-by: default avatarBruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Richard Townsend <richard.townsend@arm.com>
Cr-Commit-Position: refs/heads/master@{#659146}
parent 52d8ec7a
...@@ -88,18 +88,41 @@ bool ExportsCallback(const PEImage& image, ...@@ -88,18 +88,41 @@ bool ExportsCallback(const PEImage& image,
return true; return true;
} }
base::FilePath GetPEImageTestPath() {
base::FilePath pe_image_test_path;
EXPECT_TRUE(PathService::Get(DIR_TEST_DATA, &pe_image_test_path));
pe_image_test_path = pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image"));
#if defined(ARCH_CPU_ARM64)
pe_image_test_path =
pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image_test_arm64.dll"));
#elif defined(ARCH_CPU_X86_64)
pe_image_test_path =
pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image_test_64.dll"));
#elif defined(ARCH_CPU_X86)
pe_image_test_path =
pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image_test_32.dll"));
#else
#error This platform is not supported.
#endif
return pe_image_test_path;
}
} // namespace } // namespace
// Tests that we are able to enumerate stuff from a PE file, and that // Tests that we are able to enumerate stuff from a PE file, and that
// the actual number of items found matches an expected value. // the actual number of items found matches an expected value.
TEST(PEImageTest, EnumeratesPE) { TEST(PEImageTest, EnumeratesPE) {
base::FilePath pe_image_test_path; base::FilePath pe_image_test_path = GetPEImageTestPath();
ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &pe_image_test_path));
pe_image_test_path = pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image"));
#if defined(ARCH_CPU_64_BITS) #if defined(ARCH_CPU_ARM64)
pe_image_test_path = const int sections = 7;
pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image_test_64.dll")); const int imports_dlls = 3;
const int delay_dlls = 2;
const int exports = 3;
const int imports = 72;
const int delay_imports = 2;
const int relocs = 740;
#elif defined(ARCH_CPU_64_BITS)
const int sections = 6; const int sections = 6;
const int imports_dlls = 2; const int imports_dlls = 2;
const int delay_dlls = 2; const int delay_dlls = 2;
...@@ -108,8 +131,6 @@ TEST(PEImageTest, EnumeratesPE) { ...@@ -108,8 +131,6 @@ TEST(PEImageTest, EnumeratesPE) {
const int delay_imports = 2; const int delay_imports = 2;
const int relocs = 976; const int relocs = 976;
#else #else
pe_image_test_path =
pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image_test_32.dll"));
const int sections = 5; const int sections = 5;
const int imports_dlls = 2; const int imports_dlls = 2;
const int delay_dlls = 2; const int delay_dlls = 2;
...@@ -173,17 +194,7 @@ TEST(PEImageTest, RetrievesExports) { ...@@ -173,17 +194,7 @@ TEST(PEImageTest, RetrievesExports) {
// Tests that we can locate a forwarded export. // Tests that we can locate a forwarded export.
TEST(PEImageTest, ForwardedExport) { TEST(PEImageTest, ForwardedExport) {
base::FilePath pe_image_test_path; base::FilePath pe_image_test_path = GetPEImageTestPath();
ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &pe_image_test_path));
pe_image_test_path = pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image"));
#if defined(ARCH_CPU_64_BITS)
pe_image_test_path =
pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image_test_64.dll"));
#else
pe_image_test_path =
pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image_test_32.dll"));
#endif
ScopedNativeLibrary module(pe_image_test_path); ScopedNativeLibrary module(pe_image_test_path);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment