* config/tc-alpha.c (alpha_force_relocation): Don't assert that
[binutils.git] / gprof / sparc.c
bloba8896046cfaf69121d9ed67fc77bde55e05c4cf4
1 /*
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that: (1) source distributions retain this entire copyright
7 * notice and comment, and (2) distributions including binaries display
8 * the following acknowledgement: ``This product includes software
9 * developed by the University of California, Berkeley and its contributors''
10 * in the documentation or other materials provided with the distribution
11 * and in all advertising materials mentioning features or use of this
12 * software. Neither the name of the University nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 #include "gprof.h"
20 #include "search_list.h"
21 #include "source.h"
22 #include "symtab.h"
23 #include "cg_arcs.h"
24 #include "corefile.h"
25 #include "hist.h"
28 * opcode of the `callf' instruction
30 #define CALL (0xc0000000)
32 void sparc_find_call PARAMS ((Sym *, bfd_vma, bfd_vma));
34 void
35 sparc_find_call (parent, p_lowpc, p_highpc)
36 Sym *parent;
37 bfd_vma p_lowpc;
38 bfd_vma p_highpc;
40 bfd_vma pc, dest_pc;
41 unsigned int insn;
42 Sym *child;
44 if (core_text_space == 0)
46 return;
48 if (p_lowpc < s_lowpc)
50 p_lowpc = s_lowpc;
52 if (p_highpc > s_highpc)
54 p_highpc = s_highpc;
56 DBG (CALLDEBUG, printf ("[find_call] %s: 0x%lx to 0x%lx\n",
57 parent->name, (unsigned long) p_lowpc,
58 (unsigned long) p_highpc));
59 for (pc = (p_lowpc + 3) & ~(bfd_vma) 3; pc < p_highpc; pc += 4)
61 insn = bfd_get_32 (core_bfd, ((unsigned char *) core_text_space
62 + pc - core_text_sect->vma));
63 if (insn & CALL)
65 DBG (CALLDEBUG,
66 printf ("[find_call] 0x%lx: callf", (unsigned long) pc));
68 * Regular pc relative addressing check that this is the
69 * address of a function.
71 dest_pc = pc + (((bfd_signed_vma) (insn & 0x3fffffff)
72 ^ 0x20000000) - 0x20000000);
73 if (dest_pc >= s_lowpc && dest_pc <= s_highpc)
75 child = sym_lookup (&symtab, dest_pc);
76 DBG (CALLDEBUG,
77 printf ("\tdest_pc=0x%lx, (name=%s, addr=0x%lx)\n",
78 (unsigned long) dest_pc, child->name,
79 (unsigned long) child->addr));
80 if (child->addr == dest_pc)
82 /* a hit: */
83 arc_add (parent, child, (unsigned long) 0);
84 continue;
88 * Something funny going on.
90 DBG (CALLDEBUG, printf ("\tbut it's a botch\n"));