From: Ian Lance Taylor Date: Wed, 8 Oct 2014 23:17:34 +0000 (-0700) Subject: cmd/ld: don't add line number info for the final address of an FDE X-Git-Tag: go1.4beta1~154 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=060b24006a7efbd4ec9d966759482428a421cbe8;p=gostls13.git cmd/ld: don't add line number info for the final address of an FDE This makes dwardump --verify happy. Update #8846 LGTM=r R=golang-codereviews, r CC=golang-codereviews https://golang.org/cl/150370043 --- diff --git a/src/cmd/ld/dwarf.c b/src/cmd/ld/dwarf.c index 4efb0ed537..a3ba523253 100644 --- a/src/cmd/ld/dwarf.c +++ b/src/cmd/ld/dwarf.c @@ -1733,6 +1733,7 @@ writeframes(void) LSym *s; vlong fdeo, fdesize, pad; Pciter pcsp; + uint32 nextpc; if(framesec == S) framesec = linklookup(ctxt, ".dwarfframe", 0); @@ -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;