@@ -2579,6 +2579,11 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
25792579 if dt .BitSize > 0 {
25802580 fatalf ("%s: unexpected: %d-bit int type - %s" , lineno (pos ), dt .BitSize , dtype )
25812581 }
2582+
2583+ if t .Align = t .Size ; t .Align >= c .ptrSize {
2584+ t .Align = c .ptrSize
2585+ }
2586+
25822587 switch t .Size {
25832588 default :
25842589 fatalf ("%s: unexpected: %d-byte int type - %s" , lineno (pos ), t .Size , dtype )
@@ -2595,9 +2600,8 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
25952600 Len : c .intExpr (t .Size ),
25962601 Elt : c .uint8 ,
25972602 }
2598- }
2599- if t .Align = t .Size ; t .Align >= c .ptrSize {
2600- t .Align = c .ptrSize
2603+ // t.Align is the alignment of the Go type.
2604+ t .Align = 1
26012605 }
26022606
26032607 case * dwarf.PtrType :
@@ -2826,6 +2830,11 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
28262830 if dt .BitSize > 0 {
28272831 fatalf ("%s: unexpected: %d-bit uint type - %s" , lineno (pos ), dt .BitSize , dtype )
28282832 }
2833+
2834+ if t .Align = t .Size ; t .Align >= c .ptrSize {
2835+ t .Align = c .ptrSize
2836+ }
2837+
28292838 switch t .Size {
28302839 default :
28312840 fatalf ("%s: unexpected: %d-byte uint type - %s" , lineno (pos ), t .Size , dtype )
@@ -2842,9 +2851,8 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
28422851 Len : c .intExpr (t .Size ),
28432852 Elt : c .uint8 ,
28442853 }
2845- }
2846- if t .Align = t .Size ; t .Align >= c .ptrSize {
2847- t .Align = c .ptrSize
2854+ // t.Align is the alignment of the Go type.
2855+ t .Align = 1
28482856 }
28492857
28502858 case * dwarf.VoidType :
@@ -3110,10 +3118,11 @@ func (c *typeConv) Struct(dt *dwarf.StructType, pos token.Pos) (expr *ast.Struct
31103118 }
31113119
31123120 // Round off up to talign, assumed to be a power of 2.
3121+ origOff := off
31133122 off = (off + talign - 1 ) &^ (talign - 1 )
31143123
31153124 if f .ByteOffset > off {
3116- fld , sizes = c .pad (fld , sizes , f .ByteOffset - off )
3125+ fld , sizes = c .pad (fld , sizes , f .ByteOffset - origOff )
31173126 off = f .ByteOffset
31183127 }
31193128 if f .ByteOffset < off {
0 commit comments