diff options
author | Anthony Martin <ality@pbrane.org> | 2014-04-16 22:42:02 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-04-16 22:42:02 -0400 |
commit | 1e2a61aee19e9f327950a19131b1349ebb5240e6 (patch) | |
tree | da74dd4092d0114063a38b4aefedfd99a4d8b41c | |
parent | 6f2d91a094c78165646ddaa0c139191f6943c7d2 (diff) | |
download | go-1e2a61aee19e9f327950a19131b1349ebb5240e6.tar.gz go-1e2a61aee19e9f327950a19131b1349ebb5240e6.zip |
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://golang.org/cl/73990043
-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 585a4c66a2..78b8cf2bad 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 b4551a0908..7267c63713 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 8276fb7066..819c37954a 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(); |