cmd/ld: fix off-by-one error in DWARF .debug_line transcription
The liblink refactor changed the DWARF .debug_line flow control. The mapping was off by one pcline entry. The fix here preserves pc until it can be compared to pcline.pc. Sample dwarfdump .debug_line output for main.main from the program in issue 7351, before liblink (correct): 0x0000003c: 00 Extended: <9> 02 DW_LNE_set_address( 0x0000000000002000 ) 0x00000047: 03 DW_LNS_advance_line( 6 ) 0x00000049: 01 DW_LNS_copy 0x0000000000002000 1 7 0 is_stmt 0x0000004a: 8b address += 21, line += 1 0x0000000000002021 1 8 0 is_stmt 0x0000004b: 02 DW_LNS_advance_pc( 153 ) 0x0000004e: 03 DW_LNS_advance_line( 1 ) 0x00000050: 01 DW_LNS_copy 0x00000000000020ba 1 9 0 is_stmt After liblink (off by one entry): 0x00001bbf: 00 Extended: <9> 02 DW_LNE_set_address( 0x0000000000002000 ) 0x00001bca: 02 DW_LNS_advance_pc( 33 ) 0x00001bcc: 03 DW_LNS_advance_line( 6 ) 0x00001bce: 01 DW_LNS_copy 0x0000000000002021 1 7 0 is_stmt 0x00001bcf: 02 DW_LNS_advance_pc( 153 ) 0x00001bd2: 03 DW_LNS_advance_line( 1 ) 0x00001bd4: 01 DW_LNS_copy 0x00000000000020ba 1 8 0 is_stmt 0x00001bd5: 02 DW_LNS_advance_pc( 153 ) 0x00001bd8: 03 DW_LNS_advance_line( 1 ) 0x00001bda: 01 DW_LNS_copy 0x0000000000002153 1 9 0 is_stmt After this CL (the line 9 pc offset changed due to intervening compiler changes): 0x00001d07: 00 Extended: <9> 02 DW_LNE_set_address( 0x0000000000002000 ) 0x00001d12: 03 DW_LNS_advance_line( 6 ) 0x00001d14: 01 DW_LNS_copy 0x0000000000002000 1 7 0 is_stmt 0x00001d15: 8b address += 21, line += 1 0x0000000000002021 1 8 0 is_stmt 0x00001d16: 02 DW_LNS_advance_pc( 189 ) 0x00001d19: 03 DW_LNS_advance_line( 1 ) 0x00001d1b: 01 DW_LNS_copy 0x00000000000020de 1 9 0 is_stmt Fixes #7351. LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/66290043
Showing
Please register or sign in to comment