@@ -682,7 +682,7 @@ protected override void UpdateLayout(DwarfLayoutContext layoutContext)
682682 ulong sizeOf = 0 ;
683683
684684 // unit_length
685- sizeOf += DwarfHelper . SizeOfUInt ( Is64BitEncoding ) ;
685+ sizeOf += DwarfHelper . SizeOfUnitLength ( Is64BitEncoding ) ;
686686
687687 sizeOf += 2 ; // version (uhalf)
688688
@@ -691,18 +691,26 @@ protected override void UpdateLayout(DwarfLayoutContext layoutContext)
691691 ulong headerLengthStart = sizeOf ;
692692
693693 // minimum_instruction_length
694+ sizeOf ++ ;
695+
696+ if ( Version >= 4 )
697+ {
698+ // maximum_operations_per_instruction
699+ sizeOf ++ ;
700+ }
701+
694702 // default_is_stmt
695703 // line_base
696704 // line_range
697705 // opcode_base
698- sizeOf += 5 ;
706+ sizeOf += 4 ;
699707
700708 // StandardOpCodeLengths
701709 foreach ( var opcodeLength in _standardOpCodeLengths )
702710 {
703711 sizeOf += DwarfHelper . SizeOfULEB128 ( opcodeLength ) ;
704712 }
705-
713+
706714 // Write directory names
707715 _directoryNameToIndex . Clear ( ) ;
708716 _directoryNames . Clear ( ) ;
@@ -738,8 +746,8 @@ private void RecordDirectory(string directoryName, ref ulong sizeOf, out uint di
738746 {
739747 if ( ! _directoryNameToIndex . TryGetValue ( directoryName , out dirIndex ) )
740748 {
741- uint directoryIndex = ( uint ) _directoryNames . Count + 1 ;
742- _directoryNameToIndex . Add ( directoryName , directoryIndex ) ;
749+ dirIndex = ( uint ) _directoryNames . Count + 1 ;
750+ _directoryNameToIndex . Add ( directoryName , dirIndex ) ;
743751 sizeOf += ( ulong ) Encoding . UTF8 . GetByteCount ( directoryName ) + 1 ;
744752 _directoryNames . Add ( directoryName ) ;
745753 }
@@ -1365,4 +1373,4 @@ public override string ToString()
13651373 return $ "Section .debug_line, { nameof ( Version ) } : { Version } , { nameof ( Is64BitEncoding ) } : { Is64BitEncoding } , { nameof ( FileNames ) } : { FileNames . Count } , { nameof ( LineSequences ) } : { LineSequences . Count } ";
13661374 }
13671375 }
1368- }
1376+ }
0 commit comments