The code that handles -fdump-go-spec was incorrectly trying to pad the
last field of a struct/union to the alignment of the overall
struct/union.  That is unnecessary and incorrect, as the alignment is
handled by go_force_record_alignment anyhow.  It caused a compiler
crash on x32 and various other 32-bit targets when generating the Go
version of the libffi ffi_closure type, which is explicitly aligned to
an 8 byte boundary but does not necessarily have that size.  This
caused PRs 78431 and 78432.  Ran bootstrap and Go testsuite on
x86_64-pc-linux-gnu, with x32 multilib enabled.  Committed to
mainline.

Ian

PR go/78431
PR go/78432
* godump.c (go_format_type): Always pass alignment as 1 when
calling go_append_padding at end of struct/union.
Index: gcc/godump.c
===================================================================
--- gcc/godump.c        (revision 242724)
+++ gcc/godump.c        (working copy)
@@ -1006,14 +1006,9 @@ go_format_type (struct godump_container
              }
          }
        /* Padding.  */
-       {
-         unsigned int align_unit;
-
-         align_unit = (is_anon_record_or_union) ? 1 : TYPE_ALIGN_UNIT (type);
-         *p_art_i = go_append_padding
-           (ob, prev_field_end, TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type)),
-            align_unit, *p_art_i, &prev_field_end);
-       }
+       *p_art_i = go_append_padding (ob, prev_field_end,
+                                     TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type)),
+                                     1, *p_art_i, &prev_field_end);
        /* Alignment.  */
        if (!is_anon_record_or_union
            && known_alignment < TYPE_ALIGN_UNIT (type))

Reply via email to