mac: Make crashpad build with the 12.0 SDK

The size of dyld_all_image_infos didn't change, but the last 128 bit
of `reserved` moved out of `reserved` and got names.

On 64-bit, that's straightforward -- just move two uint64s out of the
array into fields.

On 32-bit, it's fairly awkward: It's 4 of the uintptr_t `reserved`
array, which means `UIntPtr, reserved, [4]` would have to diverge
between 32-bit and 64-bit, and also shared_cache_fs_obj_id would
straddle the `end_v14` boundary. Since macOS 12.0 doesn't support
32-bit builds, just punt on this for 32-bit. (This might possibly
mean that crashpad-on-apple-watch might not compile, but that's
a build configuration that doesn't exist.)

See comment 9 and 6 on the bug.

Bug: crashpad:375, chromium:1265179
Change-Id: I221af20c59c30a8176d5685d3f5e84aaf3de9afe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3253742
Commit-Queue: Nico Weber <thakis@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Message-Id: Merged from chromium 83a01b8e2cd2d4d96b0e298d012bb3a2bd93c64f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3293642
Commit-Queue: Robert Sesek <rsesek@chromium.org>
This commit is contained in:
Robert Sesek 2021-11-19 16:04:11 -05:00 committed by Crashpad LUCI CQ
parent c8edcf1bb8
commit 10e82d5318
4 changed files with 23 additions and 4 deletions

View File

@ -87,4 +87,10 @@
#define __MAC_11_0 110000 #define __MAC_11_0 110000
#endif #endif
// 12.0 SDK
#ifndef __MAC_12_0
#define __MAC_12_0 120000
#endif
#endif // CRASHPAD_COMPAT_MAC_AVAILABILITYVERSIONS_H_ #endif // CRASHPAD_COMPAT_MAC_AVAILABILITYVERSIONS_H_

View File

@ -147,6 +147,7 @@ size_t dyld_all_image_infos<Traits>::ExpectedSizeForVersion(
std::numeric_limits<size_t>::max(), // 15, see below std::numeric_limits<size_t>::max(), // 15, see below
offsetof(dyld_all_image_infos<Traits>, end_v16), // 16 offsetof(dyld_all_image_infos<Traits>, end_v16), // 16
sizeof(dyld_all_image_infos<Traits>), // 17 sizeof(dyld_all_image_infos<Traits>), // 17
sizeof(dyld_all_image_infos<Traits>), // 18
}; };
if (version >= base::size(kSizeForVersion)) { if (version >= base::size(kSizeForVersion)) {

View File

@ -127,12 +127,16 @@ PROCESS_TYPE_STRUCT_BEGIN(dyld_all_image_infos)
// preceding the padding in the 32-bit structure that would natively be // 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 // addressed at index 4 of |reserved|. Treat reserved_4_32 as only available
// in version 16 of the structure. // in version 16 of the structure.
// In the 12.0 SDK, 2 of the trailing UIntPtrs on 64-bit and
// 4 of them on 32-bit were replaced by two uint64_ts. On 32-bit, that
// awkwardly straddles end_v14. Since macOS 12.0 is 64-bit only, the proctype
// version of this struct only has these uint64_ts in the 64-bit version.
PROCESS_TYPE_STRUCT_MEMBER(UIntPtr, reserved, [4]) PROCESS_TYPE_STRUCT_MEMBER(UIntPtr, reserved, [4])
PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_4_64) PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_4_64)
PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_5) PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_5)
PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_6) PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_6)
PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_7) PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, shared_cache_fs_id)
PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, reserved_8) PROCESS_TYPE_STRUCT_MEMBER(Reserved64_64Only, shared_cache_fs_obj_id)
PROCESS_TYPE_STRUCT_MEMBER(Nothing, end_v14) PROCESS_TYPE_STRUCT_MEMBER(Nothing, end_v14)
PROCESS_TYPE_STRUCT_MEMBER(Reserved32_32Only, reserved_4_32) PROCESS_TYPE_STRUCT_MEMBER(Reserved32_32Only, reserved_4_32)

View File

@ -356,8 +356,16 @@ TEST(ProcessTypes, DyldImagesSelf) {
self_image_infos->reserved[4]); self_image_infos->reserved[4]);
EXPECT_EQ(proctype_image_infos.reserved_5, self_image_infos->reserved[5]); EXPECT_EQ(proctype_image_infos.reserved_5, self_image_infos->reserved[5]);
EXPECT_EQ(proctype_image_infos.reserved_6, self_image_infos->reserved[6]); EXPECT_EQ(proctype_image_infos.reserved_6, self_image_infos->reserved[6]);
EXPECT_EQ(proctype_image_infos.reserved_7, self_image_infos->reserved[7]); #if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0
EXPECT_EQ(proctype_image_infos.reserved_8, self_image_infos->reserved[8]); uint64_t shared_cache_fs_id = self_image_infos->sharedCacheFSID;
uint64_t shared_cache_fs_obj_id = self_image_infos->sharedCacheFSObjID;
#else
uint64_t shared_cache_fs_id = self_image_infos->reserved[7];
uint64_t shared_cache_fs_obj_id = self_image_infos->reserved[8];
#endif
EXPECT_EQ(proctype_image_infos.shared_cache_fs_id, shared_cache_fs_id);
EXPECT_EQ(proctype_image_infos.shared_cache_fs_obj_id,
shared_cache_fs_obj_id);
#endif #endif
} }
#endif #endif