diff options
author | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-11 23:16:30 +0000 |
---|---|---|
committer | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-11 23:16:30 +0000 |
commit | 2c68bf03d6980afc7d6efb33b6468ea74b416378 (patch) | |
tree | d0fe974faa5175dd053020cc8f6e03c961da8aa9 /chrome/browser/nacl_host | |
parent | 2f455515bf4477a86ac3fb8ca577ee9ecd05e2d6 (diff) | |
download | chromium_src-2c68bf03d6980afc7d6efb33b6468ea74b416378.zip chromium_src-2c68bf03d6980afc7d6efb33b6468ea74b416378.tar.gz chromium_src-2c68bf03d6980afc7d6efb33b6468ea74b416378.tar.bz2 |
NaCl: Implement CreateMemoryObject() to support dynamic loading on Mac
Since NaCl needs only one shared memory object that is mappable with
PROT_EXEC, we can take a short cut and pass one in at startup, saving
on IPC.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=583
TEST=test_runner.html with NaCl-side change applied, on a Mac
Review URL: http://codereview.chromium.org/4745001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65873 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/nacl_host')
-rw-r--r-- | chrome/browser/nacl_host/nacl_process_host.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc index b5123ef..8200892 100644 --- a/chrome/browser/nacl_host/nacl_process_host.cc +++ b/chrome/browser/nacl_host/nacl_process_host.cc @@ -248,11 +248,35 @@ void NaClProcessHost::SendStartMessage() { #else nacl::FileDescriptor channel; channel.fd = dup(sockets_for_sel_ldr_[i]); + if (channel.fd < 0) { + LOG(ERROR) << "Failed to dup() a file descriptor"; + return; + } channel.auto_close = true; handles_for_sel_ldr.push_back(channel); #endif } +#if defined(OS_MACOSX) + // For dynamic loading support, NaCl requires a file descriptor that + // was created in /tmp, since those created with shm_open() are not + // mappable with PROT_EXEC. Rather than requiring an extra IPC + // round trip out of the sandbox, we create an FD here. + base::SharedMemory memory_buffer; + if (!memory_buffer.CreateAnonymous(/* size= */ 1)) { + LOG(ERROR) << "Failed to allocate memory buffer"; + return; + } + nacl::FileDescriptor memory_fd; + memory_fd.fd = dup(memory_buffer.handle().fd); + if (memory_fd.fd < 0) { + LOG(ERROR) << "Failed to dup() a file descriptor"; + return; + } + memory_fd.auto_close = true; + handles_for_sel_ldr.push_back(memory_fd); +#endif + Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); sockets_for_sel_ldr_.clear(); } |