Bug 855824 - Get rid of the lib.id file on Android. r=blassey
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 09 Apr 2013 14:05:07 +0200
changeset 134925 2cc258f94ac011c3b8e911599d9b0ee745f3304f
parent 134924 39902799d11b6d81cee51ce5c8d9a8f899970130
child 134926 5133c67c0473f8af5512c0230cd3ce5028f9b38d
push id3752
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 17:21:10 +0000
treeherdermozilla-aurora@1580544aef0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs855824
milestone23.0a1
Bug 855824 - Get rid of the lib.id file on Android. r=blassey
mozglue/android/APKOpen.cpp
mozglue/android/APKOpen.h
toolkit/mozapps/installer/packager.mk
--- a/mozglue/android/APKOpen.cpp
+++ b/mozglue/android/APKOpen.cpp
@@ -126,129 +126,57 @@ static void * plc_handle = NULL;
 static void * nss_handle = NULL;
 
 template <typename T> inline void
 xul_dlsym(const char *symbolName, T *value)
 {
   *value = (T) (uintptr_t) __wrap_dlsym(xul_handle, symbolName);
 }
 
-#if defined(MOZ_CRASHREPORTER)
-static void
-extractLib(Zip::Stream &s, void * dest)
-{
-  z_stream strm = {
-    next_in: (Bytef *)s.GetBuffer(),
-    avail_in: s.GetSize(),
-    total_in: 0,
-
-    next_out: (Bytef *)dest,
-    avail_out: s.GetUncompressedSize(),
-    total_out: 0
-  };
-
-  int ret;
-  ret = inflateInit2(&strm, -MAX_WBITS);
-  if (ret != Z_OK)
-    __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "inflateInit failed: %s", strm.msg);
-
-  ret = inflate(&strm, Z_SYNC_FLUSH);
-  if (ret != Z_STREAM_END)
-    __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "inflate failed: %s", strm.msg);
-
-  ret = inflateEnd(&strm);
-  if (ret != Z_OK)
-    __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "inflateEnd failed: %s", strm.msg);
-
-  if (strm.total_out != s.GetUncompressedSize())
-    __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "File not fully uncompressed! %lu / %d", strm.total_out, s.GetUncompressedSize());
-}
-#endif
-
 static struct lib_cache_info *cache_mapping = NULL;
 
 NS_EXPORT const struct lib_cache_info *
 getLibraryCache()
 {
   return cache_mapping;
 }
 
-#ifdef MOZ_CRASHREPORTER
-static void *
-extractBuf(const char * path, Zip *zip)
-{
-  Zip::Stream s;
-  if (!zip->GetStream(path, &s))
-    return NULL;
-
-  // allocate space for a trailing null byte
-  void * buf = malloc(s.GetUncompressedSize() + 1);
-  if (buf == (void *)-1) {
-    __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't alloc decompression buffer for %s", path);
-    return NULL;
-  }
-  if (s.GetType() == Zip::Stream::DEFLATE)
-    extractLib(s, buf);
-  else
-    memcpy(buf, s.GetBuffer(), s.GetUncompressedSize());
-
-  // null terminate it
-  ((unsigned char*) buf)[s.GetUncompressedSize()] = 0;
-
-  return buf;
-}
-#endif
-
 static int mapping_count = 0;
-static char *file_ids = NULL;
 
 #define MAX_MAPPING_INFO 32
 
 extern "C" void
 report_mapping(char *name, void *base, uint32_t len, uint32_t offset)
 {
-  if (!file_ids || mapping_count >= MAX_MAPPING_INFO)
+  if (mapping_count >= MAX_MAPPING_INFO)
     return;
 
   struct mapping_info *info = &lib_mapping[mapping_count++];
   info->name = strdup(name);
   info->base = (uintptr_t)base;
   info->len = len;
   info->offset = offset;
-
-  char * entry = strstr(file_ids, name);
-  if (entry)
-    info->file_id = strndup(entry + strlen(name) + 1, 32);
 }
 
 static mozglueresult
 loadGeckoLibs(const char *apkName)
 {
   chdir(getenv("GRE_HOME"));
 
   uint64_t t0 = TimeStamp_Now();
   struct rusage usage1;
   getrusage(RUSAGE_THREAD, &usage1);
   
   RefPtr<Zip> zip = ZipCollection::GetZip(apkName);
 
-#ifdef MOZ_CRASHREPORTER
-  file_ids = (char *)extractBuf("lib.id", zip);
-#endif
-
   char *file = new char[strlen(apkName) + sizeof("!/libxul.so")];
   sprintf(file, "%s!/libxul.so", apkName);
   xul_handle = __wrap_dlopen(file, RTLD_GLOBAL | RTLD_LAZY);
   delete[] file;
 
-#ifdef MOZ_CRASHREPORTER
-  free(file_ids);
-  file_ids = NULL;
-#endif
-
   if (!xul_handle) {
     __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libxul!");
     return FAILURE;
   }
 
 #define JNI_BINDINGS
 #include "jni-stubs.inc"
 #undef JNI_BINDINGS
@@ -285,30 +213,21 @@ loadSQLiteLibs(const char *apkName)
 #else
   chdir(getenv("GRE_HOME"));
 
   RefPtr<Zip> zip = ZipCollection::GetZip(apkName);
   if (!lib_mapping) {
     lib_mapping = (struct mapping_info *)calloc(MAX_MAPPING_INFO, sizeof(*lib_mapping));
   }
 
-#ifdef MOZ_CRASHREPORTER
-  file_ids = (char *)extractBuf("lib.id", zip);
-#endif
-
   char *file = new char[strlen(apkName) + sizeof("!/libmozsqlite3.so")];
   sprintf(file, "%s!/libmozsqlite3.so", apkName);
   sqlite_handle = __wrap_dlopen(file, RTLD_GLOBAL | RTLD_LAZY);
   delete [] file;
 
-#ifdef MOZ_CRASHREPORTER
-  free(file_ids);
-  file_ids = NULL;
-#endif
-
   if (!sqlite_handle) {
     __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libmozsqlite3!");
     return FAILURE;
   }
 #endif
 
   setup_sqlite_functions(sqlite_handle);
   return SUCCESS;
@@ -322,20 +241,16 @@ loadNSSLibs(const char *apkName)
 
   chdir(getenv("GRE_HOME"));
 
   RefPtr<Zip> zip = ZipCollection::GetZip(apkName);
   if (!lib_mapping) {
     lib_mapping = (struct mapping_info *)calloc(MAX_MAPPING_INFO, sizeof(*lib_mapping));
   }
 
-#ifdef MOZ_CRASHREPORTER
-  file_ids = (char *)extractBuf("lib.id", zip);
-#endif
-
   char *file = new char[strlen(apkName) + sizeof("!/libnss3.so")];
   sprintf(file, "%s!/libnss3.so", apkName);
   nss_handle = __wrap_dlopen(file, RTLD_GLOBAL | RTLD_LAZY);
   delete [] file;
 
 #ifndef MOZ_FOLD_LIBS
   file = new char[strlen(apkName) + sizeof("!/libnspr4.so")];
   sprintf(file, "%s!/libnspr4.so", apkName);
@@ -343,21 +258,16 @@ loadNSSLibs(const char *apkName)
   delete [] file;
 
   file = new char[strlen(apkName) + sizeof("!/libplc4.so")];
   sprintf(file, "%s!/libplc4.so", apkName);
   plc_handle = __wrap_dlopen(file, RTLD_GLOBAL | RTLD_LAZY);
   delete [] file;
 #endif
 
-#ifdef MOZ_CRASHREPORTER
-  free(file_ids);
-  file_ids = NULL;
-#endif
-
   if (!nss_handle) {
     __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libnss3!");
     return FAILURE;
   }
 
 #ifndef MOZ_FOLD_LIBS
   if (!nspr_handle) {
     __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libnspr4!");
--- a/mozglue/android/APKOpen.h
+++ b/mozglue/android/APKOpen.h
@@ -8,17 +8,16 @@
 #include <jni.h>
 
 #ifndef NS_EXPORT
 #define NS_EXPORT __attribute__ ((visibility("default")))
 #endif
 
 struct mapping_info {
   char * name;
-  char * file_id;
   uintptr_t base;
   size_t len;
   size_t offset;
 };
 
 const struct mapping_info * getLibraryMapping();
 
 static const int SUCCESS = 0;
--- a/toolkit/mozapps/installer/packager.mk
+++ b/toolkit/mozapps/installer/packager.mk
@@ -251,20 +251,16 @@ ifdef MOZ_SIGN_CMD
 JARSIGNER := $(MOZ_SIGN_CMD) -f jar
 else
 JARSIGNER ?= echo
 endif
 
 DIST_FILES =
 
 # Place the files in the order they are going to be opened by the linker
-ifdef MOZ_CRASHREPORTER
-DIST_FILES += lib.id
-endif
-
 DIST_FILES += libmozalloc.so
 ifndef MOZ_FOLD_LIBS
 DIST_FILES += \
   libnspr4.so \
   libplc4.so \
   libplds4.so \
   libmozsqlite3.so \
   libnssutil3.so \
@@ -357,21 +353,16 @@ endif
 PKG_SUFFIX      = .apk
 INNER_MAKE_PACKAGE	= \
   $(foreach lib,$(SZIP_LIBRARIES),host/bin/szip $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib) $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib:.so=.sz) && mv $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib:.so=.sz) $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib) && ) \
   make -C $(GECKO_APP_AP_PATH) gecko.ap_ && \
   cp $(GECKO_APP_AP_PATH)/gecko.ap_ $(_ABS_DIST) && \
   ( cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && \
     mkdir -p lib/$(ABI_DIR) && \
     mv libmozglue.so $(MOZ_CHILD_PROCESS_NAME) lib/$(ABI_DIR) && \
-    rm -f lib.id && \
-    for SOMELIB in *.so ; \
-    do \
-      printf "`basename $$SOMELIB`:`$(_ABS_DIST)/host/bin/file_id $$SOMELIB`\n" >> lib.id ; \
-    done && \
     unzip -o $(_ABS_DIST)/gecko.ap_ && \
     rm $(_ABS_DIST)/gecko.ap_ && \
     $(if $(SZIP_LIBRARIES),$(ZIP) -0 $(_ABS_DIST)/gecko.ap_ $(SZIP_LIBRARIES) && ) \
     $(ZIP) -r9D $(_ABS_DIST)/gecko.ap_ $(DIST_FILES) -x $(NON_DIST_FILES) $(SZIP_LIBRARIES) && \
     $(ZIP) -0 $(_ABS_DIST)/gecko.ap_ $(OMNIJAR_NAME)) && \
   rm -f $(_ABS_DIST)/gecko.apk && \
   $(APKBUILDER) $(_ABS_DIST)/gecko.apk -v $(APKBUILDER_FLAGS) -z $(_ABS_DIST)/gecko.ap_ -f $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/classes.dex && \
   cp $(_ABS_DIST)/gecko.apk $(_ABS_DIST)/gecko-unsigned-unaligned.apk && \