Skip to content

Commit 0ce7732

Browse files
committed
[Reflection] Switch Remote Mirror back to uintptr_t for pointers on watchOS.
Existing Remote Mirror dylibs are compiled this way, and changing it breaks binary compatibility. We want to use uint64_t everywhere else, since the target's pointer size may not match ours. rdar://problem/50279443
1 parent 0bc0979 commit 0ce7732

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

include/swift/SwiftRemoteMirror/SwiftRemoteMirrorTypes.h

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,23 @@
2424
extern "C" {
2525
#endif
2626

27-
typedef uint64_t swift_typeref_t;
27+
// Pointers used here need to be pointer-sized on watchOS for binary
28+
// compatibility. Everywhere else, they are 64-bit so 32-bit processes can
29+
// potentially read from 64-bit processes.
30+
#if defined(__APPLE__) && defined(__MACH__)
31+
#include <Availability.h>
32+
#if TARGET_OS_WATCH
33+
#define SWIFT_REFLECTION_NATIVE_POINTERS 1
34+
#endif
35+
#endif
36+
37+
#if SWIFT_REFLECTION_NATIVE_POINTERS
38+
typedef uintptr_t swift_reflection_ptr_t;
39+
#else
40+
typedef uint64_t swift_reflection_ptr_t;
41+
#endif
42+
43+
typedef swift_reflection_ptr_t swift_typeref_t;
2844

2945
/// Represents one of the Swift reflection sections of an image.
3046
typedef struct swift_reflection_section {
@@ -37,37 +53,37 @@ typedef struct swift_reflection_section {
3753
typedef struct swift_reflection_info {
3854
struct {
3955
swift_reflection_section_t section;
40-
uint64_t offset;
56+
swift_reflection_ptr_t offset;
4157
} field;
4258

4359
struct {
4460
swift_reflection_section_t section;
45-
uint64_t offset;
61+
swift_reflection_ptr_t offset;
4662
} associated_types;
4763

4864
struct {
4965
swift_reflection_section_t section;
50-
uint64_t offset;
66+
swift_reflection_ptr_t offset;
5167
} builtin_types;
5268

5369
struct {
5470
swift_reflection_section_t section;
55-
uint64_t offset;
71+
swift_reflection_ptr_t offset;
5672
} capture;
5773

5874
struct {
5975
swift_reflection_section_t section;
60-
uint64_t offset;
76+
swift_reflection_ptr_t offset;
6177
} type_references;
6278

6379
struct {
6480
swift_reflection_section_t section;
65-
uint64_t offset;
81+
swift_reflection_ptr_t offset;
6682
} reflection_strings;
6783

6884
// Start address in local and remote address spaces.
69-
uint64_t LocalStartAddress;
70-
uint64_t RemoteStartAddress;
85+
swift_reflection_ptr_t LocalStartAddress;
86+
swift_reflection_ptr_t RemoteStartAddress;
7187
} swift_reflection_info_t;
7288

7389
/// The layout kind of a Swift type.

0 commit comments

Comments
 (0)