mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-29 08:39:44 +08:00
2633708f84
Chrome (and therefore mini_chromium) has always built with _FILE_OFFSET_BITS=64, which is intended to enable a 64-bit off_t even for 32-bit programs. However, support was never present in Android with NDK traditional headers. The new NDK unified headers do recognize _FILE_OFFSET_BITS=64 and enable a 64-bit off_t, along with corresponding functions and system call wrappers. However, no mmap() wrapper supporting a 64-bit off_t for 32-bit programs was available prior to API 21 (Android 5.0 “Lollipop”), so when targeting older API levels, NDK headers do not proivde an mmap() declaration. This avoids silently truncating 64-bit off_t values to 32 bits. NDK r15b did make such an mmap() wrapper available (https://android.googlesource.com/platform/bionic/+/785b249df024), and it did silently truncate, but this was removed for r15c (https://android.googlesource.com/platform/bionic/+/00fedf587917). How should this work if _FILE_OFFSET_BITS is set to 64 and recent unified headers are in use? The strategy employed here is to provide an mmap() declaration in compat, with a 64-bit off_t. That mmap() will call to Bionic’s mmap64() wrapper if available (it’s available since Android 5.0 “Lollipop”). If unavailable, it implements the same logic that mmap64() does directly, which predominantly involves calling the __mmap2() system call. Bionic has always provided wrappers for __mmap2(). Additional reading: https://android.googlesource.com/platform/bionic/+/0bfcbaf4d069/docs/32-bit-abi.md#is-32_bit-1 https://github.com/android-ndk/ndk/issues/442 Bug: crashpad:30 Change-Id: I98c10e2eda773cb6f3d9eb8db9b8bfde43c885e7 Reviewed-on: https://chromium-review.googlesource.com/705674 Reviewed-by: Joshua Peraza <jperaza@chromium.org>