Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1382)

Unified Diff: third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp

Issue 684453003: Add UMA for testing whether the Chromium library was page aligned in the APK file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {

Powered by Google App Engine
This is Rietveld 408576698