OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(HOST_OS_FUCHSIA) | 6 #if defined(HOST_OS_FUCHSIA) |
7 | 7 |
8 #include "bin/extensions.h" | 8 #include "bin/extensions.h" |
9 #include <dlfcn.h> // NOLINT | 9 |
| 10 #include <dlfcn.h> |
| 11 #include <launchpad/vmo.h> |
| 12 #include <magenta/dlfcn.h> |
10 | 13 |
11 #include "platform/assert.h" | 14 #include "platform/assert.h" |
12 | 15 |
13 namespace dart { | 16 namespace dart { |
14 namespace bin { | 17 namespace bin { |
15 | 18 |
16 const char* kVmSnapshotDataSymbolName = "_kDartVmSnapshotData"; | 19 const char* kVmSnapshotDataSymbolName = "_kDartVmSnapshotData"; |
17 const char* kVmSnapshotInstructionsSymbolName = "_kDartVmSnapshotInstructions"; | 20 const char* kVmSnapshotInstructionsSymbolName = "_kDartVmSnapshotInstructions"; |
18 const char* kIsolateSnapshotDataSymbolName = "_kDartIsolateSnapshotData"; | 21 const char* kIsolateSnapshotDataSymbolName = "_kDartIsolateSnapshotData"; |
19 const char* kIsolateSnapshotInstructionsSymbolName = | 22 const char* kIsolateSnapshotInstructionsSymbolName = |
20 "_kDartIsolateSnapshotInstructions"; | 23 "_kDartIsolateSnapshotInstructions"; |
21 | 24 |
22 void* Extensions::LoadExtensionLibrary(const char* library_file) { | 25 void* Extensions::LoadExtensionLibrary(const char* library_file) { |
23 return dlopen(library_file, RTLD_LAZY); | 26 mx_handle_t vmo = launchpad_vmo_from_file(library_file); |
| 27 if (vmo <= 0) { |
| 28 return NULL; |
| 29 } |
| 30 return dlopen_vmo(vmo, RTLD_LAZY); |
24 } | 31 } |
25 | 32 |
26 | 33 |
27 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { | 34 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { |
28 dlerror(); | 35 dlerror(); |
29 return dlsym(lib_handle, symbol); | 36 return dlsym(lib_handle, symbol); |
30 } | 37 } |
31 | 38 |
32 | 39 |
33 void Extensions::UnloadLibrary(void* lib_handle) { | 40 void Extensions::UnloadLibrary(void* lib_handle) { |
34 dlerror(); | 41 dlerror(); |
35 int result = dlclose(lib_handle); | 42 int result = dlclose(lib_handle); |
36 ASSERT(result == 0); | 43 ASSERT(result == 0); |
37 } | 44 } |
38 | 45 |
39 | 46 |
40 Dart_Handle Extensions::GetError() { | 47 Dart_Handle Extensions::GetError() { |
41 const char* err_str = dlerror(); | 48 const char* err_str = dlerror(); |
42 if (err_str != NULL) { | 49 if (err_str != NULL) { |
43 return Dart_NewApiError(err_str); | 50 return Dart_NewApiError(err_str); |
44 } | 51 } |
45 return Dart_Null(); | 52 return Dart_Null(); |
46 } | 53 } |
47 | 54 |
48 } // namespace bin | 55 } // namespace bin |
49 } // namespace dart | 56 } // namespace dart |
50 | 57 |
51 #endif // defined(HOST_OS_FUCHSIA) | 58 #endif // defined(HOST_OS_FUCHSIA) |
OLD | NEW |