]> Cypherpunks repositories - gostls13.git/commit
cmd/ld: fix off-by-one in DWARF frame tables
authorRob Pike <r@golang.org>
Mon, 7 Jul 2014 23:07:24 +0000 (16:07 -0700)
committerRob Pike <r@golang.org>
Mon, 7 Jul 2014 23:07:24 +0000 (16:07 -0700)
commit7b0ee5342919908e1a6b91d7c92a530ef45f5824
tree7a0361b40a993e26372102c2ec56eaf9562ae039
parentc1c8c3c8c4194de357d1be925b2b70f6fc88b72e
cmd/ld: fix off-by-one in DWARF frame tables
The code generating the .debug_frame section emits pairs of "advance PC",
"set SP offset" pseudo-instructions. Before the fix, the PC advance comes
out before the SP setting, which means the emitted offset for a block is
actually the value at the end of the block, which is incorrect for the
block itself.

The easiest way to fix this problem is to emit the SP offset before the
PC advance.

One delicate point: the last instruction to come out is now an
"advance PC", which means that if there are padding intsructions after
the final RET, they will appear to have a non-zero offset. This is odd
but harmless because there is no legal way to have a PC in that range,
or to put it another way, if you get here the SP is certainly screwed up
so getting the wrong (virtual) frame pointer is the least of your worries.

LGTM=iant
R=rsc, iant, lvd
CC=golang-codereviews
https://golang.org/cl/112750043
src/cmd/ld/dwarf.c