9d7fa835d004530df1db1872a540235e4bf0cd11
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
)
54 return usesreg
!= PC
? autoinc
: immediate
;
56 return usesreg
!= PC
? autoincdef
: absolute
;
58 return usesreg
!= PC
? bytedisp
: byterel
;
60 return usesreg
!= PC
? bytedispdef
: bytereldef
;
62 return usesreg
!= PC
? worddisp
: wordrel
;
64 return usesreg
!= PC
? worddispdef
: wordreldef
;
66 return usesreg
!= PC
? longdisp
: longrel
;
68 return usesreg
!= PC
? longdispdef
: longreldef
;
87 return "register deferred";
89 return "autodecrement";
91 return "autoincrement";
93 return "autoincrement deferred";
95 return "byte displacement";
97 return "byte displacement deferred";
99 return "byte relative";
101 return "byte relative deferred";
103 return "word displacement";
105 return "word displacement deferred";
107 return "word relative";
109 return "word relative deferred";
115 return "long displacement";
117 return "long displacement deferred";
119 return "long relative";
121 return "long relative deferred";
127 operandlength (modep
)
128 struct modebyte
*modep
;
131 switch (operandmode (modep
))
158 return 1 + operandlength ((struct modebyte
*) ((char *) modep
) + 1);
165 struct modebyte
*modep
;
167 operandenum mode
= operandmode (modep
);
173 ++cp
; /* skip over the mode */
177 fprintf (stderr
, "[reladdr] not relative address\n");
178 return (bfd_vma
) modep
;
180 return (bfd_vma
) (cp
+ sizeof *cp
+ *cp
);
183 return (bfd_vma
) (cp
+ sizeof *sp
+ *sp
);
186 return (bfd_vma
) (cp
+ sizeof *lp
+ *lp
);
192 find_call (parent
, p_lowpc
, p_highpc
)
197 unsigned char *instructp
;
201 operandenum firstmode
;
203 static bool inited
= FALSE
;
208 sym_init (&indirectchild
);
209 indirectchild
.cg
.prop
.fract
= 1.0;
210 indirectchild
.cg
.cyc
.head
= &indirectchild
;
213 if (core_text_space
== 0)
217 if (p_lowpc
< s_lowpc
)
221 if (p_highpc
> s_highpc
)
225 DBG (CALLDEBUG
, printf ("[findcall] %s: 0x%lx to 0x%lx\n",
226 parent
->name
, p_lowpc
, p_highpc
));
227 for (instructp
= (unsigned char *) core_text_space
+ p_lowpc
;
228 instructp
< (unsigned char *) core_text_space
+ p_highpc
;
232 if (*instructp
== CALLS
)
235 * maybe a calls, better check it out.
236 * skip the count of the number of arguments.
239 printf ("[findcall]\t0x%x:calls",
240 instructp
- (unsigned char *) core_text_space
));
241 firstmode
= operandmode ((struct modebyte
*) (instructp
+ length
));
250 length
+= operandlength ((struct modebyte
*) (instructp
+ length
));
251 mode
= operandmode ((struct modebyte
*) (instructp
+ length
));
253 printf ("\tfirst operand is %s", operandname (firstmode
));
254 printf ("\tsecond operand is %s\n", operandname (mode
)));
265 * indirect call: call through pointer
266 * either *d(r) as a parameter or local
267 * (r) as a return value
268 * *f as a global pointer
269 * [are there others that we miss?,
270 * e.g. arrays of pointers to functions???]
272 arc_add (parent
, &indirectchild
, (long) 0);
273 length
+= operandlength (
274 (struct modebyte
*) (instructp
+ length
));
280 * regular pc relative addressing
281 * check that this is the address of
284 destpc
= reladdr ((struct modebyte
*) (instructp
+ length
))
285 - (bfd_vma
) core_text_space
;
286 if (destpc
>= s_lowpc
&& destpc
<= s_highpc
)
288 child
= sym_lookup (&symtab
, destpc
);
290 printf ("[findcall]\tdestpc 0x%lx", destpc
);
291 printf (" child->name %s", child
->name
);
292 printf (" child->addr 0x%lx\n", child
->addr
);
294 if (child
->addr
== destpc
)
299 arc_add (parent
, child
, (long) 0);
300 length
+= operandlength ((struct modebyte
*)
301 (instructp
+ length
));
308 * it looked like a calls,
309 * but it wasn't to anywhere.
315 * something funny going on.
317 DBG (CALLDEBUG
, printf ("[findcall]\tbut it's a botch\n"));
This page took 0.037246 seconds and 4 git commands to generate.