| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/nacl/loader/nonsfi/nonsfi_main.h" | 5 #include "components/nacl/loader/nonsfi/nonsfi_main.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| 11 #include "components/nacl/loader/nonsfi/elf_loader.h" | 11 #include "components/nacl/loader/nonsfi/elf_loader.h" |
| 12 #include "components/nacl/loader/nonsfi/irt_interfaces.h" | 12 #include "components/nacl/loader/nonsfi/irt_interfaces.h" |
| 13 #include "native_client/src/include/elf_auxv.h" | 13 #include "native_client/src/include/elf_auxv.h" |
| 14 #include "native_client/src/include/nacl_macros.h" | 14 #include "native_client/src/include/nacl_macros.h" |
| 15 #include "native_client/src/trusted/desc/nacl_desc_base.h" | 15 #include "native_client/src/trusted/desc/nacl_desc_base.h" |
| 16 #include "native_client/src/trusted/desc/nacl_desc_io.h" |
| 17 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" |
| 16 | 18 |
| 17 namespace nacl { | 19 namespace nacl { |
| 18 namespace nonsfi { | 20 namespace nonsfi { |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 typedef void (*EntryPointType)(uintptr_t*); | 23 typedef void (*EntryPointType)(uintptr_t*); |
| 22 | 24 |
| 23 class PluginMainDelegate : public base::PlatformThread::Delegate { | 25 class PluginMainDelegate : public base::PlatformThread::Delegate { |
| 24 public: | 26 public: |
| 25 explicit PluginMainDelegate(EntryPointType entry_point) | 27 explicit PluginMainDelegate(EntryPointType entry_point) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 const size_t kStackSize = (16 << 20); | 59 const size_t kStackSize = (16 << 20); |
| 58 | 60 |
| 59 struct NaClDescUnrefer { | 61 struct NaClDescUnrefer { |
| 60 void operator()(struct NaClDesc* desc) const { | 62 void operator()(struct NaClDesc* desc) const { |
| 61 NaClDescUnref(desc); | 63 NaClDescUnref(desc); |
| 62 } | 64 } |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 } // namespace | 67 } // namespace |
| 66 | 68 |
| 67 void MainStart(NaClDesc* nexe_file) { | 69 void MainStart(int nexe_file) { |
| 68 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> desc(nexe_file); | 70 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> desc( |
| 71 NaClDescIoDescFromDescAllocCtor(nexe_file, NACL_ABI_O_RDONLY)); |
| 69 ElfImage image; | 72 ElfImage image; |
| 70 if (image.Read(desc.get()) != LOAD_OK) { | 73 if (image.Read(desc.get()) != LOAD_OK) { |
| 71 LOG(ERROR) << "LoadModuleRpc: Failed to read binary."; | 74 LOG(ERROR) << "LoadModuleRpc: Failed to read binary."; |
| 72 return; | 75 return; |
| 73 } | 76 } |
| 74 | 77 |
| 75 if (image.Load(desc.get()) != LOAD_OK) { | 78 if (image.Load(desc.get()) != LOAD_OK) { |
| 76 LOG(ERROR) << "LoadModuleRpc: Failed to load the image"; | 79 LOG(ERROR) << "LoadModuleRpc: Failed to load the image"; |
| 77 return; | 80 return; |
| 78 } | 81 } |
| 79 | 82 |
| 80 EntryPointType entry_point = | 83 EntryPointType entry_point = |
| 81 reinterpret_cast<EntryPointType>(image.entry_point()); | 84 reinterpret_cast<EntryPointType>(image.entry_point()); |
| 82 if (!base::PlatformThread::CreateNonJoinable( | 85 if (!base::PlatformThread::CreateNonJoinable( |
| 83 kStackSize, new PluginMainDelegate(entry_point))) { | 86 kStackSize, new PluginMainDelegate(entry_point))) { |
| 84 LOG(ERROR) << "LoadModuleRpc: Failed to create plugin main thread."; | 87 LOG(ERROR) << "LoadModuleRpc: Failed to create plugin main thread."; |
| 85 return; | 88 return; |
| 86 } | 89 } |
| 87 } | 90 } |
| 88 | 91 |
| 89 } // namespace nonsfi | 92 } // namespace nonsfi |
| 90 } // namespace nacl | 93 } // namespace nacl |
| OLD | NEW |