Skip to content

Commit

Permalink
cmd/ld: don't add line number info for the final address of an FDE
Browse files Browse the repository at this point in the history
This makes dwardump --verify happy.

Update golang#8846

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/150370043
  • Loading branch information
ianlancetaylor authored and wheatman committed Jul 9, 2018
1 parent 62064f5 commit 3fcbabc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/cmd/ld/dwarf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,7 @@ writeframes(void)
LSym *s;
vlong fdeo, fdesize, pad;
Pciter pcsp;
uint32 nextpc;

if(framesec == S)
framesec = linklookup(ctxt, ".dwarfframe", 0);
Expand Down Expand Up @@ -1775,8 +1776,17 @@ writeframes(void)
addrput(0); // initial location
addrput(0); // address range

for(pciterinit(ctxt, &pcsp, &s->pcln->pcsp); !pcsp.done; pciternext(&pcsp))
putpccfadelta(pcsp.nextpc - pcsp.pc, PtrSize + pcsp.value);
for(pciterinit(ctxt, &pcsp, &s->pcln->pcsp); !pcsp.done; pciternext(&pcsp)) {
nextpc = pcsp.nextpc;
// pciterinit goes up to the end of the function,
// but DWARF expects us to stop just before the end.
if(nextpc == s->size) {
nextpc--;
if(nextpc < pcsp.pc)
continue;
}
putpccfadelta(nextpc - pcsp.pc, PtrSize + pcsp.value);
}

fdesize = cpos() - fdeo - 4; // exclude the length field.
pad = rnd(fdesize, PtrSize) - fdesize;
Expand Down

0 comments on commit 3fcbabc

Please sign in to comment.