Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Side by Side Diff: chrome_elf/elf_imports_unittest.cc

Issue 974903002: Add ASan MD RTL to the list of valid imports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 #include <windows.h> 6 #include <windows.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 "target was built, instead of chrome_elf_unittests.exe"; 59 "target was built, instead of chrome_elf_unittests.exe";
60 60
61 std::vector<std::string>::iterator it(elf_imports.begin()); 61 std::vector<std::string>::iterator it(elf_imports.begin());
62 62
63 static const char* const kValidFilePatterns[] = { 63 static const char* const kValidFilePatterns[] = {
64 "KERNEL32.dll", 64 "KERNEL32.dll",
65 "MSVC*", 65 "MSVC*",
66 #if defined(SYZYASAN) 66 #if defined(SYZYASAN)
67 "syzyasan_rtl.dll", 67 "syzyasan_rtl.dll",
68 #endif 68 #endif
69 #if defined(ADDRESS_SANITIZER) && defined(COMPONENT_BUILD)
70 "clang_rt.asan_dynamic-i386.dll",
71 #endif
69 "ADVAPI32.dll" 72 "ADVAPI32.dll"
70 }; 73 };
71 74
72 // Make sure all of ELF's imports are in the valid imports list. 75 // Make sure all of ELF's imports are in the valid imports list.
73 for (; it != elf_imports.end(); it++) { 76 for (; it != elf_imports.end(); it++) {
74 bool match = false; 77 bool match = false;
75 for (int i = 0; i < arraysize(kValidFilePatterns); ++i) { 78 for (int i = 0; i < arraysize(kValidFilePatterns); ++i) {
76 if (MatchPattern(*it, kValidFilePatterns[i])) 79 if (MatchPattern(*it, kValidFilePatterns[i]))
77 match = true; 80 match = true;
78 } 81 }
79 ASSERT_TRUE(match) << "Illegal import in chrome_elf.dll."; 82 ASSERT_TRUE(match) << "Illegal import in chrome_elf.dll: " << *it;
80 } 83 }
81 } 84 }
82 85
83 TEST_F(ELFImportsTest, ChromeExeSanityCheck) { 86 TEST_F(ELFImportsTest, ChromeExeSanityCheck) {
84 std::vector<std::string> exe_imports; 87 std::vector<std::string> exe_imports;
85 88
86 base::FilePath exe; 89 base::FilePath exe;
87 ASSERT_TRUE(PathService::Get(base::DIR_EXE, &exe)); 90 ASSERT_TRUE(PathService::Get(base::DIR_EXE, &exe));
88 exe = exe.Append(L"chrome.exe"); 91 exe = exe.Append(L"chrome.exe");
89 GetImports(exe, &exe_imports); 92 GetImports(exe, &exe_imports);
90 93
91 // Check that chrome.exe has imports. 94 // Check that chrome.exe has imports.
92 ASSERT_LT(0u, exe_imports.size()) << "Ensure the chrome_elf_unittests " 95 ASSERT_LT(0u, exe_imports.size()) << "Ensure the chrome_elf_unittests "
93 "target was built, instead of chrome_elf_unittests.exe"; 96 "target was built, instead of chrome_elf_unittests.exe";
94 97
95 // Chrome.exe's first import must be ELF. 98 // Chrome.exe's first import must be ELF.
96 EXPECT_EQ("chrome_elf.dll", exe_imports[0]) << 99 EXPECT_EQ("chrome_elf.dll", exe_imports[0]) <<
97 "Illegal import order in chrome.exe (ensure the chrome_elf_unittest " 100 "Illegal import order in chrome.exe (ensure the chrome_elf_unittest "
98 "target was built, instead of just chrome_elf_unittests.exe)"; 101 "target was built, instead of just chrome_elf_unittests.exe)";
99 } 102 }
100 103
101 } // namespace 104 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698