Merge branch 'master' into mracek/arm64e

This commit is contained in:
Kuba (Brecka) Mracek
2020-03-06 15:07:01 -08:00
committed by GitHub
264 changed files with 12893 additions and 2795 deletions

View File

@@ -21,6 +21,10 @@
#include <cstring>
#if defined(__APPLE__) && defined(__MACH__)
#include <TargetConditionals.h>
#endif
namespace swift {
namespace remote {
@@ -29,28 +33,62 @@ namespace remote {
class InProcessMemoryReader final : public MemoryReader {
bool queryDataLayout(DataLayoutQueryType type, void *inBuffer,
void *outBuffer) override {
switch (type) {
case DLQ_GetPointerSize: {
auto result = static_cast<uint8_t *>(outBuffer);
*result = sizeof(void *);
return true;
}
case DLQ_GetSizeSize: {
auto result = static_cast<uint8_t *>(outBuffer);
*result = sizeof(size_t);
return true;
}
case DLQ_GetPtrAuthMask: {
auto result = static_cast<uintptr_t *>(outBuffer);
#if __has_feature(ptrauth_calls)
*result = (uintptr_t)ptrauth_strip((void*)0x0007ffffffffffff, 0);
#if defined(__APPLE__) && __APPLE__
auto applePlatform = true;
#else
*result = (uintptr_t)~0ull;
auto applePlatform = false;
#endif
#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV))
auto iosDerivedPlatform = true;
#else
auto iosDerivedPlatform = false;
#endif
return true;
}
}
switch (type) {
case DLQ_GetPointerSize: {
auto result = static_cast<uint8_t *>(outBuffer);
*result = sizeof(void *);
return true;
}
case DLQ_GetSizeSize: {
auto result = static_cast<uint8_t *>(outBuffer);
*result = sizeof(size_t);
return true;
}
case DLQ_GetPtrAuthMask: {
auto result = static_cast<uintptr_t *>(outBuffer);
#if __has_feature(ptrauth_calls)
*result = (uintptr_t)ptrauth_strip((void*)0x0007ffffffffffff, 0);
#else
*result = (uintptr_t)~0ull;
#endif
return true;
}
case DLQ_GetObjCReservedLowBits: {
auto result = static_cast<uint8_t *>(outBuffer);
if (applePlatform && !iosDerivedPlatform && (sizeof(void *) == 8)) {
// Obj-C reserves low bit on 64-bit macOS only.
// Other Apple platforms don't reserve this bit (even when
// running on x86_64-based simulators).
*result = 1;
} else {
*result = 0;
}
return true;
}
case DLQ_GetLeastValidPointerValue: {
auto result = static_cast<uint64_t *>(outBuffer);
if (applePlatform && (sizeof(void *) == 8)) {
// Swift reserves the first 4GiB on Apple 64-bit platforms
*result = 0x100000000;
return 1;
} else {
// Swift reserves the first 4KiB everywhere else
*result = 0x1000;
}
return true;
}
}
return false;
}