2 * Copyright (c) 1983, 1998 Regents of the University of California.
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.
26 * Opcodes of the call instructions:
31 #define Jxx_FUNC_JMP 0
32 #define Jxx_FUNC_JSR 1
33 #define Jxx_FUNC_RET 2
34 #define Jxx_FUNC_JSR_COROUTINE 3
50 b
; /* branch format */
63 static Sym indirect_child
;
67 * On the Alpha we can only detect PC relative calls, which are
68 * usually generated for calls to functions within the same
69 * object file only. This is still better than nothing, however.
70 * (In particular it should be possible to find functions that
71 * potentially call integer division routines, for example.)
74 alpha_find_call (parent
, p_lowpc
, p_highpc
)
79 static bfd_vma delta
= 0;
81 alpha_Instruction
*pc
;
86 delta
= (bfd_vma
) core_text_space
- core_text_sect
->vma
;
88 sym_init (&indirect_child
);
89 indirect_child
.name
= _("<indirect child>");
90 indirect_child
.cg
.prop
.fract
= 1.0;
91 indirect_child
.cg
.cyc
.head
= &indirect_child
;
98 if (p_lowpc
< s_lowpc
)
102 if (p_highpc
> s_highpc
)
106 DBG (CALLDEBUG
, printf (_("[find_call] %s: 0x%lx to 0x%lx\n"),
107 parent
->name
, (unsigned long) p_lowpc
,
108 (unsigned long) p_highpc
));
109 for (pc
= (alpha_Instruction
*) (p_lowpc
+ delta
);
110 pc
< (alpha_Instruction
*) (p_highpc
+ delta
);
113 switch (pc
->a
.op_code
)
117 * There is no simple and reliable way to determine the
118 * target of a jsr (the hint bits help, but there aren't
119 * enough bits to get a satisfactory hit rate). Instead,
120 * for any indirect jump we simply add an arc from PARENT
121 * to INDIRECT_CHILD---that way the user it at least able
122 * to see that there are other calls as well.
124 if (pc
->j
.func
== Jxx_FUNC_JSR
125 || pc
->j
.func
== Jxx_FUNC_JSR_COROUTINE
)
128 printf (_("[find_call] 0x%lx: jsr%s <indirect_child>\n"),
129 (unsigned long) pc
- delta
,
130 pc
->j
.func
== Jxx_FUNC_JSR
? "" : "_coroutine"));
131 arc_add (parent
, &indirect_child
, (unsigned long) 0);
137 printf (_("[find_call] 0x%lx: bsr"),
138 (unsigned long) pc
- delta
));
140 * Regular PC relative addressing. Check that this is the
141 * address of a function. The linker sometimes redirects
142 * the entry point by 8 bytes to skip loading the global
143 * pointer, so we all for either address:
145 dest_pc
= ((bfd_vma
) (pc
+ 1 + pc
->b
.disp
)) - delta
;
146 if (dest_pc
>= s_lowpc
&& dest_pc
<= s_highpc
)
148 child
= sym_lookup (&symtab
, dest_pc
);
150 printf (" 0x%lx\t; name=%s, addr=0x%lx",
151 (unsigned long) dest_pc
, child
->name
,
152 (unsigned long) child
->addr
));
153 if (child
->addr
== dest_pc
|| child
->addr
== dest_pc
- 8)
155 DBG (CALLDEBUG
, printf ("\n"));
157 arc_add (parent
, child
, (unsigned long) 0);
162 * Something funny going on.
164 DBG (CALLDEBUG
, printf ("\tbut it's a botch\n"));