Closed kovdan01 closed 8 months ago
A question arises here if explicitly and implicitly signed pointers with identical effective signing schemas should have the same Dwarf info. As for now, I suppose that we can use the same info for simplicity, but if it's expected that such types should be treated different, the Dwarf info should be different as well.
With #64 applied, we have DW_TAG_LLVM_ptrauth_type
emitted containing signing schema and reference to the actual pointer type for the following implicitly signed pointers:
For virtual function pointers, things are a bit different. We do not have the virtual table as a thing in IR debug metadata nodes and in Dwarf info. Instead, we only have an artificial member of a polymorphic class which holds the pointer to the table, and an attribute for virtual functions holding their position in the table. So, there is no object with DW_TAG_pointer_type
which can be wrapped with DW_TAG_LLVM_ptrauth_type
to mark underlying function as signed and specify the schema.
A possible solution is to propose a new attribute for DW_TAG_subprogram
instances having DW_AT_virtuality
other than DW_VIRTUALITY_none
. This attribute would hold a reference to a DW_TAG_LLVM_ptrauth_type
with the desired signing schema.
For both signed virtual table pointers and signed virtual function pointers in the table, we should teach the debugger to look at the corresponding attributes and apply the requested signing schema when constructing user expressions. For free and member function pointers, this should be transparent since we just changed the type and a __ptrauth
specifier with parameters corresponding to the signing schema would be added to the pointer type when construction a user expression.
Tagging @ahmedbougacha
Closing with the same reason as related #64 (should have been closed together with that): https://github.com/access-softek/llvm-project/pull/64#issuecomment-1909335683
In f28e8dbbbd445af8ec0c720aa8fe96214e3a9ce7,
DW_TAG_LLVM_ptrauth_type
and corresponding attributes were introduced. However, those are only emitted for explicitly signed pointers (those with explicit__ptrauth
specifier).Consider the following code:
When building for a Linux target with
-mbranch-protection=pauthabi
(or for an Apple's arm64e), we get the following Dwarf info (unrelated parts omitted):So, only pointer
b
is listed in Dwarf info as signed, whiley
is not. However, for bothb
andy
signedR_AARCH64_AUTH_ABS64
relocations are emitted, so they are actually both signed (as expected when using-mbranch-protection=pauthabi
).The same issue also applies to other implicitly signed pointers (by implicitly we here mean without explicit
__ptrauth
specifier): pointers to member functions, vtable pointers, function pointers with are signed at runtime instead of a relocation.The fix should include changes in functions declared in
llvm/include/llvm/IR/DIBuilder.h
, such asDIBuilder::createClassType
. Now, we haveDIBuilder::createPtrAuthQualifiedType
which is only applied to pointers with__ptrauth
specifier.