Chromium Code Reviews| Index: chrome/nacl/nacl_helper_linux.cc |
| diff --git a/chrome/nacl/nacl_helper_linux.cc b/chrome/nacl/nacl_helper_linux.cc |
| index b943e2b24c6cf80ab6db7e7b332002a814fba09f..7598aa0f47a01a5c2166b41558ac0111f5a3dc54 100644 |
| --- a/chrome/nacl/nacl_helper_linux.cc |
| +++ b/chrome/nacl/nacl_helper_linux.cc |
| @@ -116,14 +116,33 @@ void HandleForkRequest(const std::vector<int>& child_fds) { |
| } // namespace |
| -int main(int argc, char *argv[]) { |
| +static const char* g_nacl_reserved_space = NULL; |
| +extern "C" __attribute__((visibility("default"))) |
| +const char* nacl_helper_get_1G_address() { |
|
Roland McGrath
2011/08/15 20:15:51
Might as well just be const void* (both the variab
Brad Chen
2011/08/15 23:02:28
Done.
|
| + return g_nacl_reserved_space; |
| +} |
| + |
| +// nacl_helper_init does the real work of this module. It is invoked as |
| +// a static constructor and never returns, preventing main() from the |
| +// nacl_helper_bootstrap program from being called. |
| +// |
| +// NOTE This routine must not return. |
| +extern "C" __attribute__((visibility("default"))) |
| +void nacl_helper_init(int argc, char *argv[], |
| + const char *nacl_reserved_space) { |
| CommandLine::Init(argc, argv); |
| base::AtExitManager exit_manager; |
| base::RandUint64(); // acquire /dev/urandom fd before sandbox is raised |
| std::vector<int> empty; // for SendMsg() calls |
| g_suid_sandbox_active = (NULL != getenv("SBX_D")); |
| - |
| + g_nacl_reserved_space = nacl_reserved_space; |
| + if (!nacl_reserved_space) { |
| + VLOG(1) << "nacl_reserved_space is NULL"; |
| + } else { |
| + VLOG(1) << "nacl_reserved_space is at " |
| + << (void *)nacl_reserved_space; |
| + } |
| // Send the zygote a message to let it know we are ready to help |
| if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor, |
| kNaClHelperStartupAck, |
| @@ -163,4 +182,12 @@ int main(int argc, char *argv[]) { |
| LOG(ERROR) << "*** send() to zygote failed"; |
| } |
| } |
| + CHECK(false); // This routine must not return |
| +} |
| + |
| +// This main() is used for testing, and to fool the linker into |
|
Roland McGrath
2011/08/15 20:15:51
main should go away since we're doing -shared link
Brad Chen
2011/08/15 23:02:28
Done.
|
| +// linking this module as an executable which helps make it small. |
| +int main(int argc, char *argv[]) { |
| + nacl_helper_init(argc, argv, NULL); |
| + assert(0); |
| } |