Hi,
This is the backport of r15-6983 to releases/gcc-14.
In r14-8766, the layout of TypeInfo_Class changed in the runtime
library, but didn't get reflected in the compiler-generated data,
causing a corruption of runtime type introspection on BigEndian targets.
This adjusts the size of the `ClassFlags' field from uint to ushort, and
adds a new ushort `depth' field in the space where ClassFlags used to
occupy.
Bootstrapped and regression tested on x86_64-pc-linux-gnu and
sparcv9-sun-solaris2.11, committed to releases/gcc-14.
Regards,
Iain.
---
PR d/115249
gcc/d/ChangeLog:
* typeinfo.cc (create_tinfo_types): Update internal Typenfo
representation.
(TypeInfoVisitor::visit (TypeInfoClassDeclaration *)): Likewise.
(cherry picked from commit d740694ff89ab5c78652a1f66b058ca16634ddbc)
---
gcc/d/typeinfo.cc | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc
index cadcbe8164e..aa702892c4d 100644
--- a/gcc/d/typeinfo.cc
+++ b/gcc/d/typeinfo.cc
@@ -258,10 +258,10 @@ create_tinfo_types (Module *mod)
Identifier::idPool ("TypeInfo_Class"),
array_type_node, array_type_node, array_type_node,
array_type_node, ptr_type_node, ptr_type_node,
- ptr_type_node, d_uint_type, ptr_type_node,
- array_type_node, ptr_type_node, ptr_type_node,
- d_uint_type, d_uint_type, d_uint_type, d_uint_type,
- NULL);
+ ptr_type_node, d_ushort_type, d_ushort_type,
+ ptr_type_node, array_type_node, ptr_type_node,
+ ptr_type_node, d_uint_type, d_uint_type, d_uint_type,
+ d_uint_type, NULL);
object_module = mod;
}
@@ -813,6 +813,7 @@ public:
void *destructor;
void function(Object) classInvariant;
ClassFlags m_flags;
+ ushort depth;
void *deallocator;
OffsetTypeInfo[] m_offTi;
void function(Object) defaultConstructor;
@@ -918,7 +919,10 @@ public:
flags |= ClassFlags::noPointers;
Lhaspointers:
- this->layout_field (build_integer_cst (flags, d_uint_type));
+ this->layout_field (build_integer_cst (flags, d_ushort_type));
+
+ /* ushort depth; (not implemented) */
+ this->layout_field (build_zero_cst (d_ushort_type));
/* void *deallocator; */
this->layout_field (null_pointer_node);
@@ -979,7 +983,10 @@ public:
if (cd->isCOMinterface ())
flags |= ClassFlags::isCOMclass;
- this->layout_field (build_integer_cst (flags, d_uint_type));
+ this->layout_field (build_integer_cst (flags, d_ushort_type));
+
+ /* ushort depth; (not implemented) */
+ this->layout_field (build_zero_cst (d_ushort_type));
/* void *deallocator;
OffsetTypeInfo[] m_offTi; (not implemented)
--
2.43.0