Commit 1e2a61ae authored by Anthony Martin's avatar Anthony Martin Committed by Russ Cox

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
parent 6f2d91a0
...@@ -1483,6 +1483,27 @@ undef(void) ...@@ -1483,6 +1483,27 @@ undef(void)
errorexit(); errorexit();
} }
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 void
diag(char *fmt, ...) diag(char *fmt, ...)
{ {
......
...@@ -178,6 +178,7 @@ void asmplan9sym(void); ...@@ -178,6 +178,7 @@ void asmplan9sym(void);
uint16 be16(uchar *b); uint16 be16(uchar *b);
uint32 be32(uchar *b); uint32 be32(uchar *b);
uint64 be64(uchar *b); uint64 be64(uchar *b);
void callgraph(void);
void cflush(void); void cflush(void);
void codeblk(int32 addr, int32 size); void codeblk(int32 addr, int32 size);
vlong cpos(void); vlong cpos(void);
......
...@@ -164,6 +164,7 @@ main(int argc, char *argv[]) ...@@ -164,6 +164,7 @@ main(int argc, char *argv[])
} }
deadcode(); deadcode();
callgraph();
paramspace = "SP"; /* (FP) now (SP) on output */ paramspace = "SP"; /* (FP) now (SP) on output */
doelf(); doelf();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment