2 * Copyright (c) 1983 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.
27 * A symbol to be the child of indirect calls:
34 struct modebyte
*modep
;
36 long usesreg
= modep
->regfield
;
38 switch (modep
->modefield
) {
53 return usesreg
!= PC
? autoinc
: immediate
;
55 return usesreg
!= PC
? autoincdef
: absolute
;
57 return usesreg
!= PC
? bytedisp
: byterel
;
59 return usesreg
!= PC
? bytedispdef
: bytereldef
;
61 return usesreg
!= PC
? worddisp
: wordrel
;
63 return usesreg
!= PC
? worddispdef
: wordreldef
;
65 return usesreg
!= PC
? longdisp
: longrel
;
67 return usesreg
!= PC
? longdispdef
: longreldef
;
85 return "register deferred";
87 return "autodecrement";
89 return "autoincrement";
91 return "autoincrement deferred";
93 return "byte displacement";
95 return "byte displacement deferred";
97 return "byte relative";
99 return "byte relative deferred";
101 return "word displacement";
103 return "word displacement deferred";
105 return "word relative";
107 return "word relative deferred";
113 return "long displacement";
115 return "long displacement deferred";
117 return "long relative";
119 return "long relative deferred";
126 struct modebyte
*modep
;
129 switch (operandmode(modep
)) {
155 return 1+operandlength((struct modebyte
*) ((char *) modep
) + 1);
162 struct modebyte
*modep
;
164 operandenum mode
= operandmode(modep
);
170 ++cp
; /* skip over the mode */
173 fprintf(stderr
, "[reladdr] not relative address\n");
174 return (bfd_vma
) modep
;
176 return (bfd_vma
) (cp
+ sizeof *cp
+ *cp
);
179 return (bfd_vma
) (cp
+ sizeof *sp
+ *sp
);
182 return (bfd_vma
) (cp
+ sizeof *lp
+ *lp
);
188 find_call(parent
, p_lowpc
, p_highpc
)
193 unsigned char *instructp
;
197 operandenum firstmode
;
199 static bool inited
= FALSE
;
203 sym_init(&indirectchild
);
204 indirectchild
.cg
.prop
.fract
= 1.0;
205 indirectchild
.cg
.cyc
.head
= &indirectchild
;
208 if (core_text_space
== 0) {
211 if (p_lowpc
< s_lowpc
) {
214 if (p_highpc
> s_highpc
) {
217 DBG(CALLDEBUG
, printf("[findcall] %s: 0x%lx to 0x%lx\n",
218 parent
->name
, p_lowpc
, p_highpc
));
219 for ( instructp
= (unsigned char*) core_text_space
+ p_lowpc
;
220 instructp
< (unsigned char*) core_text_space
+ p_highpc
;
221 instructp
+= length
) {
223 if (*instructp
== CALLS
) {
225 * maybe a calls, better check it out.
226 * skip the count of the number of arguments.
229 printf("[findcall]\t0x%x:calls",
230 instructp
- (unsigned char*) core_text_space
));
231 firstmode
= operandmode((struct modebyte
*) (instructp
+length
));
239 length
+= operandlength((struct modebyte
*) (instructp
+length
));
240 mode
= operandmode((struct modebyte
*) (instructp
+ length
));
242 printf("\tfirst operand is %s", operandname(firstmode
));
243 printf("\tsecond operand is %s\n", operandname(mode
)));
253 * indirect call: call through pointer
254 * either *d(r) as a parameter or local
255 * (r) as a return value
256 * *f as a global pointer
257 * [are there others that we miss?,
258 * e.g. arrays of pointers to functions???]
260 arc_add(parent
, &indirectchild
, (long) 0);
261 length
+= operandlength(
262 (struct modebyte
*) (instructp
+ length
));
268 * regular pc relative addressing
269 * check that this is the address of
272 destpc
= reladdr((struct modebyte
*) (instructp
+length
))
273 - (bfd_vma
) core_text_space
;
274 if (destpc
>= s_lowpc
&& destpc
<= s_highpc
) {
275 child
= sym_lookup(&symtab
, destpc
);
277 printf("[findcall]\tdestpc 0x%lx", destpc
);
278 printf(" child->name %s", child
->name
);
279 printf(" child->addr 0x%lx\n", child
->addr
);
281 if (child
->addr
== destpc
) {
285 arc_add(parent
, child
, (long) 0);
286 length
+= operandlength((struct modebyte
*)
287 (instructp
+ length
));
294 * it looked like a calls,
295 * but it wasn't to anywhere.
301 * something funny going on.
303 DBG(CALLDEBUG
, printf("[findcall]\tbut it's a botch\n"));
This page took 0.039602 seconds and 5 git commands to generate.