Chromium Code Reviews| 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; |
| } |
|
picksi1
2014/10/28 11:37:09
Instead of returning -1 can we return a constant (
petrcermak
2014/10/28 12:16:48
Done.
|
| int offset = FindStartOffsetOfFileInZipFile(zip_file_path, fullname.c_str()); |
| if (offset == -1) { |
| - return NULL; |
| + return -1; |
| } |
| if ((offset & (kPageSize - 1)) != 0) { |
|
picksi1
2014/10/28 11:37:08
nit: This only works because kPageSize is a power
petrcermak
2014/10/28 12:16:48
Done (using C++11 static_assert).
|
| - 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) { |