summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2011-09-08 10:55:54 +1000
committerAndrew Gerrand <adg@golang.org>2011-09-08 10:55:54 +1000
commitb8ea7950ff8ca7c4b1078ec137ed1645fe443772 (patch)
treefd6de920ad751ae72178326427c8e2eac5ec02a4
parent96963422c934a6ef40fb8b1866d373e9ad1155fe (diff)
downloadgo-b8ea7950ff8ca7c4b1078ec137ed1645fe443772.tar.gz
[release-branch.r60] gc: fix pc/line table
??? CL 4938042 / 5671737303a0 gc: fix pc/line table When a line directive was encountered we would push a new 'z' entry into the history to indicate the start of new file attributation, and a 'Z' entry to change line numbering. However we didn't pop the 'z' entry, so we were actually corrupting the history stack. The most obvious occurance of this was in the code that build the symbol tables for the DWARF information - where an internal stack in the linker would overflow when more than a few line directives were encountered in a single stack (Issue 1878). So now we pop the 'z' entry when we encounter the end of the file that the directive was in, which maintains the history stack integrity. Also, although new 'z' entries for new files had relative paths expanded, the same was not done for line directives. Now we do it for line directives also - so that the now correct DWARF information has the full path available. Fixes issue 1878. R=rsc CC=golang-dev http://codereview.appspot.com/4938042 Committer: Russ Cox <rsc@golang.org> ??? R=golang-dev CC=golang-dev http://codereview.appspot.com/4973069
-rw-r--r--src/cmd/gc/obj.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cmd/gc/obj.c b/src/cmd/gc/obj.c
index f34fc76c8..456aabb88 100644
--- a/src/cmd/gc/obj.c
+++ b/src/cmd/gc/obj.c
@@ -127,6 +127,7 @@ static void
outhist(Biobuf *b)
{
Hist *h;
+ int i, depth = 0;
char *p, ds[] = {'c', ':', '/', 0};
for(h = hist; h != H; h = h->link) {
@@ -156,13 +157,21 @@ outhist(Biobuf *b)
outzfile(b, p+1);
} else {
// relative name, like dir/file.go
- if(h->offset == 0 && pathname && pathname[0] == '/') {
+ if(h->offset >= 0 && pathname && pathname[0] == '/') {
zfile(b, "/", 1); // leading "/"
outzfile(b, pathname+1);
}
outzfile(b, p);
}
}
+ if(h->offset > 0) {
+ //line directive
+ depth++;
+ }
+ } else if(depth > 0) {
+ for(i = 0; i < depth; i++)
+ zhist(b, h->line, h->offset);
+ depth = 0;
}
zhist(b, h->line, h->offset);
}