diff options
-rw-r--r-- | chrome/chrome_exe.gypi | 8 | ||||
-rw-r--r-- | chrome_elf/chrome_elf.gyp | 1 | ||||
-rw-r--r-- | chrome_elf/elf_imports_unittest.cc | 95 |
3 files changed, 2 insertions, 102 deletions
diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi index 0c1f678..f694ae0 100644 --- a/chrome/chrome_exe.gypi +++ b/chrome/chrome_exe.gypi @@ -41,12 +41,6 @@ 'INFOPLIST_FILE': 'app/app-Info.plist', }, 'conditions': [ - ['OS == "win" ', { - 'dependencies': [ - # Note that chrome_elf must be listed first. Do not reorder it. - '../chrome_elf/chrome_elf.gyp:chrome_elf', - ], - }], ['component == "shared_library"', { 'variables': { 'win_use_external_manifest': 1, @@ -474,6 +468,8 @@ }], ['OS=="win"', { 'dependencies': [ + # Note that chrome_elf must be listed first. Do not reorder it. + '../chrome_elf/chrome_elf.gyp:chrome_elf', 'chrome_dll', 'chrome_nacl_win64', 'chrome_process_finder', diff --git a/chrome_elf/chrome_elf.gyp b/chrome_elf/chrome_elf.gyp index 60b4186d..7227fe6 100644 --- a/chrome_elf/chrome_elf.gyp +++ b/chrome_elf/chrome_elf.gyp @@ -45,7 +45,6 @@ 'type': 'executable', 'sources': [ 'blacklist/test/blacklist_test.cc', - 'elf_imports_unittest.cc', 'ntdll_cache_unittest.cc', ], 'include_dirs': [ diff --git a/chrome_elf/elf_imports_unittest.cc b/chrome_elf/elf_imports_unittest.cc deleted file mode 100644 index 5df401a..0000000 --- a/chrome_elf/elf_imports_unittest.cc +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <stdint.h> -#include <windows.h> - -#include <algorithm> -#include <vector> - -#include "base/base_paths.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/files/file_path.h" -#include "base/files/memory_mapped_file.h" -#include "base/path_service.h" -#include "base/strings/string_util.h" -#include "base/win/pe_image.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -class ELFImportsTest : public testing::Test { - protected: - static bool ImportsCallback(const base::win::PEImage &image, - LPCSTR module, - PIMAGE_THUNK_DATA name_table, - PIMAGE_THUNK_DATA iat, - PVOID cookie) { - std::vector<std::string>* import_list = - reinterpret_cast<std::vector<std::string>*>(cookie); - import_list->push_back(module); - return true; - } - - void GetImports(const base::FilePath& module_path, - std::vector<std::string>* imports) { - - ASSERT_TRUE(imports != NULL); - - base::MemoryMappedFile module_mmap; - - ASSERT_TRUE(module_mmap.Initialize(module_path)); - base::win::PEImageAsData pe_image_data( - reinterpret_cast<HMODULE>(const_cast<uint8*>(module_mmap.data()))); - pe_image_data.EnumImportChunks(ELFImportsTest::ImportsCallback, imports); - } -}; - -TEST_F(ELFImportsTest, ChromeElfSanityCheck) { - std::vector<std::string> elf_imports; - - base::FilePath dll; - ASSERT_TRUE(PathService::Get(base::DIR_EXE, &dll)); - dll = dll.Append(L"chrome_elf.dll"); - GetImports(dll, &elf_imports); - - // Check that ELF has imports. - ASSERT_LT(0u, elf_imports.size()); - - std::vector<std::string>::iterator it(elf_imports.begin()); - - static const char* const kValidFilePatterns[] = { - "KERNEL32.dll", - "MSVC*", - "ADVAPI32.dll"}; - - // Make sure all of ELF's imports are in the valid imports list. - for (; it != elf_imports.end(); it++) { - bool match = false; - for (int i = 0; i < arraysize(kValidFilePatterns); ++i) { - if (MatchPattern(*it, kValidFilePatterns[i])) - match = true; - } - ASSERT_TRUE(match) << "Illegal import in chrome_elf.dll."; - } -} - -TEST_F(ELFImportsTest, ChromeExeSanityCheck) { - std::vector<std::string> exe_imports; - - base::FilePath exe; - ASSERT_TRUE(PathService::Get(base::DIR_EXE, &exe)); - exe = exe.Append(L"chrome.exe"); - GetImports(exe, &exe_imports); - - // Check that chrome.exe has imports. - ASSERT_LT(0u, exe_imports.size()); - - // Chrome.exe's first import must be ELF. - EXPECT_EQ("chrome_elf.dll", exe_imports[0]) << - "Illegal import order in chrome.exe, see chrome_exe.gypi for details"; -} - -} // namespace |