From 28e971c5fb2ad911a36c909aabac7828bfd5dbd6 Mon Sep 17 00:00:00 2001 From: Mathieu Bourgeois Date: Mon, 24 Dec 2018 16:32:22 -0500 Subject: [PATCH 1/7] Fix crash with big apks on assembly registration Xamarin.Android, on launch, needs to do a pass through the files in the apk to register assemblies (.dll/.exe), dll configuration files (.config), symbols (.mdb/.pdb) and bindings typemaps (.jm/.mj). To do this pass, the process was to mmap the apk in the process' adress space, then grab the memory offsets for each file and register them on each system as needed. However, mmap-ing the whole apk has the consequence of taking potentially a lot of adress space. Considering it is legal to have a big apk (even though you can't submit an apk of more than 100 Mb to the Play Store, you can still submit it somewhere else, or embed your data in the apk during the development process for simplicity's sake), having an apk of about ~800 Mb in size automatically crashes on launch in armeabi-v7a because it can't find a contiguous 800 Mb block of adress space. The following log is usually found when that issue hits: `I/monodroid-assembly(14915): start: 0xffffffff end: 0x3da16747 len: 1033987912 apk: /data/app/-1/base.apk` However, we don't need to mmap the whole apk, only the files that we are actually registering. Therefore, refactor the registration code to not mmap the whole apk. Instead, open the apk regularly, then when we actually need one of the entries, mmap the area of the file in the apk from a page-aligned offset and use those mmap sections for registration instead. Fixes https://github.com/xamarin/xamarin-android/issues/1673 --- src/monodroid/jni/embedded-assemblies.cc | 100 +++++++++++++---------- 1 file changed, 58 insertions(+), 42 deletions(-) diff --git a/src/monodroid/jni/embedded-assemblies.cc b/src/monodroid/jni/embedded-assemblies.cc index d740775f822..2c23d9d30cb 100644 --- a/src/monodroid/jni/embedded-assemblies.cc +++ b/src/monodroid/jni/embedded-assemblies.cc @@ -243,6 +243,35 @@ struct md_mmap_info { size_t size; }; +struct md_apk_mmap_info { + md_mmap_info mmap_info; + md_mmap_info file_info; +}; + +MONO_API int monodroid_getpagesize (void); + +static md_apk_mmap_info +md_mmap_apk_file(int fd, uLong offset, uLong size, const char* filename, const char* apk) +{ + md_apk_mmap_info info; + + int pageSize = monodroid_getpagesize(); + uLong offsetFromPage = offset % pageSize; + uLong offsetPage = offset - offsetFromPage; + uLong offsetSize = size + offsetFromPage; + + info.mmap_info.area = mmap(NULL, offsetSize, PROT_READ, MAP_PRIVATE, fd, offsetPage); + info.mmap_info.size = offsetSize; + info.file_info.area = (void*)((const char*)info.mmap_info.area + offsetFromPage); + info.file_info.size = size; + + log_info (LOG_ASSEMBLY, " mmap_start: %08p mmap_end: %08p mmap_len: % 12u file_start: %08p file_end: %08p file_len: % 12u apk: %s file: %s", + info.mmap_info.area, reinterpret_cast (info.mmap_info.area) + info.mmap_info.size, (unsigned int) info.mmap_info.size, + info.file_info.area, reinterpret_cast (info.file_info.area) + info.file_info.size, (unsigned int) info.file_info.size, apk, filename); + + return info; +} + static void* md_mmap_open_file (void *opaque, const char *filename, int mode) { @@ -254,37 +283,31 @@ md_mmap_open_file (void *opaque, const char *filename, int mode) static uLong md_mmap_read_file (void *opaque, void *stream, void *buf, uLong size) { - int *offset = reinterpret_cast (stream); - struct md_mmap_info *info = reinterpret_cast (opaque); - - memcpy (buf, ((const char*) info->area) + *offset, size); - *offset += size; - - return size; + int fd = *reinterpret_cast(opaque); + return read(fd, buf, size); } static long md_mmap_tell_file (void *opaque, void *stream) { - int *offset = reinterpret_cast (stream); - return *offset; + int fd = *reinterpret_cast(opaque); + return lseek(fd, 0, SEEK_CUR); } static long md_mmap_seek_file (void *opaque, void *stream, uLong offset, int origin) { - int *pos = reinterpret_cast (stream); - struct md_mmap_info *info = reinterpret_cast (opaque); + int fd = *reinterpret_cast(opaque); switch (origin) { case ZLIB_FILEFUNC_SEEK_END: - *pos = info->size; - /* goto case ZLIB_FILEFUNC_SEEK_CUR */ + lseek(fd, offset, SEEK_END); + break; case ZLIB_FILEFUNC_SEEK_CUR: - *pos += (int) offset; + lseek(fd, offset, SEEK_CUR); break; case ZLIB_FILEFUNC_SEEK_SET: - *pos = (int) offset; + lseek(fd, offset, SEEK_SET); break; default: return -1; @@ -351,8 +374,6 @@ gather_bundled_assemblies_from_apk ( int *bundle_count) { int fd; - struct stat buf; - struct md_mmap_info mmap_info; unzFile file; zlib_filefunc_def funcs = { @@ -371,21 +392,8 @@ gather_bundled_assemblies_from_apk ( // TODO: throw return -1; } - if (fstat (fd, &buf) < 0) { - close (fd); - // TODO: throw - return -1; - } - - mmap_info.area = mmap (NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - mmap_info.size = buf.st_size; - - log_info (LOG_ASSEMBLY, " start: %08p end: %08p len: % 12u apk: %s", - mmap_info.area, reinterpret_cast (mmap_info.area) + mmap_info.size, (unsigned int) mmap_info.size, apk); - - close (fd); - funcs.opaque = &mmap_info; + funcs.opaque = &fd; if ((file = unzOpen2 (NULL, &funcs)) != NULL) { do { @@ -405,11 +413,13 @@ gather_bundled_assemblies_from_apk ( } if (utils.ends_with (cur_entry_name, ".jm")) { - add_type_mapping (&java_to_managed_maps, apk, cur_entry_name, ((const char*) mmap_info.area) + offset); + md_apk_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); + add_type_mapping (&java_to_managed_maps, apk, cur_entry_name, (const char*)map_info.file_info.area); continue; } if (utils.ends_with (cur_entry_name, ".mj")) { - add_type_mapping (&managed_to_java_maps, apk, cur_entry_name, ((const char*) mmap_info.area) + offset); + md_apk_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); + add_type_mapping (&managed_to_java_maps, apk, cur_entry_name, (const char*)map_info.file_info.area); continue; } @@ -420,7 +430,7 @@ gather_bundled_assemblies_from_apk ( // assemblies must be 4-byte aligned, or Bad Things happen if ((offset & 0x3) != 0) { log_fatal (LOG_ASSEMBLY, "Assembly '%s' is located at a bad address %p\n", cur_entry_name, - ((const unsigned char*) mmap_info.area) + offset); + offset); log_fatal (LOG_ASSEMBLY, "You MUST run `zipalign` on %s\n", strrchr (apk, '/') + 1); exit (FATAL_EXIT_MISSING_ZIPALIGN); } @@ -431,19 +441,22 @@ gather_bundled_assemblies_from_apk ( if ((utils.ends_with (cur_entry_name, ".mdb") || utils.ends_with (cur_entry_name, ".pdb")) && register_debug_symbols && !entry_is_overridden && - *bundle != NULL && - register_debug_symbols_for_assembly (mono, cur_entry_name, (*bundle) [*bundle_count-1], - ((const mono_byte*) mmap_info.area) + offset, - info.uncompressed_size)) - continue; + *bundle != NULL) { + md_apk_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); + if(register_debug_symbols_for_assembly (mono, cur_entry_name, (*bundle) [*bundle_count-1], + (const mono_byte*)map_info.file_info.area, + info.uncompressed_size)) + continue; + } if (utils.ends_with (cur_entry_name, ".config") && *bundle != NULL) { char *assembly_name = utils.monodroid_strdup_printf ("%s", basename (cur_entry_name)); // Remove '.config' suffix *strrchr (assembly_name, '.') = '\0'; - - mono->register_config_for_assembly (assembly_name, ((const char*) mmap_info.area) + offset); + + md_apk_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); + mono->register_config_for_assembly (assembly_name, (const char*)map_info.file_info.area); continue; } @@ -458,8 +471,9 @@ gather_bundled_assemblies_from_apk ( cur = (*bundle) [*bundle_count] = reinterpret_cast (utils.xcalloc (1, sizeof (MonoBundledAssembly))); ++*bundle_count; + md_apk_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); cur->name = utils.monodroid_strdup_printf ("%s", strstr (cur_entry_name, prefix) + strlen (prefix)); - cur->data = ((const unsigned char*) mmap_info.area) + offset; + cur->data = (const unsigned char*)map_info.file_info.area; // MonoBundledAssembly::size is const?! psize = (unsigned int*) &cur->size; @@ -483,6 +497,8 @@ gather_bundled_assemblies_from_apk ( } while (unzGoToNextFile (file) == UNZ_OK); unzClose (file); } + + close(fd); return 0; } From 4a08ef9c62db80d807aaf0597f17aab68fb5bdff Mon Sep 17 00:00:00 2001 From: Mathieu Bourgeois Date: Wed, 2 Jan 2019 11:43:12 -0500 Subject: [PATCH 2/7] Clean up code based on Jonathan Pryor's feedback - Added check to mmap with fatal log and forced exit when mmap fails - moved forward declaration to it's proper place in monodroid-glue.h --- src/monodroid/jni/embedded-assemblies.cc | 11 ++++++++--- src/monodroid/jni/monodroid-glue.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/monodroid/jni/embedded-assemblies.cc b/src/monodroid/jni/embedded-assemblies.cc index 2c23d9d30cb..9d81ef4aed4 100644 --- a/src/monodroid/jni/embedded-assemblies.cc +++ b/src/monodroid/jni/embedded-assemblies.cc @@ -7,6 +7,7 @@ #include #include #include +#include extern "C" { #include "java-interop-util.h" @@ -19,6 +20,7 @@ extern "C" { #include "ioapi.h" #include "embedded-assemblies.h" #include "globals.h" +#include "monodroid-glue.h" using namespace xamarin::android; using namespace xamarin::android::internal; @@ -248,8 +250,6 @@ struct md_apk_mmap_info { md_mmap_info file_info; }; -MONO_API int monodroid_getpagesize (void); - static md_apk_mmap_info md_mmap_apk_file(int fd, uLong offset, uLong size, const char* filename, const char* apk) { @@ -260,7 +260,12 @@ md_mmap_apk_file(int fd, uLong offset, uLong size, const char* filename, const c uLong offsetPage = offset - offsetFromPage; uLong offsetSize = size + offsetFromPage; - info.mmap_info.area = mmap(NULL, offsetSize, PROT_READ, MAP_PRIVATE, fd, offsetPage); + info.mmap_info.area = mmap (NULL, offsetSize, PROT_READ, MAP_PRIVATE, fd, offsetPage); + if (info.mmap_info.area == MAP_FAILED) { + log_fatal (LOG_DEFAULT, "Could not `mmap` apk `%s` entry `%s`: %s", apk, filename, strerror (errno)); + exit (FATAL_EXIT_CANNOT_FIND_APK); + } + info.mmap_info.size = offsetSize; info.file_info.area = (void*)((const char*)info.mmap_info.area + offsetFromPage); info.file_info.size = size; diff --git a/src/monodroid/jni/monodroid-glue.h b/src/monodroid/jni/monodroid-glue.h index 5dd18065b14..633c187d1e4 100644 --- a/src/monodroid/jni/monodroid-glue.h +++ b/src/monodroid/jni/monodroid-glue.h @@ -11,6 +11,7 @@ extern "C" { #endif MONO_API int monodroid_get_system_property (const char *name, char **value); + MONO_API int monodroid_getpagesize (void); #ifdef __cplusplus } #endif From fe1236ce97247e5b98d590d3991d48952c8b3984 Mon Sep 17 00:00:00 2001 From: Mathieu Bourgeois Date: Wed, 2 Jan 2019 15:54:00 -0500 Subject: [PATCH 3/7] Remove unneeded md_apk_mmap_info type We only use the file_info part since we never munmap those. Therefore, the whole type (which contains the info of the actual realigned mmap) is not needed. It can always be recomputed anyway by realigning to the page size --- src/monodroid/jni/embedded-assemblies.cc | 46 +++++++++++------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/monodroid/jni/embedded-assemblies.cc b/src/monodroid/jni/embedded-assemblies.cc index 9d81ef4aed4..a32f41addac 100644 --- a/src/monodroid/jni/embedded-assemblies.cc +++ b/src/monodroid/jni/embedded-assemblies.cc @@ -245,36 +245,32 @@ struct md_mmap_info { size_t size; }; -struct md_apk_mmap_info { - md_mmap_info mmap_info; - md_mmap_info file_info; -}; - -static md_apk_mmap_info +static md_mmap_info md_mmap_apk_file(int fd, uLong offset, uLong size, const char* filename, const char* apk) { - md_apk_mmap_info info; + md_mmap_info file_info; + md_mmap_info mmap_info; int pageSize = monodroid_getpagesize(); uLong offsetFromPage = offset % pageSize; uLong offsetPage = offset - offsetFromPage; uLong offsetSize = size + offsetFromPage; - info.mmap_info.area = mmap (NULL, offsetSize, PROT_READ, MAP_PRIVATE, fd, offsetPage); - if (info.mmap_info.area == MAP_FAILED) { + mmap_info.area = mmap (NULL, offsetSize, PROT_READ, MAP_PRIVATE, fd, offsetPage); + if (mmap_info.area == MAP_FAILED) { log_fatal (LOG_DEFAULT, "Could not `mmap` apk `%s` entry `%s`: %s", apk, filename, strerror (errno)); exit (FATAL_EXIT_CANNOT_FIND_APK); } - info.mmap_info.size = offsetSize; - info.file_info.area = (void*)((const char*)info.mmap_info.area + offsetFromPage); - info.file_info.size = size; + mmap_info.size = offsetSize; + file_info.area = (void*)((const char*)mmap_info.area + offsetFromPage); + file_info.size = size; log_info (LOG_ASSEMBLY, " mmap_start: %08p mmap_end: %08p mmap_len: % 12u file_start: %08p file_end: %08p file_len: % 12u apk: %s file: %s", - info.mmap_info.area, reinterpret_cast (info.mmap_info.area) + info.mmap_info.size, (unsigned int) info.mmap_info.size, - info.file_info.area, reinterpret_cast (info.file_info.area) + info.file_info.size, (unsigned int) info.file_info.size, apk, filename); + mmap_info.area, reinterpret_cast (mmap_info.area) + mmap_info.size, (unsigned int) mmap_info.size, + file_info.area, reinterpret_cast (file_info.area) + file_info.size, (unsigned int) file_info.size, apk, filename); - return info; + return file_info; } static void* @@ -418,13 +414,13 @@ gather_bundled_assemblies_from_apk ( } if (utils.ends_with (cur_entry_name, ".jm")) { - md_apk_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); - add_type_mapping (&java_to_managed_maps, apk, cur_entry_name, (const char*)map_info.file_info.area); + md_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); + add_type_mapping (&java_to_managed_maps, apk, cur_entry_name, (const char*)map_info.area); continue; } if (utils.ends_with (cur_entry_name, ".mj")) { - md_apk_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); - add_type_mapping (&managed_to_java_maps, apk, cur_entry_name, (const char*)map_info.file_info.area); + md_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); + add_type_mapping (&managed_to_java_maps, apk, cur_entry_name, (const char*)map_info.area); continue; } @@ -447,9 +443,9 @@ gather_bundled_assemblies_from_apk ( register_debug_symbols && !entry_is_overridden && *bundle != NULL) { - md_apk_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); + md_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); if(register_debug_symbols_for_assembly (mono, cur_entry_name, (*bundle) [*bundle_count-1], - (const mono_byte*)map_info.file_info.area, + (const mono_byte*)map_info.area, info.uncompressed_size)) continue; } @@ -460,8 +456,8 @@ gather_bundled_assemblies_from_apk ( // Remove '.config' suffix *strrchr (assembly_name, '.') = '\0'; - md_apk_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); - mono->register_config_for_assembly (assembly_name, (const char*)map_info.file_info.area); + md_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); + mono->register_config_for_assembly (assembly_name, (const char*)map_info.area); continue; } @@ -476,9 +472,9 @@ gather_bundled_assemblies_from_apk ( cur = (*bundle) [*bundle_count] = reinterpret_cast (utils.xcalloc (1, sizeof (MonoBundledAssembly))); ++*bundle_count; - md_apk_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); + md_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); cur->name = utils.monodroid_strdup_printf ("%s", strstr (cur_entry_name, prefix) + strlen (prefix)); - cur->data = (const unsigned char*)map_info.file_info.area; + cur->data = (const unsigned char*)map_info.area; // MonoBundledAssembly::size is const?! psize = (unsigned int*) &cur->size; From 6dc14321e0dc53c1eb8a4ac58ba6a822c09c81e5 Mon Sep 17 00:00:00 2001 From: Mathieu Bourgeois Date: Wed, 2 Jan 2019 15:55:47 -0500 Subject: [PATCH 4/7] Rework message of assembly not being 4-byte aligned The assemblies, at that point, aren't mmap-ed anymore so we can't use a process space adress. Instead, mention that we're talking about an offset in the apk. --- src/monodroid/jni/embedded-assemblies.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monodroid/jni/embedded-assemblies.cc b/src/monodroid/jni/embedded-assemblies.cc index a32f41addac..203c62b23d3 100644 --- a/src/monodroid/jni/embedded-assemblies.cc +++ b/src/monodroid/jni/embedded-assemblies.cc @@ -430,7 +430,7 @@ gather_bundled_assemblies_from_apk ( // assemblies must be 4-byte aligned, or Bad Things happen if ((offset & 0x3) != 0) { - log_fatal (LOG_ASSEMBLY, "Assembly '%s' is located at a bad address %p\n", cur_entry_name, + log_fatal (LOG_ASSEMBLY, "Assembly '%s' is located at a bad offset %p in the apk\n", cur_entry_name, offset); log_fatal (LOG_ASSEMBLY, "You MUST run `zipalign` on %s\n", strrchr (apk, '/') + 1); exit (FATAL_EXIT_MISSING_ZIPALIGN); From db77d355e0e13e17a93186e19df67328d139cb45 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 3 Jan 2019 11:43:25 -0500 Subject: [PATCH 5/7] Fix code formatting. --- src/monodroid/jni/embedded-assemblies.cc | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/monodroid/jni/embedded-assemblies.cc b/src/monodroid/jni/embedded-assemblies.cc index 203c62b23d3..94eda3236b3 100644 --- a/src/monodroid/jni/embedded-assemblies.cc +++ b/src/monodroid/jni/embedded-assemblies.cc @@ -246,25 +246,25 @@ struct md_mmap_info { }; static md_mmap_info -md_mmap_apk_file(int fd, uLong offset, uLong size, const char* filename, const char* apk) +md_mmap_apk_file (int fd, uLong offset, uLong size, const char* filename, const char* apk) { md_mmap_info file_info; md_mmap_info mmap_info; - int pageSize = monodroid_getpagesize(); - uLong offsetFromPage = offset % pageSize; - uLong offsetPage = offset - offsetFromPage; - uLong offsetSize = size + offsetFromPage; + int pageSize = monodroid_getpagesize(); + uLong offsetFromPage = offset % pageSize; + uLong offsetPage = offset - offsetFromPage; + uLong offsetSize = size + offsetFromPage; - mmap_info.area = mmap (NULL, offsetSize, PROT_READ, MAP_PRIVATE, fd, offsetPage); + mmap_info.area = mmap (NULL, offsetSize, PROT_READ, MAP_PRIVATE, fd, offsetPage); if (mmap_info.area == MAP_FAILED) { log_fatal (LOG_DEFAULT, "Could not `mmap` apk `%s` entry `%s`: %s", apk, filename, strerror (errno)); exit (FATAL_EXIT_CANNOT_FIND_APK); } - mmap_info.size = offsetSize; - file_info.area = (void*)((const char*)mmap_info.area + offsetFromPage); - file_info.size = size; + mmap_info.size = offsetSize; + file_info.area = (void*)((const char*)mmap_info.area + offsetFromPage); + file_info.size = size; log_info (LOG_ASSEMBLY, " mmap_start: %08p mmap_end: %08p mmap_len: % 12u file_start: %08p file_end: %08p file_len: % 12u apk: %s file: %s", mmap_info.area, reinterpret_cast (mmap_info.area) + mmap_info.size, (unsigned int) mmap_info.size, @@ -285,14 +285,14 @@ static uLong md_mmap_read_file (void *opaque, void *stream, void *buf, uLong size) { int fd = *reinterpret_cast(opaque); - return read(fd, buf, size); + return read (fd, buf, size); } static long md_mmap_tell_file (void *opaque, void *stream) { int fd = *reinterpret_cast(opaque); - return lseek(fd, 0, SEEK_CUR); + return lseek (fd, 0, SEEK_CUR); } static long @@ -302,13 +302,13 @@ md_mmap_seek_file (void *opaque, void *stream, uLong offset, int origin) switch (origin) { case ZLIB_FILEFUNC_SEEK_END: - lseek(fd, offset, SEEK_END); + lseek (fd, offset, SEEK_END); break; case ZLIB_FILEFUNC_SEEK_CUR: - lseek(fd, offset, SEEK_CUR); + lseek (fd, offset, SEEK_CUR); break; case ZLIB_FILEFUNC_SEEK_SET: - lseek(fd, offset, SEEK_SET); + lseek (fd, offset, SEEK_SET); break; default: return -1; @@ -414,12 +414,12 @@ gather_bundled_assemblies_from_apk ( } if (utils.ends_with (cur_entry_name, ".jm")) { - md_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); + md_mmap_info map_info = md_mmap_apk_file (fd, offset, info.uncompressed_size, cur_entry_name, apk); add_type_mapping (&java_to_managed_maps, apk, cur_entry_name, (const char*)map_info.area); continue; } if (utils.ends_with (cur_entry_name, ".mj")) { - md_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); + md_mmap_info map_info = md_mmap_apk_file (fd, offset, info.uncompressed_size, cur_entry_name, apk); add_type_mapping (&managed_to_java_maps, apk, cur_entry_name, (const char*)map_info.area); continue; } @@ -430,7 +430,7 @@ gather_bundled_assemblies_from_apk ( // assemblies must be 4-byte aligned, or Bad Things happen if ((offset & 0x3) != 0) { - log_fatal (LOG_ASSEMBLY, "Assembly '%s' is located at a bad offset %p in the apk\n", cur_entry_name, + log_fatal (LOG_ASSEMBLY, "Assembly '%s' is located at bad offset %lu within the .apk\n", cur_entry_name, offset); log_fatal (LOG_ASSEMBLY, "You MUST run `zipalign` on %s\n", strrchr (apk, '/') + 1); exit (FATAL_EXIT_MISSING_ZIPALIGN); From 00cf461fdad5e3fd6fceabfcd9fa4e61469f940b Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 3 Jan 2019 11:46:30 -0500 Subject: [PATCH 6/7] More indentation fixes. --- src/monodroid/jni/embedded-assemblies.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/monodroid/jni/embedded-assemblies.cc b/src/monodroid/jni/embedded-assemblies.cc index 94eda3236b3..39a56dff7cc 100644 --- a/src/monodroid/jni/embedded-assemblies.cc +++ b/src/monodroid/jni/embedded-assemblies.cc @@ -267,8 +267,8 @@ md_mmap_apk_file (int fd, uLong offset, uLong size, const char* filename, const file_info.size = size; log_info (LOG_ASSEMBLY, " mmap_start: %08p mmap_end: %08p mmap_len: % 12u file_start: %08p file_end: %08p file_len: % 12u apk: %s file: %s", - mmap_info.area, reinterpret_cast (mmap_info.area) + mmap_info.size, (unsigned int) mmap_info.size, - file_info.area, reinterpret_cast (file_info.area) + file_info.size, (unsigned int) file_info.size, apk, filename); + mmap_info.area, reinterpret_cast (mmap_info.area) + mmap_info.size, (unsigned int) mmap_info.size, + file_info.area, reinterpret_cast (file_info.area) + file_info.size, (unsigned int) file_info.size, apk, filename); return file_info; } @@ -414,12 +414,12 @@ gather_bundled_assemblies_from_apk ( } if (utils.ends_with (cur_entry_name, ".jm")) { - md_mmap_info map_info = md_mmap_apk_file (fd, offset, info.uncompressed_size, cur_entry_name, apk); + md_mmap_info map_info = md_mmap_apk_file (fd, offset, info.uncompressed_size, cur_entry_name, apk); add_type_mapping (&java_to_managed_maps, apk, cur_entry_name, (const char*)map_info.area); continue; } if (utils.ends_with (cur_entry_name, ".mj")) { - md_mmap_info map_info = md_mmap_apk_file (fd, offset, info.uncompressed_size, cur_entry_name, apk); + md_mmap_info map_info = md_mmap_apk_file (fd, offset, info.uncompressed_size, cur_entry_name, apk); add_type_mapping (&managed_to_java_maps, apk, cur_entry_name, (const char*)map_info.area); continue; } @@ -445,8 +445,8 @@ gather_bundled_assemblies_from_apk ( *bundle != NULL) { md_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); if(register_debug_symbols_for_assembly (mono, cur_entry_name, (*bundle) [*bundle_count-1], - (const mono_byte*)map_info.area, - info.uncompressed_size)) + (const mono_byte*)map_info.area, + info.uncompressed_size)) continue; } From d4798921e9af0a1e4e71b209ae5bed242394b533 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 3 Jan 2019 11:48:22 -0500 Subject: [PATCH 7/7] lol --- src/monodroid/jni/embedded-assemblies.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monodroid/jni/embedded-assemblies.cc b/src/monodroid/jni/embedded-assemblies.cc index 39a56dff7cc..0e68779dd5a 100644 --- a/src/monodroid/jni/embedded-assemblies.cc +++ b/src/monodroid/jni/embedded-assemblies.cc @@ -444,7 +444,7 @@ gather_bundled_assemblies_from_apk ( !entry_is_overridden && *bundle != NULL) { md_mmap_info map_info = md_mmap_apk_file(fd, offset, info.uncompressed_size, cur_entry_name, apk); - if(register_debug_symbols_for_assembly (mono, cur_entry_name, (*bundle) [*bundle_count-1], + if (register_debug_symbols_for_assembly (mono, cur_entry_name, (*bundle) [*bundle_count-1], (const mono_byte*)map_info.area, info.uncompressed_size)) continue;