[PATCH] D35032: [sanitizer] Use TASK_VM_INFO to get the maximum VM address on iOS/AArch64
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 6 13:30:37 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307307: [sanitizer] Use TASK_VM_INFO to get the maximum VM address on iOS/AArch64 (authored by kuba.brecka).
Changed prior to commit:
https://reviews.llvm.org/D35032?vs=105497&id=105518#toc
Repository:
rL LLVM
https://reviews.llvm.org/D35032
Files:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
@@ -799,13 +799,37 @@
char **GetArgv() {
return *_NSGetArgv();
}
+
+#if defined(__aarch64__) && SANITIZER_IOS && !SANITIZER_IOSSIM
+// The task_vm_info struct is normally provided by the macOS SDK, but we need
+// fields only available in 10.12+. Declare the struct manually to be able to
+// build against older SDKs.
+struct __sanitizer_task_vm_info {
+ uptr _unused[(SANITIZER_WORDSIZE == 32) ? 20 : 19];
+ uptr min_address;
+ uptr max_address;
+};
+
+uptr GetTaskInfoMaxAddress() {
+ __sanitizer_task_vm_info vm_info = {{0}, 0, 0};
+ mach_msg_type_number_t count = sizeof(vm_info) / sizeof(int);
+ int err = task_info(mach_task_self(), TASK_VM_INFO, (int *)&vm_info, &count);
+ if (err == 0) {
+ return vm_info.max_address;
+ } else {
+ // xnu cannot provide vm address limit
+ return 0x200000000 - 1;
+ }
+}
+#endif
uptr GetMaxVirtualAddress() {
#if SANITIZER_WORDSIZE == 64
# if defined(__aarch64__) && SANITIZER_IOS && !SANITIZER_IOSSIM
- // Ideally, we would derive the upper bound from MACH_VM_MAX_ADDRESS. The
- // upper bound can change depending on the device.
- return 0x200000000 - 1;
+ // Get the maximum VM address
+ static uptr max_vm = GetTaskInfoMaxAddress();
+ CHECK(max_vm);
+ return max_vm;
# else
return (1ULL << 47) - 1; // 0x00007fffffffffffUL;
# endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35032.105518.patch
Type: text/x-patch
Size: 1572 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170706/73f8fff8/attachment.bin>
More information about the llvm-commits
mailing list