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 // Implements the crazy linker C-based API exposed by <crazy_linker.h> | 5 // Implements the crazy linker C-based API exposed by <crazy_linker.h> |
6 | 6 |
7 #include <crazy_linker.h> | 7 #include <crazy_linker.h> |
8 | 8 |
9 #include <limits.h> | |
9 #include <string.h> | 10 #include <string.h> |
10 | 11 |
11 #include "crazy_linker_error.h" | 12 #include "crazy_linker_error.h" |
12 #include "crazy_linker_ashmem.h" | 13 #include "crazy_linker_ashmem.h" |
13 #include "crazy_linker_globals.h" | 14 #include "crazy_linker_globals.h" |
14 #include "crazy_linker_proc_maps.h" | 15 #include "crazy_linker_proc_maps.h" |
15 #include "crazy_linker_search_path_list.h" | 16 #include "crazy_linker_search_path_list.h" |
16 #include "crazy_linker_shared_library.h" | 17 #include "crazy_linker_shared_library.h" |
17 #include "crazy_linker_thread.h" | 18 #include "crazy_linker_thread.h" |
18 #include "crazy_linker_util.h" | 19 #include "crazy_linker_util.h" |
19 #include "crazy_linker_library_view.h" | 20 #include "crazy_linker_library_view.h" |
20 #include "crazy_linker_system.h" | 21 #include "crazy_linker_system.h" |
21 | 22 |
22 using crazy::Globals; | 23 using crazy::Globals; |
23 using crazy::Error; | 24 using crazy::Error; |
24 using crazy::SearchPathList; | 25 using crazy::SearchPathList; |
25 using crazy::ScopedGlobalLock; | 26 using crazy::ScopedGlobalLock; |
26 using crazy::LibraryView; | 27 using crazy::LibraryView; |
28 using crazy::FileDescriptor; | |
27 | 29 |
28 // | 30 // |
29 // crazy_context_t | 31 // crazy_context_t |
30 // | 32 // |
31 | 33 |
32 struct crazy_context_t { | 34 struct crazy_context_t { |
33 public: | 35 public: |
34 crazy_context_t() | 36 crazy_context_t() |
35 : load_address(0), | 37 : load_address(0), |
36 file_offset(0), | 38 file_offset(0), |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 crazy_context_t* context) { | 382 crazy_context_t* context) { |
381 if (library) { | 383 if (library) { |
382 ScopedDelayedCallbackPoster poster(context); | 384 ScopedDelayedCallbackPoster poster(context); |
383 ScopedGlobalLock lock; | 385 ScopedGlobalLock lock; |
384 LibraryView* wrap = reinterpret_cast<LibraryView*>(library); | 386 LibraryView* wrap = reinterpret_cast<LibraryView*>(library); |
385 | 387 |
386 Globals::GetLibraries()->UnloadLibrary(wrap); | 388 Globals::GetLibraries()->UnloadLibrary(wrap); |
387 } | 389 } |
388 } | 390 } |
389 | 391 |
392 crazy_status_t crazy_linker_test_load_from_apk(const char* apkfile_name) { | |
393 FileDescriptor fd(apkfile_name); | |
394 | |
395 LOG("%s: Memory mapping the first page of %s\n", __FUNCTION__, apkfile_name); | |
396 void* address = fd.Map(NULL, PAGE_SIZE, PROT_EXEC, MAP_PRIVATE, 0); | |
397 | |
398 crazy_status_t status = CRAZY_STATUS_FAILURE; | |
399 if (address != MAP_FAILED) { | |
400 status = CRAZY_STATUS_SUCCESS; | |
401 munmap(address, PAGE_SIZE); | |
402 } | |
picksi1
2014/10/10 10:52:18
I think this would be clearer is we swapped the if
petrcermak
2014/10/10 14:20:14
Done.
| |
403 | |
404 LOG(" %s\n", status == CRAZY_STATUS_SUCCESS ? "supported" : "NOT supported"); | |
405 return status; | |
406 } | |
407 | |
390 } // extern "C" | 408 } // extern "C" |
OLD | NEW |