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.
20 #include "search_list.h"
28 * Opcodes of the call instructions:
33 #define Jxx_FUNC_JMP 0
34 #define Jxx_FUNC_JSR 1
35 #define Jxx_FUNC_RET 2
36 #define Jxx_FUNC_JSR_COROUTINE 3
39 /* Here to document only. We can't use this when cross compiling as
40 the bitfield layout might not be the same as native. */
55 b
; /* branch format */
69 static Sym indirect_child
;
71 void alpha_find_call
PARAMS ((Sym
*, bfd_vma
, bfd_vma
));
74 * On the Alpha we can only detect PC relative calls, which are
75 * usually generated for calls to functions within the same
76 * object file only. This is still better than nothing, however.
77 * (In particular it should be possible to find functions that
78 * potentially call integer division routines, for example.)
81 alpha_find_call (parent
, p_lowpc
, p_highpc
)
90 if (indirect_child
.name
== NULL
)
92 sym_init (&indirect_child
);
93 indirect_child
.name
= _("<indirect child>");
94 indirect_child
.cg
.prop
.fract
= 1.0;
95 indirect_child
.cg
.cyc
.head
= &indirect_child
;
102 if (p_lowpc
< s_lowpc
)
106 if (p_highpc
> s_highpc
)
110 DBG (CALLDEBUG
, printf (_("[find_call] %s: 0x%lx to 0x%lx\n"),
111 parent
->name
, (unsigned long) p_lowpc
,
112 (unsigned long) p_highpc
));
113 for (pc
= (p_lowpc
+ 3) & ~(bfd_vma
) 3; pc
< p_highpc
; pc
+= 4)
115 insn
= bfd_get_32 (core_bfd
, ((unsigned char *) core_text_space
116 + pc
- core_text_sect
->vma
));
117 switch (insn
& (0x3f << 26))
121 * There is no simple and reliable way to determine the
122 * target of a jsr (the hint bits help, but there aren't
123 * enough bits to get a satisfactory hit rate). Instead,
124 * for any indirect jump we simply add an arc from PARENT
125 * to INDIRECT_CHILD---that way the user it at least able
126 * to see that there are other calls as well.
128 if ((insn
& (3 << 14)) == Jxx_FUNC_JSR
<< 14
129 || (insn
& (3 << 14)) == Jxx_FUNC_JSR_COROUTINE
<< 14)
132 printf (_("[find_call] 0x%lx: jsr%s <indirect_child>\n"),
134 ((insn
& (3 << 14)) == Jxx_FUNC_JSR
<< 14
135 ? "" : "_coroutine")));
136 arc_add (parent
, &indirect_child
, (unsigned long) 0);
142 printf (_("[find_call] 0x%lx: bsr"), (unsigned long) pc
));
144 * Regular PC relative addressing. Check that this is the
145 * address of a function. The linker sometimes redirects
146 * the entry point by 8 bytes to skip loading the global
147 * pointer, so we allow for either address:
149 dest_pc
= pc
+ 4 + (((bfd_signed_vma
) (insn
& 0x1fffff)
150 ^ 0x100000) - 0x100000);
151 if (dest_pc
>= s_lowpc
&& dest_pc
<= s_highpc
)
153 child
= sym_lookup (&symtab
, dest_pc
);
155 printf (" 0x%lx\t; name=%s, addr=0x%lx",
156 (unsigned long) dest_pc
, child
->name
,
157 (unsigned long) child
->addr
));
158 if (child
->addr
== dest_pc
|| child
->addr
== dest_pc
- 8)
160 DBG (CALLDEBUG
, printf ("\n"));
162 arc_add (parent
, child
, (unsigned long) 0);
167 * Something funny going on.
169 DBG (CALLDEBUG
, printf ("\tbut it's a botch\n"));
This page took 0.033029 seconds and 4 git commands to generate.