Chromium Code Reviews| 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 // This is the Android-specific Chromium linker, a tiny shared library | 5 // This is the Android-specific Chromium linker, a tiny shared library |
| 6 // implementing a custom dynamic linker that can be used to load the | 6 // implementing a custom dynamic linker that can be used to load the |
| 7 // real Chromium libraries (e.g. libcontentshell.so). | 7 // real Chromium libraries (e.g. libcontentshell.so). |
| 8 | 8 |
| 9 // The main point of this linker is to be able to share the RELRO | 9 // The main point of this linker is to be able to share the RELRO |
| 10 // section of libcontentshell.so (or equivalent) between the browser and | 10 // section of libcontentshell.so (or equivalent) between the browser and |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 592 if (fd == -1) { | 592 if (fd == -1) { |
| 593 LOG_ERROR("%s: Failed to open %s\n", __FUNCTION__, apkfile_name_c_str); | 593 LOG_ERROR("%s: Failed to open %s\n", __FUNCTION__, apkfile_name_c_str); |
| 594 return false; | 594 return false; |
| 595 } | 595 } |
| 596 | 596 |
| 597 LOG_INFO( | 597 LOG_INFO( |
| 598 "%s: Memory mapping the first page of %s with executable permissions\n", | 598 "%s: Memory mapping the first page of %s with executable permissions\n", |
| 599 __FUNCTION__, apkfile_name_c_str); | 599 __FUNCTION__, apkfile_name_c_str); |
| 600 void* address = mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_PRIVATE, fd, 0); | 600 void* address = mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_PRIVATE, fd, 0); |
| 601 | 601 |
| 602 jboolean success; | 602 jboolean status; |
|
petrcermak
2014/10/20 13:11:49
Does it make sense to say that the current status
| |
| 603 if (address == MAP_FAILED) { | 603 if (address == MAP_FAILED) { |
| 604 success = false; | 604 status = false; |
| 605 } else { | 605 } else { |
| 606 success = true; | 606 status = true; |
| 607 munmap(address, PAGE_SIZE); | 607 munmap(address, PAGE_SIZE); |
| 608 } | 608 } |
| 609 | 609 |
| 610 close(fd); | 610 close(fd); |
| 611 | 611 |
| 612 LOG_INFO(" %ssupported\n", success ? "" : "NOT "); | 612 LOG_INFO("%s: %s\n", __FUNCTION__, status ? "Supported" : "NOT supported"); |
| 613 return success; | 613 return status; |
| 614 | |
| 615 } | 614 } |
| 616 | 615 |
| 617 const JNINativeMethod kNativeMethods[] = { | 616 const JNINativeMethod kNativeMethods[] = { |
| 618 {"nativeLoadLibrary", | 617 {"nativeLoadLibrary", |
| 619 "(" | 618 "(" |
| 620 "Ljava/lang/String;" | 619 "Ljava/lang/String;" |
| 621 "J" | 620 "J" |
| 622 "Lorg/chromium/base/library_loader/Linker$LibInfo;" | 621 "Lorg/chromium/base/library_loader/Linker$LibInfo;" |
| 623 ")" | 622 ")" |
| 624 "Z", | 623 "Z", |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 713 crazy_context_t* context = GetCrazyContext(); | 712 crazy_context_t* context = GetCrazyContext(); |
| 714 crazy_context_set_java_vm(context, vm, JNI_VERSION_1_4); | 713 crazy_context_set_java_vm(context, vm, JNI_VERSION_1_4); |
| 715 | 714 |
| 716 // Register the function that the crazy linker can call to post code | 715 // Register the function that the crazy linker can call to post code |
| 717 // for later execution. | 716 // for later execution. |
| 718 crazy_context_set_callback_poster(context, &PostForLaterExecution, NULL); | 717 crazy_context_set_callback_poster(context, &PostForLaterExecution, NULL); |
| 719 | 718 |
| 720 LOG_INFO("%s: Done", __FUNCTION__); | 719 LOG_INFO("%s: Done", __FUNCTION__); |
| 721 return JNI_VERSION_1_4; | 720 return JNI_VERSION_1_4; |
| 722 } | 721 } |
| OLD | NEW |