2014-07-31 13:45:51 -04:00
|
|
|
# Copyright 2014 The Crashpad Authors. All rights reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
{
|
2015-03-08 15:17:22 -04:00
|
|
|
'includes': [
|
|
|
|
'../build/crashpad.gypi',
|
|
|
|
],
|
2014-07-31 13:45:51 -04:00
|
|
|
'targets': [
|
|
|
|
{
|
2015-03-08 16:25:34 -04:00
|
|
|
'target_name': 'crashpad_compat',
|
2020-09-10 14:23:59 -07:00
|
|
|
'dependencies': [
|
|
|
|
'../util/no_cfi_icall.gyp:no_cfi_icall',
|
|
|
|
],
|
|
|
|
'include_dirs': [
|
|
|
|
'..',
|
|
|
|
],
|
2014-07-31 13:45:51 -04:00
|
|
|
'sources': [
|
2017-12-22 15:32:37 -08:00
|
|
|
'android/dlfcn_internal.cc',
|
|
|
|
'android/dlfcn_internal.h',
|
2017-10-06 12:47:28 -04:00
|
|
|
'android/elf.h',
|
|
|
|
'android/linux/elf.h',
|
|
|
|
'android/linux/prctl.h',
|
|
|
|
'android/linux/ptrace.h',
|
|
|
|
'android/sched.h',
|
2017-12-19 12:03:54 -08:00
|
|
|
'android/sys/epoll.cc',
|
|
|
|
'android/sys/epoll.h',
|
2017-12-06 12:53:54 -05:00
|
|
|
'android/sys/mman.h',
|
2020-07-08 00:00:18 -04:00
|
|
|
'android/sys/mman_mmap.cc',
|
2017-10-06 12:47:28 -04:00
|
|
|
'android/sys/syscall.h',
|
|
|
|
'android/sys/user.h',
|
|
|
|
'linux/signal.h',
|
|
|
|
'linux/sys/ptrace.h',
|
2018-06-27 14:07:25 -07:00
|
|
|
'linux/sys/user.h',
|
mac: Switch from <AvailabilityMacros.h> to <Availability.h>
The macOS 11.0 SDK, as of Xcode 12b6 12A8189n, has not updated
<AvailabilityMacros.h> with a MAC_OS_X_VERSION_11_0 or
MAC_OS_X_VERSION_10_16 constant. However, the <Availability.h> interface
has been updated to provide both __MAC_11_0 and __MAC_10_16.
<AvailabilityMacros.h>’s MAC_OS_X_VERSION_MAX_ALLOWED, which is supposed
to identify the SDK version, is broken in the 11.0 SDK in that whenever
the deployment target is set to 10.15 or earlier, the SDK will be
mis-identified through this interface as 10.15. When using the
<Availability.h> equivalent, __MAC_OS_X_VERSION_MAX_ALLOWED, the 11.0
SDK is identified as 10.16 (arguably it should be internally versioned
as 11.0, but at least this interface allows it to be detected
unambiguously.) It’s clear that the <AvailabilityMacros.h> interface
provides no meaningful support for the macOS 11.0 SDK at all, but
<Availability.h> does.
<Availability.h> was introduced in the Mac OS X 10.5 SDK, so there is no
relevant SDK version compatibility problem with this interface.
Key differences between these interfaces for the purposes used by
Crashpad:
- <AvailabilityMacros.h> → <Availability.h>
- MAC_OS_X_VERSION_MIN_REQUIRED (DT) → __MAC_OS_X_VERSION_MIN_REQUIRED
- MAC_OS_X_VERSION_MAX_ALLOWED (SDK) → __MAC_OS_X_VERSION_MAX_ALLOWED
- MAC_OS_X_VERSION_x_y → __MAC_x_y
- <Availability.h> __MAC_OS_X_VERSION_* SDK/DT macros are only
available when targeting macOS, while <AvailabilityMacros.h>
MAC_OS_X_VERSION_* SDK/DT macros are available on all Apple platforms,
which may be a source of confusion. (<Availability.h> __MAC_* macros
do remain available on all Apple platforms.)
This change was made mostly mechanically by:
sed -i '' -Ee 's/<AvailabilityMacros.h>/<Availability.h>/g' \
$(git grep -E -l '<AvailabilityMacros.h>' |
grep -v AvailabilityMacros.h)
sed -i '' -Ee 's/(MAC_OS_X_VERSION_(MIN_REQUIRED|MAX_ALLOWED))/__\1/g' \
$(git grep -E -l 'MAC_OS_X_VERSION_(MIN_REQUIRED|MAX_ALLOWED)' |
grep -v AvailabilityMacros.h)
sed -i '' -Ee 's/(MAC_OS_X_VERSION_(10_[0-9]+))/__MAC_\2/g' \
$(git grep -E -l 'MAC_OS_X_VERSION_(10_[0-9]+)' |
grep -v AvailabilityMacros.h)
Bug: crashpad:347
Change-Id: Ibdcd7a6215a82f7060b7b67d98691f88454085fc
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2382421
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-08-28 20:00:15 -04:00
|
|
|
'mac/Availability.h',
|
|
|
|
'mac/AvailabilityVersions.h',
|
2015-12-02 15:31:44 -08:00
|
|
|
'mac/kern/exc_resource.h',
|
2017-06-20 09:50:37 -04:00
|
|
|
'mac/mach/i386/thread_state.h',
|
2014-07-31 13:45:51 -04:00
|
|
|
'mac/mach/mach.h',
|
|
|
|
'mac/mach-o/loader.h',
|
2015-04-08 17:46:09 -04:00
|
|
|
'mac/sys/resource.h',
|
2014-08-01 14:37:20 -04:00
|
|
|
'non_mac/mach/mach.h',
|
2014-07-31 13:45:51 -04:00
|
|
|
'non_win/dbghelp.h',
|
|
|
|
'non_win/minwinbase.h',
|
|
|
|
'non_win/timezoneapi.h',
|
|
|
|
'non_win/verrsrc.h',
|
2015-02-04 17:30:03 -08:00
|
|
|
'non_win/windows.h',
|
2014-07-31 13:45:51 -04:00
|
|
|
'non_win/winnt.h',
|
2015-05-06 10:28:07 -07:00
|
|
|
'win/getopt.h',
|
2015-08-05 16:34:50 -04:00
|
|
|
'win/strings.cc',
|
|
|
|
'win/strings.h',
|
2017-10-06 12:47:28 -04:00
|
|
|
'win/sys/time.h',
|
2014-12-10 11:39:50 -08:00
|
|
|
'win/sys/types.h',
|
2015-05-06 10:28:07 -07:00
|
|
|
'win/time.cc',
|
|
|
|
'win/time.h',
|
2017-10-26 18:37:49 -04:00
|
|
|
'win/winbase.h',
|
2015-03-02 13:06:34 -08:00
|
|
|
'win/winnt.h',
|
2017-10-11 00:19:13 -04:00
|
|
|
'win/winternl.h',
|
2014-07-31 13:45:51 -04:00
|
|
|
],
|
2014-09-12 12:13:27 -04:00
|
|
|
'conditions': [
|
|
|
|
['OS=="mac"', {
|
2018-07-03 15:01:12 -04:00
|
|
|
'type': 'none',
|
2014-09-12 12:13:27 -04:00
|
|
|
'include_dirs': [
|
|
|
|
'mac',
|
|
|
|
],
|
|
|
|
'direct_dependent_settings': {
|
|
|
|
'include_dirs': [
|
|
|
|
'mac',
|
|
|
|
],
|
|
|
|
},
|
2018-07-03 15:01:12 -04:00
|
|
|
}, {
|
|
|
|
'include_dirs': [
|
|
|
|
'non_mac',
|
|
|
|
],
|
|
|
|
'direct_dependent_settings': {
|
|
|
|
'include_dirs': [
|
|
|
|
'non_mac',
|
|
|
|
],
|
|
|
|
},
|
2014-09-12 12:13:27 -04:00
|
|
|
}],
|
2014-12-10 11:39:50 -08:00
|
|
|
['OS=="win"', {
|
2018-07-03 15:01:12 -04:00
|
|
|
'type': 'static_library',
|
2014-12-10 11:39:50 -08:00
|
|
|
'include_dirs': [
|
|
|
|
'win',
|
|
|
|
],
|
|
|
|
'direct_dependent_settings': {
|
|
|
|
'include_dirs': [
|
|
|
|
'win',
|
|
|
|
],
|
|
|
|
},
|
2015-05-06 10:28:07 -07:00
|
|
|
'dependencies': [
|
|
|
|
'../third_party/getopt/getopt.gyp:getopt',
|
|
|
|
],
|
2014-12-10 11:39:50 -08:00
|
|
|
}, {
|
2014-09-12 12:13:27 -04:00
|
|
|
'include_dirs': [
|
|
|
|
'non_win',
|
|
|
|
],
|
|
|
|
'direct_dependent_settings': {
|
|
|
|
'include_dirs': [
|
|
|
|
'non_win',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}],
|
2017-03-15 13:47:31 -04:00
|
|
|
['OS=="android"', {
|
2018-07-03 15:01:12 -04:00
|
|
|
'type': 'static_library',
|
2017-03-15 13:47:31 -04:00
|
|
|
'include_dirs': [
|
|
|
|
'android',
|
2017-08-01 19:05:06 -07:00
|
|
|
'linux',
|
2017-03-15 13:47:31 -04:00
|
|
|
],
|
|
|
|
'direct_dependent_settings': {
|
|
|
|
'include_dirs': [
|
|
|
|
'android',
|
2017-08-01 19:05:06 -07:00
|
|
|
'linux',
|
2017-03-15 13:47:31 -04:00
|
|
|
],
|
|
|
|
},
|
android: Support mmap() with large file offsets and API < 21
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>
2017-10-06 15:58:36 -04:00
|
|
|
'link_settings': {
|
|
|
|
'libraries': [
|
|
|
|
'-ldl',
|
|
|
|
],
|
|
|
|
},
|
2017-03-15 13:47:31 -04:00
|
|
|
}],
|
linux: Use PTRACE_GET_THREAD_AREA for x86 ThreadInfo.GetThreadArea
Linux supports TLS on x86 by allocating slots in the GDT, accessible
via the system calls get/set_thread_area. This allows segment
registers (%gs on x86) to be used to quickly access the TLS.
Previously, we used PTRACE_GETREGSET with the NT_386_TLS regset. This
"register set" provides access to the subarray of the GDT used for TLS.
However, there are multiple slots provided and we don't know which one
is being used by the threading library for the current thread's TLS.
Previously, we were just using the first one, which worked for x86 on
64-bit kernels, but not 32-bit kernels. On 32-bit kernels, the first
slot ended up pointing to the TLS of the main thread.
The authoritative index of the current thread's TLS in the GDT is
given by bits 3-15 of %gs. However, this index cannot be used with
PTRACE_GETREGSET+NT386_TLS because we don't know the location of the
TLS slots in the GDT. PTRACE_GET_THREAD_AREA, however, accepts an
index from the start of the GDT similarly to get/set_thread_area.
Bug: crashpad:30
Change-Id: Ie6dfbdd088c6816fad409812a1a97037d4b38fd7
Reviewed-on: https://chromium-review.googlesource.com/575318
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-07-18 16:42:58 -07:00
|
|
|
['OS=="linux"', {
|
2018-07-03 15:01:12 -04:00
|
|
|
'type': 'none',
|
linux: Use PTRACE_GET_THREAD_AREA for x86 ThreadInfo.GetThreadArea
Linux supports TLS on x86 by allocating slots in the GDT, accessible
via the system calls get/set_thread_area. This allows segment
registers (%gs on x86) to be used to quickly access the TLS.
Previously, we used PTRACE_GETREGSET with the NT_386_TLS regset. This
"register set" provides access to the subarray of the GDT used for TLS.
However, there are multiple slots provided and we don't know which one
is being used by the threading library for the current thread's TLS.
Previously, we were just using the first one, which worked for x86 on
64-bit kernels, but not 32-bit kernels. On 32-bit kernels, the first
slot ended up pointing to the TLS of the main thread.
The authoritative index of the current thread's TLS in the GDT is
given by bits 3-15 of %gs. However, this index cannot be used with
PTRACE_GETREGSET+NT386_TLS because we don't know the location of the
TLS slots in the GDT. PTRACE_GET_THREAD_AREA, however, accepts an
index from the start of the GDT similarly to get/set_thread_area.
Bug: crashpad:30
Change-Id: Ie6dfbdd088c6816fad409812a1a97037d4b38fd7
Reviewed-on: https://chromium-review.googlesource.com/575318
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-07-18 16:42:58 -07:00
|
|
|
'include_dirs': [
|
|
|
|
'linux',
|
|
|
|
],
|
|
|
|
'direct_dependent_settings': {
|
|
|
|
'include_dirs': [
|
|
|
|
'linux',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}],
|
2014-09-12 12:13:27 -04:00
|
|
|
],
|
2014-07-31 13:45:51 -04:00
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|