aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2025-01-17 00:23:45 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2025-01-17 00:54:47 +0100
commitd740694ff89ab5c78652a1f66b058ca16634ddbc (patch)
tree25c5cb3839da05635103e7fe146ba61b4c5ec321
parent15a7544e09d81fd35edcc32adc08e494e4debcc2 (diff)
downloadgcc-d740694ff89ab5c78652a1f66b058ca16634ddbc.zip
gcc-d740694ff89ab5c78652a1f66b058ca16634ddbc.tar.gz
gcc-d740694ff89ab5c78652a1f66b058ca16634ddbc.tar.bz2
d: Fix record layout of compiler-generated TypeInfo_Class [PR115249]
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. PR d/115249 gcc/d/ChangeLog: * typeinfo.cc (create_tinfo_types): Update internal Typenfo representation. (TypeInfoVisitor::visit (TypeInfoClassDeclaration *)): Likewise.
-rw-r--r--gcc/d/typeinfo.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc
index 66cfa2c..f548451 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)