Skip to content

Strip authentication bits from vtable load address #71128

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

Conversation

jasonmolenda
Copy link
Collaborator

The current Darwin arm64e ABI on AArch64 systems using ARMv8.3 & newer cores, adds authentication bits to the vtable pointer address. The vtable address must be in addressable memory, so running it through Process::FixDataAddress will be a no-op on other targets.

This was originally a downstream change that I hadn't upstreamed yet, and it was surfaced by Greg's changes in
#67599
so I needed to update the local patch, and was reminded that I should upstream this.

The current Darwin arm64e ABI on AArch64 systems using ARMv8.3 &
newer cores, adds authentication bits to the vtable pointer address.
The vtable address must be in addressable memory, so running it
through Process::FixDataAddress will be a no-op on other targets.

This was originally a downstream change that I hadn't upstreamed
yet, and it was surfaced by Greg's changes in
llvm#67599
so I needed to update the local patch, and was reminded that I
should upstream this.
@llvmbot
Copy link
Member

llvmbot commented Nov 3, 2023

@llvm/pr-subscribers-lldb

Author: Jason Molenda (jasonmolenda)

Changes

The current Darwin arm64e ABI on AArch64 systems using ARMv8.3 & newer cores, adds authentication bits to the vtable pointer address. The vtable address must be in addressable memory, so running it through Process::FixDataAddress will be a no-op on other targets.

This was originally a downstream change that I hadn't upstreamed yet, and it was surfaced by Greg's changes in
#67599
so I needed to update the local patch, and was reminded that I should upstream this.


Full diff: https://github.com/llvm/llvm-project/pull/71128.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (+5-2)
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
index 17c8b43578691c0..6c763ea1558feb1 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -235,14 +235,17 @@ llvm::Expected<LanguageRuntime::VTableInfo>
                                    "failed to get the address of the value");
 
   Status error;
-  const lldb::addr_t vtable_load_addr =
+  lldb::addr_t vtable_load_addr =
       process->ReadPointerFromMemory(original_ptr, error);
 
   if (!error.Success() || vtable_load_addr == LLDB_INVALID_ADDRESS)
     return llvm::createStringError(std::errc::invalid_argument,
         "failed to read vtable pointer from memory at 0x%" PRIx64,
         original_ptr);
-;
+
+  // The vtable load address can have authentication bits with
+  // AArch64 targets on Darwin.
+  vtable_load_addr = process->FixDataAddress(vtable_load_addr);
 
   // Find the symbol that contains the "vtable_load_addr" address
   Address vtable_addr;

@DavidSpickett
Copy link
Collaborator

I'm assuming lack of new tests is because testing is running existing tests on arm64e. LGTM.

@jasonmolenda
Copy link
Collaborator Author

I'm assuming lack of new tests is because testing is running existing tests on arm64e. LGTM.

Yeah, lldb can't get the dynamic type in any function that takes a base class argument but a subclass object is passed in (and they have virtual functions), there's tests for that already. But running the testsuite for arm64e requires some boot-args be set so we can't do it on the CI bots yet.

@jasonmolenda jasonmolenda merged commit de24b0e into llvm:main Nov 3, 2023
@jasonmolenda jasonmolenda deleted the strip-authentication-bits-from-vtable-address branch November 3, 2023 23:26
Michael137 pushed a commit to Michael137/llvm-project that referenced this pull request Dec 15, 2023
The current Darwin arm64e ABI on AArch64 systems using ARMv8.3 & newer
cores, adds authentication bits to the vtable pointer address. The
vtable address must be in addressable memory, so running it through
Process::FixDataAddress will be a no-op on other targets.

This was originally a downstream change that I hadn't upstreamed yet,
and it was surfaced by Greg's changes in
llvm#67599
so I needed to update the local patch, and was reminded that I should
upstream this.

(cherry picked from commit de24b0e)
Michael137 pushed a commit to Michael137/llvm-project that referenced this pull request Jan 18, 2024
The current Darwin arm64e ABI on AArch64 systems using ARMv8.3 & newer
cores, adds authentication bits to the vtable pointer address. The
vtable address must be in addressable memory, so running it through
Process::FixDataAddress will be a no-op on other targets.

This was originally a downstream change that I hadn't upstreamed yet,
and it was surfaced by Greg's changes in
llvm#67599
so I needed to update the local patch, and was reminded that I should
upstream this.

(cherry picked from commit de24b0e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants