| Index: third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp
|
| diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp
|
| index 1ca932109ddcbed447c11be7dfde8ccbf0764143..99cc02e81bf7d2b7a6c4e193c1168bb8ad1d5e9e 100644
|
| --- a/third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp
|
| +++ b/third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp
|
| @@ -392,15 +392,33 @@ LibraryView* LibraryList::LoadLibrary(const char* lib_name,
|
| #error "Unsupported target abi"
|
| #endif
|
|
|
| -const size_t kMaxFilenameInZip = 256;
|
| -const size_t kPageSize = 4096;
|
| -
|
| LibraryView* LibraryList::LoadLibraryInZipFile(const char* zip_file_path,
|
| const char* lib_name,
|
| int dlopen_flags,
|
| uintptr_t load_address,
|
| SearchPathList* search_path_list,
|
| Error* error) {
|
| + int offset = FindAlignedLibraryInZipFile(zip_file_path, lib_name, error);
|
| + if (offset == -1) {
|
| + return NULL;
|
| + }
|
| +
|
| + return LoadLibrary(
|
| + zip_file_path, dlopen_flags, load_address, offset,
|
| + search_path_list, error);
|
| +}
|
| +
|
| +void LibraryList::AddLibrary(LibraryView* wrap) {
|
| + known_libraries_.PushBack(wrap);
|
| +}
|
| +
|
| +const size_t kMaxFilenameInZip = 256;
|
| +const size_t kPageSize = 4096;
|
| +
|
| +int LibraryList::FindAlignedLibraryInZipFile(
|
| + const char* zip_file_path,
|
| + const char* lib_name,
|
| + Error* error) {
|
| String fullname;
|
| fullname.Reserve(kMaxFilenameInZip);
|
| fullname = "lib/";
|
| @@ -409,29 +427,27 @@ LibraryView* LibraryList::LoadLibraryInZipFile(const char* zip_file_path,
|
| fullname += lib_name;
|
|
|
| if (fullname.size() + 1 > kMaxFilenameInZip) {
|
| - error->Format("Filename too long for a file in a zip file %s\n",
|
| - fullname.c_str());
|
| - return NULL;
|
| + if (error) {
|
| + error->Format("Filename too long for a file in a zip file %s\n",
|
| + fullname.c_str());
|
| + }
|
| + return -1;
|
| }
|
|
|
| int offset = FindStartOffsetOfFileInZipFile(zip_file_path, fullname.c_str());
|
| if (offset == -1) {
|
| - return NULL;
|
| + return -1;
|
| }
|
|
|
| if ((offset & (kPageSize - 1)) != 0) {
|
| - error->Format("Library %s is not page aligned in zipfile %s\n",
|
| - lib_name, zip_file_path);
|
| - return NULL;
|
| + if (error) {
|
| + error->Format("Library %s is not page aligned in zipfile %s\n",
|
| + lib_name, zip_file_path);
|
| + }
|
| + return -1;
|
| }
|
|
|
| - return LoadLibrary(
|
| - zip_file_path, dlopen_flags, load_address, offset,
|
| - search_path_list, error);
|
| -}
|
| -
|
| -void LibraryList::AddLibrary(LibraryView* wrap) {
|
| - known_libraries_.PushBack(wrap);
|
| + return offset;
|
| }
|
|
|
| LibraryView* LibraryList::FindKnownLibrary(const char* name) {
|
|
|