]> Cypherpunks repositories - gostls13.git/commit
[dev.link] cmd/{compile,link}: fix file/line of last instruction in DWARF line table
authorThan McIntosh <thanm@google.com>
Mon, 22 Jun 2020 17:26:15 +0000 (13:26 -0400)
committerThan McIntosh <thanm@google.com>
Wed, 24 Jun 2020 11:57:56 +0000 (11:57 +0000)
commitf0cf4d4d7f60ed5ae806e6ed410b346bb2fd0b5a
tree20fe8b32c4f7a1b62853c6f6d68f813f2810a25d
parentf547046850010e726dc179340fcc8b7b5c470155
[dev.link] cmd/{compile,link}: fix file/line of last instruction in DWARF line table

The code in the compiler's DWARF line table generation emits line
table ops at the end of each function fragment to reset the state
machine registers back to an initial state, so that when the line
table fragments for each function are stitched together into a
compilation unit, each fragment will have a clean starting point. The
set-file/set-line ops emitted in this code were being applied to the
last row of the line table, however, meaning that they were
overwriting the existing values.

To avoid this problem, add code to advance the PC past the end of the
last instruction in the function, and switch to just using an
end-of-sequence operator at the end of each function instead of
explicit set-file/set-line ops.

Updates #39757.

Change-Id: Ieb30f83444fa86fb1f2cd53862d8cc8972bb8763
Reviewed-on: https://go-review.googlesource.com/c/go/+/239286
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/internal/obj/dwarf.go
src/cmd/link/internal/ld/dwarf.go
src/cmd/link/internal/ld/dwarf_test.go
src/cmd/link/internal/ld/testdata/issue39757/issue39757main.go [new file with mode: 0644]