aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Harmstone <mark@harmstone.com>2024-07-20 20:12:30 +0100
committerThomas Koenig <tkoenig@gcc.gnu.org>2024-07-28 19:05:49 +0200
commit98fa2f48b5f91a6ac2bb8329de53a456da1015f2 (patch)
tree8fa82480a5c36981f751d2d2a8d97a366e3b82d4
parente13081bf2db7d755a8de99cb67eb395dc2f1decb (diff)
downloadgcc-98fa2f48b5f91a6ac2bb8329de53a456da1015f2.zip
gcc-98fa2f48b5f91a6ac2bb8329de53a456da1015f2.tar.gz
gcc-98fa2f48b5f91a6ac2bb8329de53a456da1015f2.tar.bz2
Output CodeView type information for references
Translates DW_TAG_reference_type DIEs into LF_POINTER types. gcc/ * dwarf2codeview.cc (get_type_num_reference_type): New function. (get_type_num_array_type): Add DW_TAG_reference_type to switch. (get_type_num): Handle DW_TAG_reference_type DIEs. * dwarf2codeview.h (CV_PTR_MODE_LVREF): Define.
-rw-r--r--gcc/dwarf2codeview.cc44
-rw-r--r--gcc/dwarf2codeview.h1
2 files changed, 45 insertions, 0 deletions
diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc
index c174f32..2317520 100644
--- a/gcc/dwarf2codeview.cc
+++ b/gcc/dwarf2codeview.cc
@@ -2293,6 +2293,45 @@ get_type_num_pointer_type (dw_die_ref type, bool in_struct)
return ct->num;
}
+/* Process a DW_TAG_reference_type DIE, add a new LF_POINTER type, and return
+ its number. */
+
+static uint32_t
+get_type_num_reference_type (dw_die_ref type, bool in_struct)
+{
+ uint32_t base_type_num, byte_size;
+ dw_die_ref base_type;
+ codeview_custom_type *ct;
+
+ byte_size = get_AT_unsigned (type, DW_AT_byte_size);
+ if (byte_size != 4 && byte_size != 8)
+ return 0;
+
+ base_type = get_AT_ref (type, DW_AT_type);
+
+ base_type_num = get_type_num (base_type, in_struct, false);
+ if (base_type_num == 0)
+ return 0;
+
+ ct = (codeview_custom_type *) xmalloc (sizeof (codeview_custom_type));
+
+ ct->next = NULL;
+ ct->kind = LF_POINTER;
+ ct->lf_pointer.base_type = base_type_num;
+ ct->lf_pointer.attributes = CV_PTR_MODE_LVREF;
+
+ if (byte_size == 4)
+ ct->lf_pointer.attributes |= CV_PTR_NEAR32;
+ else
+ ct->lf_pointer.attributes |= CV_PTR_64;
+
+ ct->lf_pointer.attributes |= byte_size << 13;
+
+ add_custom_type (ct);
+
+ return ct->num;
+}
+
/* Process a DW_TAG_const_type DIE, adding an LF_MODIFIER type and returning
its number. */
@@ -3024,6 +3063,7 @@ get_type_num_array_type (dw_die_ref type, bool in_struct)
case DW_TAG_class_type:
case DW_TAG_union_type:
case DW_TAG_pointer_type:
+ case DW_TAG_reference_type:
size = get_AT_unsigned (t, DW_AT_byte_size);
break;
@@ -3151,6 +3191,10 @@ get_type_num (dw_die_ref type, bool in_struct, bool no_fwd_ref)
num = get_type_num_pointer_type (type, in_struct);
break;
+ case DW_TAG_reference_type:
+ num = get_type_num_reference_type (type, in_struct);
+ break;
+
case DW_TAG_const_type:
num = get_type_num_const_type (type, in_struct);
break;
diff --git a/gcc/dwarf2codeview.h b/gcc/dwarf2codeview.h
index 8fd3632..7d4e3ab 100644
--- a/gcc/dwarf2codeview.h
+++ b/gcc/dwarf2codeview.h
@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see
/* LF_POINTER attributes. */
#define CV_PTR_NEAR32 0x0a
#define CV_PTR_64 0x0c
+#define CV_PTR_MODE_LVREF 0x20
/* LF_MODIFIER values. */
#define MOD_const 0x1