]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Output CodeView type information for references
authorMark Harmstone <mark@harmstone.com>
Sat, 20 Jul 2024 19:12:30 +0000 (20:12 +0100)
committerMark Harmstone <mark@harmstone.com>
Tue, 23 Jul 2024 23:51:13 +0000 (00:51 +0100)
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.

gcc/dwarf2codeview.cc
gcc/dwarf2codeview.h

index c174f3204803a528b22f01960f01018d5ae505cc..23175204acd344ff02516da40818b49476078494 100644 (file)
@@ -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;
index 8fd3632e524c3e1a3c66909f259406cbc8c6cf99..7d4e3ab1db435d76e5f6385c6f1a8d205d7941d7 100644 (file)
@@ -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