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

Unified Diff: src/native_client/src/trusted/service_runtime/sel_ldr_standard.c

Issue 7068021: Dynamic loading: Fill pages with halts only when they are needed (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Fix log messages Created 9 years, 7 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
Index: src/native_client/src/trusted/service_runtime/sel_ldr_standard.c
diff --git a/src/native_client/src/trusted/service_runtime/sel_ldr_standard.c b/src/native_client/src/trusted/service_runtime/sel_ldr_standard.c
index 4788f6e05ea9a8dbc9dc4f01804de64b17cce92d..6b8400b361f476b5f6aac2727d8f7fd92fd74c92 100644
--- a/src/native_client/src/trusted/service_runtime/sel_ldr_standard.c
+++ b/src/native_client/src/trusted/service_runtime/sel_ldr_standard.c
@@ -322,6 +322,26 @@ NaClErrorCode NaClAppLoadFile(struct Gio *gp,
}
/*
+ * Make sure the static image pages are marked writable before we try
+ * to write them.
+ */
+ NaClLog(2, "Loading into memory\n");
+ ret = NaCl_mprotect((void *) (nap->mem_start + NACL_TRAMPOLINE_START),
+ NaClRoundAllocPage(nap->data_end) - NACL_TRAMPOLINE_START,
+ PROT_READ | PROT_WRITE);
+ if (0 != ret) {
+ NaClLog(LOG_FATAL,
+ "NaClAppLoadFile: Failed to make image pages writable. "
+ "Error code 0x%x\n",
+ ret);
+ }
+ subret = NaClElfImageLoad(image, gp, nap->addr_bits, nap->mem_start);
+ if (LOAD_OK != subret) {
+ ret = subret;
+ goto done;
+ }
+
+ /*
* NB: mem_map object has been initialized, but is empty.
* NaClMakeDynamicTextShared does not touch it.
*
@@ -380,24 +400,6 @@ NaClErrorCode NaClAppLoadFile(struct Gio *gp,
#endif
/*
- * Make sure the static image pages are marked writable before we try
- * to write them.
- */
- NaClLog(2, "Loading into memory\n");
- ret = NaCl_mprotect((void*) (nap->mem_start + NACL_TRAMPOLINE_START),
- NaClRoundAllocPage(nap->data_end) - NACL_TRAMPOLINE_START,
- PROT_READ|PROT_WRITE);
- if (ret) {
- NaClLog(LOG_FATAL, "Couldn't get writeable pages for image. "
- "Error code 0x%X\n", ret);
- }
- subret = NaClElfImageLoad(image, gp, nap->addr_bits, nap->mem_start);
- if (LOAD_OK != subret) {
- ret = subret;
- goto done;
- }
-
- /*
* NaClFillEndOfTextRegion will fill with halt instructions the
* padding space after the static text region.
*

Powered by Google App Engine
This is Rietveld 408576698