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

Unified Diff: chrome/browser/safe_browsing/incident_reporting/verifier_test/verifier_test_dll.cc

Issue 2327193002: Fix module verifier test by padding out DummyExport with 256 bytes of nops (Closed)
Patch Set: use macros Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/incident_reporting/verifier_test/verifier_test_dll.cc
diff --git a/chrome/browser/safe_browsing/incident_reporting/verifier_test/verifier_test_dll.cc b/chrome/browser/safe_browsing/incident_reporting/verifier_test/verifier_test_dll.cc
index 092c226908d042a2003047cbb760bd0ebe7da573..ee316935318df6afd4f1b4c0f97b22b3c8c89fa7 100644
--- a/chrome/browser/safe_browsing/incident_reporting/verifier_test/verifier_test_dll.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/verifier_test/verifier_test_dll.cc
@@ -5,21 +5,28 @@
// Some pointless code that will become a DLL with some exports and relocs.
#include <windows.h>
+#include <intrin.h>
namespace {
-void (*g_somestate)(int) = nullptr;
-volatile int g_somevalue = 0;
+void (*volatile g_somestate)() = nullptr;
} // namespace
-extern "C"
-void DummyExport(int foo) {
- // The test will patch the code of this function. Do a volatile store to a
- // global variable to defeat LLVM's dead store elimination and the linker's
- // ICF. Otherwise the code patch affects code run during DLL unloading.
+extern "C" void DummyExport() {
+ // Emit 256 bytes of nops because the test modifies up to 256 bytes of code.
+ // Use nops instead of volatile stores to avoid relocation entries in this
+ // region. One of the tests measures the number of modified bytes between
+ // relocations, and extra relocations will cause the test to fail.
// http://crbug.com/636157
- g_somevalue = foo;
+ // http://crbug.com/645544
+#define T4(x) x; x; x; x
+#define NOP4 T4(__nop());
+#define NOP16 T4(NOP4);
+#define NOP64 T4(NOP16);
+#define NOP256 T4(NOP64);
+ NOP256;
+ g_somestate = nullptr;
}
extern "C"
« 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