mac: 11.0 SDK support

This updates the process_types version of dyld_all_image_infos for macOS
11.0.

Test: crashpad_snapshot_test ProcessTypes.DyldImagesSelf
Bug: crashpad:347
Change-Id: Ieb134f17015070a11c918b26ece316f77a4cc263
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2384317
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
This commit is contained in:
Mark Mentovai 2020-08-31 13:39:58 -04:00 committed by Commit Bot
parent bdf9471324
commit 56937e1df5
3 changed files with 45 additions and 24 deletions

View File

@ -142,9 +142,10 @@ size_t dyld_all_image_infos<Traits>::ExpectedSizeForVersion(
offsetof(dyld_all_image_infos<Traits>, sharedCacheSlide), // 11
offsetof(dyld_all_image_infos<Traits>, sharedCacheUUID), // 12
offsetof(dyld_all_image_infos<Traits>, infoArrayChangeTimestamp), // 13
offsetof(dyld_all_image_infos<Traits>, end_14), // 14
offsetof(dyld_all_image_infos<Traits>, end_v14), // 14
std::numeric_limits<size_t>::max(), // 15, see below
sizeof(dyld_all_image_infos<Traits>), // 16
offsetof(dyld_all_image_infos<Traits>, end_v16), // 16
sizeof(dyld_all_image_infos<Traits>), // 17
};
if (version >= base::size(kSizeForVersion)) {
@ -162,7 +163,7 @@ size_t dyld_all_image_infos<Traits>::ExpectedSizeForVersion(
// interpreting it, so use an OS version check.
int mac_os_x_minor_version = MacOSXMinorVersion();
if (mac_os_x_minor_version == 12) {
return offsetof(dyld_all_image_infos<Traits>, end_14);
return offsetof(dyld_all_image_infos<Traits>, end_v14);
}
DCHECK_GE(mac_os_x_minor_version, 13);

View File

@ -121,29 +121,40 @@ PROCESS_TYPE_STRUCT_BEGIN(dyld_all_image_infos)
// the runtimes that use versions 14 and 15 were built with SDKs that did not
// have this extra padding, its necessary to treat the element at index 4 on
// 32-bit systems as outside of the version 14 and 15 structure. This is why
// |reserved| is only declared a 4-element array, with a special end_14 member
// (not present in the native definition) available to indicate the end of the
// native version 14 structure and the 10.12 version 15 structure, preceding
// the padding in the 32-bit structure that would natively be addressed at
// index 4 of |reserved|. Treat reserved_4_32 as only available in version 16
// of the structure.
// |reserved| is only declared a 4-element array, with a special end_v14
// member (not present in the native definition) available to indicate the end
// of the native version 14 structure and the 10.12 version 15 structure,
// preceding the padding in the 32-bit structure that would natively be
// addressed at index 4 of |reserved|. Treat reserved_4_32 as only available
// in version 16 of the structure.
PROCESS_TYPE_STRUCT_MEMBER(UIntPtr, reserved, [4])
PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_4_64)
PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_5)
PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_6)
PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_7)
PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_8)
PROCESS_TYPE_STRUCT_MEMBER(Nothing, end_14)
PROCESS_TYPE_STRUCT_MEMBER(Nothing, end_v14)
PROCESS_TYPE_STRUCT_MEMBER(Reserved32_32Only, reserved_4_32)
// Version 15 (macOS 10.13). <mach-o/dyld_images.h> incorrectly claims that
// these were introduced at version 16. These fields are not present in macOS
// 10.12, which also identifies its structure as version 15.
// Version 15 (macOS 10.13)
// <mach-o/dyld_images.h> incorrectly claims that these were introduced at
// version 16. These fields are not present in macOS 10.12, which also
// identifies its structure as version 15.
PROCESS_TYPE_STRUCT_MEMBER(UIntPtr, compact_dyld_image_info_addr)
PROCESS_TYPE_STRUCT_MEMBER(ULong, compact_dyld_image_info_size) // size_t
// Version 16 (macOS 10.15)
// The native structure is followed by 4 bytes of padding, marked by the
// end_v16 member later, not present in the native version of the structure.
PROCESS_TYPE_STRUCT_MEMBER(uint32_t, platform) // dyld_platform_t
// Version 17 (macOS 10.16/11.0)
PROCESS_TYPE_STRUCT_MEMBER(uint32_t, aotInfoCount)
PROCESS_TYPE_STRUCT_MEMBER(Nothing, end_v16)
PROCESS_TYPE_STRUCT_MEMBER(Pointer, aotInfoArray) // dyld_aot_image_info*
PROCESS_TYPE_STRUCT_MEMBER(uint64_t, aotInfoArrayChangeTimestamp)
PROCESS_TYPE_STRUCT_MEMBER(UIntPtr, aotSharedCacheBaseAddress)
PROCESS_TYPE_STRUCT_MEMBER(uint8_t, aotSharedCacheUUID, [16])
PROCESS_TYPE_STRUCT_END(dyld_all_image_infos)
#endif // ! PROCESS_TYPE_STRUCT_IMPLEMENT_INTERNAL_READ_INTO &&

View File

@ -103,7 +103,9 @@ TEST(ProcessTypes, DyldImagesSelf) {
ProcessReaderMac process_reader;
ASSERT_TRUE(process_reader.Initialize(mach_task_self()));
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_15
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_16
constexpr uint32_t kDyldAllImageInfosVersionInSDK = 17;
#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_15
constexpr uint32_t kDyldAllImageInfosVersionInSDK = 16;
#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12
constexpr uint32_t kDyldAllImageInfosVersionInSDK = 15;
@ -144,8 +146,10 @@ TEST(ProcessTypes, DyldImagesSelf) {
}
// Make sure that the computed sizes of various versions of this structure are
// correct at different bitnessses.
// correct at different bitnessses. Version 16 and later are unsupported on
// 32-bit systems due to the OS deprecating 32-bit support in macOS 10.15.
constexpr size_t kSpecialCase = std::numeric_limits<size_t>::max();
constexpr size_t kUnsupported = std::numeric_limits<size_t>::max() - 1;
constexpr struct {
uint32_t version;
size_t size_32;
@ -165,7 +169,8 @@ TEST(ProcessTypes, DyldImagesSelf) {
{13, 104, 184},
{14, 164, 304},
{15, kSpecialCase, kSpecialCase},
{16, 184, 328},
{16, kUnsupported, 328},
{17, kUnsupported, 368},
};
for (size_t index = 0; index < base::size(kVersionsAndSizes); ++index) {
uint32_t version = kVersionsAndSizes[index].version;
@ -198,14 +203,18 @@ TEST(ProcessTypes, DyldImagesSelf) {
ASSERT_NE(kVersionsAndSizes[index].size_32, kSpecialCase);
ASSERT_NE(kVersionsAndSizes[index].size_64, kSpecialCase);
EXPECT_EQ(
process_types::internal::dyld_all_image_infos<
process_types::internal::Traits32>::ExpectedSizeForVersion(version),
kVersionsAndSizes[index].size_32);
EXPECT_EQ(
process_types::internal::dyld_all_image_infos<
process_types::internal::Traits64>::ExpectedSizeForVersion(version),
kVersionsAndSizes[index].size_64);
if (kVersionsAndSizes[index].size_32 != kUnsupported) {
EXPECT_EQ(process_types::internal::dyld_all_image_infos<
process_types::internal::Traits32>::
ExpectedSizeForVersion(version),
kVersionsAndSizes[index].size_32);
}
if (kVersionsAndSizes[index].size_64 != kUnsupported) {
EXPECT_EQ(process_types::internal::dyld_all_image_infos<
process_types::internal::Traits64>::
ExpectedSizeForVersion(version),
kVersionsAndSizes[index].size_64);
}
}
process_types::dyld_all_image_infos proctype_image_infos;