|
17 | 17 |
|
18 | 18 | #include "sanitizer_common/sanitizer_common.h"
|
19 | 19 | #include "sanitizer_common/sanitizer_ptrauth.h"
|
| 20 | +#include <stdint.h> |
20 | 21 |
|
21 | 22 | // The following are intended to be binary compatible with the definitions
|
22 | 23 | // given in the Itanium ABI. We make no attempt to be ODR-compatible with
|
|
25 | 26 | namespace std {
|
26 | 27 | class type_info {
|
27 | 28 | public:
|
| 29 | + typedef const char *__type_name_t; |
28 | 30 | virtual ~type_info();
|
29 | 31 |
|
30 | 32 | const char *__type_name;
|
| 33 | + |
| 34 | + __type_name_t name() const { |
| 35 | +#if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__) |
| 36 | + uintptr_t __non_unique_rtti_bit = |
| 37 | + (1ULL << ((__CHAR_BIT__ * sizeof(__type_name_t)) - 1)); |
| 38 | + return (__type_name_t)((uintptr_t)__type_name & ~__non_unique_rtti_bit); |
| 39 | +#else |
| 40 | + return __type_name; |
| 41 | +#endif |
| 42 | + } |
31 | 43 | };
|
32 | 44 | }
|
33 | 45 |
|
@@ -117,7 +129,7 @@ static __ubsan::HashValue *getTypeCacheHashTableBucket(__ubsan::HashValue V) {
|
117 | 129 | static bool isDerivedFromAtOffset(const abi::__class_type_info *Derived,
|
118 | 130 | const abi::__class_type_info *Base,
|
119 | 131 | sptr Offset) {
|
120 |
| - if (Derived->__type_name == Base->__type_name || |
| 132 | + if (Derived->name() == Base->name() || |
121 | 133 | __ubsan::checkTypeInfoEquality(Derived, Base))
|
122 | 134 | return Offset == 0;
|
123 | 135 |
|
@@ -254,17 +266,16 @@ __ubsan::getDynamicTypeInfoFromVtable(void *VtablePtr) {
|
254 | 266 | const abi::__class_type_info *ObjectType = findBaseAtOffset(
|
255 | 267 | static_cast<const abi::__class_type_info*>(Vtable->TypeInfo),
|
256 | 268 | -Vtable->Offset);
|
257 |
| - return DynamicTypeInfo(Vtable->TypeInfo->__type_name, -Vtable->Offset, |
258 |
| - ObjectType ? ObjectType->__type_name : "<unknown>"); |
| 269 | + return DynamicTypeInfo(Vtable->TypeInfo->name(), -Vtable->Offset, |
| 270 | + ObjectType ? ObjectType->name() : "<unknown>"); |
259 | 271 | }
|
260 | 272 |
|
261 | 273 | bool __ubsan::checkTypeInfoEquality(const void *TypeInfo1,
|
262 | 274 | const void *TypeInfo2) {
|
263 | 275 | auto TI1 = static_cast<const std::type_info *>(TypeInfo1);
|
264 | 276 | auto TI2 = static_cast<const std::type_info *>(TypeInfo2);
|
265 |
| - return SANITIZER_NON_UNIQUE_TYPEINFO && TI1->__type_name[0] != '*' && |
266 |
| - TI2->__type_name[0] != '*' && |
267 |
| - !internal_strcmp(TI1->__type_name, TI2->__type_name); |
| 277 | + return SANITIZER_NON_UNIQUE_TYPEINFO && TI1->name()[0] != '*' && |
| 278 | + TI2->name()[0] != '*' && !internal_strcmp(TI1->name(), TI2->name()); |
268 | 279 | }
|
269 | 280 |
|
270 | 281 | #endif // CAN_SANITIZE_UB && !SANITIZER_WINDOWS
|
0 commit comments