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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 library_name, | 290 library_name, |
291 crazy_context_get_error(context)); | 291 crazy_context_get_error(context)); |
292 return false; | 292 return false; |
293 } | 293 } |
294 return true; | 294 return true; |
295 } | 295 } |
296 | 296 |
297 // Used for opening the library in a zip file. | 297 // Used for opening the library in a zip file. |
298 class ZipLibraryOpener { | 298 class ZipLibraryOpener { |
299 public: | 299 public: |
300 ZipLibraryOpener(const char* zip_file) : zip_file_(zip_file) {} | 300 explicit ZipLibraryOpener(const char* zip_file) : zip_file_(zip_file) {} |
301 bool Open( | 301 bool Open( |
302 crazy_library_t** library, | 302 crazy_library_t** library, |
303 const char* library_name, | 303 const char* library_name, |
304 crazy_context_t* context) const; | 304 crazy_context_t* context) const; |
305 private: | 305 private: |
306 const char* zip_file_; | 306 const char* zip_file_; |
307 }; | 307 }; |
308 | 308 |
309 bool ZipLibraryOpener::Open( | 309 bool ZipLibraryOpener::Open( |
310 crazy_library_t** library, | 310 crazy_library_t** library, |
311 const char* library_name, | 311 const char* library_name, |
312 crazy_context_t* context) const { | 312 crazy_context_t* context) const { |
313 if (!crazy_library_open_in_zip_file( | 313 if (!crazy_library_open_in_zip_file( |
314 library, zip_file_, library_name, context)) { | 314 library, zip_file_, library_name, context)) { |
315 LOG_ERROR("%s: Could not open %s in zip file %s: %s", | 315 LOG_ERROR("%s: Could not open %s in zip file %s: %s", |
316 __FUNCTION__, library_name, zip_file_, | 316 __FUNCTION__, library_name, zip_file_, |
317 crazy_context_get_error(context)); | 317 crazy_context_get_error(context)); |
318 return false; | 318 return false; |
319 } | 319 } |
320 return true; | 320 return true; |
321 } | 321 } |
322 | 322 |
323 } // unnamed namespace | 323 } // unnamed namespace |
324 | 324 |
325 // Load a library with the chromium linker. This will also call its | 325 // Load a library with the chromium linker. This will also call its |
326 // JNI_OnLoad() method, which shall register its methods. Note that | 326 // JNI_OnLoad() method, which shall register its methods. Note that |
327 // lazy native method resolution will _not_ work after this, because | 327 // lazy native method resolution will _not_ work after this, because |
328 // Dalvik uses the system's dlsym() which won't see the new library, | 328 // Dalvik uses the system's dlsym() which won't see the new library, |
329 // so explicit registration is mandatory. | 329 // so explicit registration is mandatory. |
330 // |env| is the current JNI environment handle. | 330 // |env| is the current JNI environment handle. |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 crazy_context_t* context = GetCrazyContext(); | 658 crazy_context_t* context = GetCrazyContext(); |
659 crazy_context_set_java_vm(context, vm, JNI_VERSION_1_4); | 659 crazy_context_set_java_vm(context, vm, JNI_VERSION_1_4); |
660 | 660 |
661 // Register the function that the crazy linker can call to post code | 661 // Register the function that the crazy linker can call to post code |
662 // for later execution. | 662 // for later execution. |
663 crazy_context_set_callback_poster(context, &PostForLaterExecution, NULL); | 663 crazy_context_set_callback_poster(context, &PostForLaterExecution, NULL); |
664 | 664 |
665 LOG_INFO("%s: Done", __FUNCTION__); | 665 LOG_INFO("%s: Done", __FUNCTION__); |
666 return JNI_VERSION_1_4; | 666 return JNI_VERSION_1_4; |
667 } | 667 } |
OLD | NEW |