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
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
diag(char *fmt, ...)
{
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);
}
deadcode();
+ callgraph();
paramspace = "SP"; /* (FP) now (SP) on output */
doelf();