This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Use TASK_VM_INFO to get the maximum VM address on iOS/AArch64
ClosedPublic

Authored by kubamracek on Jul 5 2017, 1:59 PM.

Details

Summary

We currently hardcode the maximum VM address on iOS/AArch64, which is not really correct and this value changes between device configurations. Let's use TASK_VM_INFO to retrieve the maximum VM address dynamically.

The patch manually declares some constants, which would normally be provided in a header file by the SDK, but since this API is only declared in a recent SDK and we want to continue supporting building against older SDKs, the patch declares the constants manually.

Diff Detail

Repository
rL LLVM

Event Timeline

kubamracek created this revision.Jul 5 2017, 1:59 PM
eugenis added inline comments.Jul 5 2017, 4:54 PM
lib/sanitizer_common/sanitizer_mac.cc
812 ↗(On Diff #105333)

Why use pointer cast, and not just load an integer_t and static_cast to uptr? Are they always the same width?

filcab added inline comments.Jul 6 2017, 5:17 AM
lib/sanitizer_common/sanitizer_mac.cc
808 ↗(On Diff #105333)

Shouldn't this be a task_vm_info_data_t? Or is that not available?
As far as I can tell, integer_t are int, and we're not guaranteed to have this array properly aligned for that uptr load.

If it's not available, I'm ok with a stub somewhere, but I'd make this either a properly-sized and aligned struct, or a uptr array (proper alignment, AFAICT) and cast its pointer when calling task_info.

824 ↗(On Diff #105333)

Why not static uptr max_vm = GetTaskInfoMaxAddress();?

kubamracek marked 3 inline comments as done.
kubamracek added inline comments.
lib/sanitizer_common/sanitizer_mac.cc
808 ↗(On Diff #105333)

task_vm_info_data_t can't be used because we need to access a field that's only available in a new version of the SDK, and we still want to be able to build with the older SDKs.

You're right about the int/integer_t/uptr confusion. The new version should be more clear.

This revision was automatically updated to reflect the committed changes.