[Lldb-commits] [lldb] [lldb] Support arm64e in TestClearSBValueNonAddressableBits.py (PR #194748)
Jason Molenda via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 28 22:11:14 PDT 2026
================
@@ -54,6 +54,14 @@ def test(self):
main_p = frame.FindVariable("main_p")
main_invalid_p = frame.FindVariable("main_invalid_p")
- self.assertEqual(
- main_p.GetValueAsUnsigned(), main_invalid_p.GetValueAsAddress()
- )
+ if self.getArchitecture() in ["arm64e"]:
+ # On arm64e, main_p.GetValueAsUnsigned() will have all the pointer
+ # metadata in it whereas main_invalid_p will have all the metadata
+ # stripped.
----------------
jasonmolenda wrote:
I think this comment is a little misleading
```
int (*main_p)() = main;
scratch = (intptr_t)main_p;
scratch |= (3ULL << 60);
int (*main_invalid_p)() = (int (*)())scratch;
```
We're getting a function pointer to `main`, OR'ing a bit in the top byte, and putting it in `main_invalid_p`, and then comparing that `main_invalid_p.GetValueAsAddress()` removes the non-addressable bit we just set.
The reason this fails on arm64e is that `main_p` _already_ has metadata in it - the PAC pointer signing. `main_invalid_p` has an extra bit also set in the top byte, plus the PAC signing. `main_p.GetValueAsUnsigned(), main_invalid_p.GetValueAsAddress()` is taking main() + ptrauth, and comparing it to main() + ptrauth + extra top byte bit, stripped to just addressable bits, so just main(). main+ptrauth is not the same as main(), so the test fails, when the inferior is built for arm64e aka ptrauth.
I think a more correct fix is to remove the conditional based on arch (which is not going to work correctly if it was run on aarch64 linux with PAC, idk if they do that though) and instead do
```
self.assertEqual(main_p.GetValueAsAddress(), main_invalid_p.GetValueAsAddress())
```
what do you think?
https://github.com/llvm/llvm-project/pull/194748
More information about the lldb-commits
mailing list