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

Unified Diff: ports/nacl-spawn/nacl_spawn.cc

Issue 1553053002: Update pnacl toolchain build (Closed) Base URL: https://chromium.googlesource.com/webports.git@master
Patch Set: Created 4 years, 11 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 | « ports/nacl-spawn/library_dependencies.cc ('k') | ports/pkg/nacl.patch » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ports/nacl-spawn/nacl_spawn.cc
diff --git a/ports/nacl-spawn/nacl_spawn.cc b/ports/nacl-spawn/nacl_spawn.cc
index a2915f74a4e9eea06a2f0f9b86158ff0da831e13..59cd9a955dc0b8af195414c7a093b9e8601cf245 100644
--- a/ports/nacl-spawn/nacl_spawn.cc
+++ b/ports/nacl-spawn/nacl_spawn.cc
@@ -240,13 +240,10 @@ static bool UseBuiltInFallback(std::string* prog, struct PP_Var req_var) {
return false;
}
-// Check if a file is a pnacl type file.
-// If the file can't be read, return false.
-static bool IsPNaClType(const std::string& filename) {
- // Open script.
+static bool CheckFileMagic(const std::string& filename,
+ const std::string& magic) {
int fh = open(filename.c_str(), O_RDONLY);
if (fh < 0) {
- // Default to nacl type if the file can't be read.
return false;
}
// Read first 4 bytes.
@@ -254,7 +251,17 @@ static bool IsPNaClType(const std::string& filename) {
ssize_t len = read(fh, buffer, sizeof buffer);
close(fh);
// Decide based on the header.
- return len == 4 && memcmp(buffer, "PEXE", sizeof buffer) == 0;
+ return len == 4 && memcmp(buffer, magic.c_str(), sizeof buffer) == 0;
+}
+
+// Check if a file contains finalised PNaCl bitcode
+static bool IsPNaClType(const std::string& filename) {
+ return CheckFileMagic(filename, "PEXE");
+}
+
+// Check if a file contains LLVM bitcode
+static bool IsBitcode(const std::string& filename) {
+ return CheckFileMagic(filename, "BC\xc0\xde");
}
// Adds a NMF to the request if |prog| is stored in HTML5 filesystem.
@@ -276,12 +283,23 @@ static bool AddNmfToRequest(std::string prog, struct PP_Var req_var) {
return true;
}
+ bool debug = getenv("LD_DEBUG") != NULL;
+
// Check for pnacl.
if (IsPNaClType(prog)) {
+ if (debug) {
+ fprintf(stderr, "%s: loading PNaCl bitcode: %s\n",
+ LOADER_NAME, prog.c_str());
+ }
AddNmfToRequestForPNaCl(prog, req_var);
return true;
}
+ if (IsBitcode(prog)) {
+ fprintf(stderr, "%s: cannot execute unfinalized bitcode\n", prog.c_str());
+ return false;
+ }
+
std::string arch;
std::vector<std::string> dependencies;
if (!nspawn_find_arch_and_library_deps(prog, &arch, &dependencies))
« no previous file with comments | « ports/nacl-spawn/library_dependencies.cc ('k') | ports/pkg/nacl.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698