| 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/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
| 9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
| 10 #include "native_client/src/include/elf_auxv.h" | 10 #include "native_client/src/include/elf_auxv.h" |
| 11 | 11 |
| 12 #if defined(OS_NACL_NONSFI) | 12 #if defined(OS_NACL_NONSFI) |
| 13 #include "native_client/src/public/nonsfi/elf_loader.h" | 13 #include "native_client/src/public/nonsfi/elf_loader.h" |
| 14 #include "ppapi/nacl_irt/irt_ppapi.h" | 14 #include "ppapi/nacl_irt/irt_ppapi.h" |
| 15 #else | 15 #else |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "components/nacl/loader/nonsfi/elf_loader.h" | 17 #include "components/nacl/loader/nonsfi/elf_loader.h" |
| 18 #include "components/nacl/loader/nonsfi/irt_interfaces.h" | 18 #include "components/nacl/loader/nonsfi/irt_interfaces.h" |
| 19 #include "native_client/src/include/nacl_macros.h" | 19 #include "native_client/src/include/nacl_macros.h" |
| 20 #include "native_client/src/trusted/desc/nacl_desc_base.h" | 20 #include "native_client/src/public/nacl_desc.h" |
| 21 #include "native_client/src/trusted/desc/nacl_desc_io.h" | |
| 22 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" | 21 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" |
| 23 #endif | 22 #endif |
| 24 | 23 |
| 25 namespace nacl { | 24 namespace nacl { |
| 26 namespace nonsfi { | 25 namespace nonsfi { |
| 27 namespace { | 26 namespace { |
| 28 | 27 |
| 29 typedef void (*EntryPointType)(uintptr_t*); | 28 typedef void (*EntryPointType)(uintptr_t*); |
| 30 | 29 |
| 31 class PluginMainDelegate : public base::PlatformThread::Delegate { | 30 class PluginMainDelegate : public base::PlatformThread::Delegate { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 #endif | 75 #endif |
| 77 | 76 |
| 78 } // namespace | 77 } // namespace |
| 79 | 78 |
| 80 void MainStart(int nexe_file) { | 79 void MainStart(int nexe_file) { |
| 81 #if defined(OS_NACL_NONSFI) | 80 #if defined(OS_NACL_NONSFI) |
| 82 EntryPointType entry_point = | 81 EntryPointType entry_point = |
| 83 reinterpret_cast<EntryPointType>(NaClLoadElfFile(nexe_file)); | 82 reinterpret_cast<EntryPointType>(NaClLoadElfFile(nexe_file)); |
| 84 #else | 83 #else |
| 85 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> desc( | 84 ::scoped_ptr<struct NaClDesc, NaClDescUnrefer> desc( |
| 86 NaClDescIoDescFromDescAllocCtor(nexe_file, NACL_ABI_O_RDONLY)); | 85 NaClDescIoMakeFromHandle(nexe_file, NACL_ABI_O_RDONLY)); |
| 87 ElfImage image; | 86 ElfImage image; |
| 88 if (image.Read(desc.get()) != LOAD_OK) { | 87 if (image.Read(desc.get()) != LOAD_OK) { |
| 89 LOG(ERROR) << "LoadModuleRpc: Failed to read binary."; | 88 LOG(ERROR) << "LoadModuleRpc: Failed to read binary."; |
| 90 return; | 89 return; |
| 91 } | 90 } |
| 92 | 91 |
| 93 if (image.Load(desc.get()) != LOAD_OK) { | 92 if (image.Load(desc.get()) != LOAD_OK) { |
| 94 LOG(ERROR) << "LoadModuleRpc: Failed to load the image"; | 93 LOG(ERROR) << "LoadModuleRpc: Failed to load the image"; |
| 95 return; | 94 return; |
| 96 } | 95 } |
| 97 | 96 |
| 98 EntryPointType entry_point = | 97 EntryPointType entry_point = |
| 99 reinterpret_cast<EntryPointType>(image.entry_point()); | 98 reinterpret_cast<EntryPointType>(image.entry_point()); |
| 100 #endif | 99 #endif |
| 101 if (!base::PlatformThread::CreateNonJoinable( | 100 if (!base::PlatformThread::CreateNonJoinable( |
| 102 kStackSize, new PluginMainDelegate(entry_point))) { | 101 kStackSize, new PluginMainDelegate(entry_point))) { |
| 103 LOG(ERROR) << "LoadModuleRpc: Failed to create plugin main thread."; | 102 LOG(ERROR) << "LoadModuleRpc: Failed to create plugin main thread."; |
| 104 return; | 103 return; |
| 105 } | 104 } |
| 106 } | 105 } |
| 107 | 106 |
| 108 } // namespace nonsfi | 107 } // namespace nonsfi |
| 109 } // namespace nacl | 108 } // namespace nacl |
| OLD | NEW |