Skip to content

Implement DLQ_GetPtrAuthMask using info from debugserver. … #4110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lldb/source/Plugins/LanguageRuntime/Swift/LLDBMemoryReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ namespace lldb_private {
bool LLDBMemoryReader::queryDataLayout(DataLayoutQueryType type, void *inBuffer,
void *outBuffer) {
switch (type) {
// FIXME: add support for case DLQ_GetPtrAuthMask rdar://70729149
case DLQ_GetPtrAuthMask:
return false;
case DLQ_GetPtrAuthMask: {
assert(m_process.GetCodeAddressMask() == m_process.GetDataAddressMask() &&
"not supported");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: different code and address masks are not supported?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this code know if the mask returned is used for data or for code addresses? Linux standardized on the code/data masks, but I don't think the distinction is possible in AArch64, I'm not sure what target motivated that choice. I think a sanity check of ensuring that they're the same, if we don't know what this mask might be used for, is correct.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The swift::reflection::MemoryReader API doesn't distinguish between the two.

lldb::addr_t ptrauth_mask = m_process.GetCodeAddressMask();
if (!ptrauth_mask)
return false;
// The mask returned by the process masks out the non-addressable bits.
uint64_t mask_pattern = ~ptrauth_mask;
memcpy(outBuffer, &mask_pattern, sizeof(uint64_t));
return true;
}
case DLQ_GetObjCReservedLowBits: {
auto *result = static_cast<uint8_t *>(outBuffer);
auto &triple = m_process.GetTarget().GetArchitecture().GetTriple();
Expand Down