diff options
author | Anthony Martin <ality@pbrane.org> | 2014-04-16 22:42:02 -0400 |
---|---|---|
committer | Anthony Martin <ality@pbrane.org> | 2014-04-16 22:42:02 -0400 |
commit | 68b93659c996ce2b5fed292c71fc01fe5b1c41cf (patch) | |
tree | 110d95850cdcc9ff7e1cfc3e6a8f70d83e4ce7b6 /src/cmd | |
parent | 1cf1c76235b80ac7c85214e8c37ebe006c30f623 (diff) | |
download | go-68b93659c996ce2b5fed292c71fc01fe5b1c41cf.tar.gz |
cmd/ld: restore the call graph dump
Before the switch to liblink, the linkers accepted the -c flag
to print the call graph. This change restores the functionality.
This came in handy when I was trying to audit the use of SSE
instructions inside the Plan 9 note handler.
LGTM=rsc
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews
https://codereview.appspot.com/73990043
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/ld/lib.c | 21 | ||||
-rw-r--r-- | src/cmd/ld/lib.h | 1 | ||||
-rw-r--r-- | src/cmd/ld/pobj.c | 1 |
3 files changed, 23 insertions, 0 deletions
diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c index 585a4c66a..78b8cf2ba 100644 --- a/src/cmd/ld/lib.c +++ b/src/cmd/ld/lib.c @@ -1484,6 +1484,27 @@ undef(void) } void +callgraph(void) +{ + LSym *s; + Reloc *r; + int i; + + if(!debug['c']) + return; + + for(s = ctxt->textp; s != nil; s = s->next) { + for(i=0; i<s->nr; i++) { + r = &s->r[i]; + if(r->sym == nil) + continue; + if((r->type == R_CALL || r->type == R_CALLARM) && r->sym->type == STEXT) + Bprint(&bso, "%s calls %s\n", s->name, r->sym->name); + } + } +} + +void diag(char *fmt, ...) { char buf[1024], *tn, *sep; diff --git a/src/cmd/ld/lib.h b/src/cmd/ld/lib.h index b4551a090..7267c6371 100644 --- a/src/cmd/ld/lib.h +++ b/src/cmd/ld/lib.h @@ -178,6 +178,7 @@ void asmplan9sym(void); uint16 be16(uchar *b); uint32 be32(uchar *b); uint64 be64(uchar *b); +void callgraph(void); void cflush(void); void codeblk(int32 addr, int32 size); vlong cpos(void); diff --git a/src/cmd/ld/pobj.c b/src/cmd/ld/pobj.c index 8276fb706..819c37954 100644 --- a/src/cmd/ld/pobj.c +++ b/src/cmd/ld/pobj.c @@ -164,6 +164,7 @@ main(int argc, char *argv[]) } deadcode(); + callgraph(); paramspace = "SP"; /* (FP) now (SP) on output */ doelf(); |