1 /* unwind-ia64.c -- utility routines to dump IA-64 unwind info for readelf.
2 Copyright (C) 2000-2015 Free Software Foundation, Inc.
4 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
6 This file is part of GNU Binutils.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
24 #include "unwind-ia64.h"
29 /* Define BFD64 here, even if our default architecture is 32 bit ELF
30 as this will allow us to read in and parse 64bit and 32bit ELF files.
31 Only do this if we believe that the compiler can support a 64 bit
32 data type. For now we only rely on GCC being able to do this. */
37 static bfd_vma unw_rlen = 0;
39 static void unw_print_brmask (char *, unsigned int);
40 static void unw_print_grmask (char *, unsigned int);
41 static void unw_print_frmask (char *, unsigned int);
42 static void unw_print_abreg (char *, unsigned int);
43 static void unw_print_xyreg (char *, unsigned int, unsigned int);
46 unw_print_brmask (char *cp, unsigned int mask)
51 for (i = 0; mask && (i < 5); ++i)
67 unw_print_grmask (char *cp, unsigned int mask)
72 for (i = 0; i < 4; ++i)
88 unw_print_frmask (char *cp, unsigned int mask)
93 for (i = 0; i < 20; ++i)
104 *cp++ = (i + 2) / 10 + 1 + '0';
105 *cp++ = (i + 2) % 10 + '0';
115 unw_print_abreg (char *cp, unsigned int abreg)
117 static const char * const special_reg[16] =
119 "pr", "psp", "@priunat", "rp", "ar.bsp", "ar.bspstore", "ar.rnat",
120 "ar.unat", "ar.fpsr", "ar.pfs", "ar.lc",
121 "Unknown11", "Unknown12", "Unknown13", "Unknown14", "Unknown15"
124 switch ((abreg >> 5) & 0x3)
127 sprintf (cp, "r%u", (abreg & 0x1f));
131 sprintf (cp, "f%u", (abreg & 0x1f));
135 sprintf (cp, "b%u", (abreg & 0x1f));
138 case 3: /* special */
139 strcpy (cp, special_reg[abreg & 0xf]);
145 unw_print_xyreg (char *cp, unsigned int x, unsigned int ytreg)
147 switch ((x << 1) | ((ytreg >> 7) & 1))
150 sprintf (cp, "r%u", (ytreg & 0x1f));
154 sprintf (cp, "f%u", (ytreg & 0x1f));
158 sprintf (cp, "b%u", (ytreg & 0x1f));
163 #define UNW_REG_BSP "bsp"
164 #define UNW_REG_BSPSTORE "bspstore"
165 #define UNW_REG_FPSR "fpsr"
166 #define UNW_REG_LC "lc"
167 #define UNW_REG_PFS "pfs"
168 #define UNW_REG_PR "pr"
169 #define UNW_REG_PSP "psp"
170 #define UNW_REG_RNAT "rnat"
171 #define UNW_REG_RP "rp"
172 #define UNW_REG_UNAT "unat"
174 typedef bfd_vma unw_word;
176 #define UNW_DEC_BAD_CODE(code) \
177 printf ("Unknown code 0x%02x\n", code)
179 #define UNW_DEC_PROLOGUE(fmt, body, rlen, arg) \
183 *(int *)arg = body; \
184 printf (" %s:%s(rlen=%lu)\n", \
185 fmt, body ? "body" : "prologue", (unsigned long) rlen); \
189 #define UNW_DEC_PROLOGUE_GR(fmt, rlen, mask, grsave, arg) \
192 char regname[16], maskstr[64], *sep; \
201 strcat (maskstr, "rp"); \
206 strcat (maskstr, sep); \
207 strcat (maskstr, "ar.pfs"); \
212 strcat (maskstr, sep); \
213 strcat (maskstr, "psp"); \
218 strcat (maskstr, sep); \
219 strcat (maskstr, "pr"); \
221 sprintf (regname, "r%u", grsave); \
222 printf (" %s:prologue_gr(mask=[%s],grsave=%s,rlen=%lu)\n", \
223 fmt, maskstr, regname, (unsigned long) rlen); \
227 #define UNW_DEC_FR_MEM(fmt, frmask, arg) \
232 unw_print_frmask (frstr, frmask); \
233 printf ("\t%s:fr_mem(frmask=[%s])\n", fmt, frstr); \
237 #define UNW_DEC_GR_MEM(fmt, grmask, arg) \
242 unw_print_grmask (grstr, grmask); \
243 printf ("\t%s:gr_mem(grmask=[%s])\n", fmt, grstr); \
247 #define UNW_DEC_FRGR_MEM(fmt, grmask, frmask, arg) \
250 char frstr[200], grstr[20]; \
252 unw_print_grmask (grstr, grmask); \
253 unw_print_frmask (frstr, frmask); \
254 printf ("\t%s:frgr_mem(grmask=[%s],frmask=[%s])\n", fmt, grstr, frstr); \
258 #define UNW_DEC_BR_MEM(fmt, brmask, arg) \
263 unw_print_brmask (brstr, brmask); \
264 printf ("\t%s:br_mem(brmask=[%s])\n", fmt, brstr); \
268 #define UNW_DEC_BR_GR(fmt, brmask, gr, arg) \
273 unw_print_brmask (brstr, brmask); \
274 printf ("\t%s:br_gr(brmask=[%s],gr=r%u)\n", fmt, brstr, gr); \
278 #define UNW_DEC_REG_GR(fmt, src, dst, arg) \
279 printf ("\t%s:%s_gr(reg=r%u)\n", fmt, src, dst)
281 #define UNW_DEC_RP_BR(fmt, dst, arg) \
282 printf ("\t%s:rp_br(reg=b%u)\n", fmt, dst)
284 #define UNW_DEC_REG_WHEN(fmt, reg, t, arg) \
285 printf ("\t%s:%s_when(t=%lu)\n", fmt, reg, (unsigned long) t)
287 #define UNW_DEC_REG_SPREL(fmt, reg, spoff, arg) \
288 printf ("\t%s:%s_sprel(spoff=0x%lx)\n", \
289 fmt, reg, 4*(unsigned long)spoff)
291 #define UNW_DEC_REG_PSPREL(fmt, reg, pspoff, arg) \
292 printf ("\t%s:%s_psprel(pspoff=0x10-0x%lx)\n", \
293 fmt, reg, 4*(unsigned long)pspoff)
295 #define UNW_DEC_GR_GR(fmt, grmask, gr, arg) \
300 unw_print_grmask (grstr, grmask); \
301 printf ("\t%s:gr_gr(grmask=[%s],r%u)\n", fmt, grstr, gr); \
305 #define UNW_DEC_ABI(fmt, abi, context, arg) \
308 static const char * const abiname[] = \
310 "@svr4", "@hpux", "@nt" \
313 const char *abistr = buf; \
316 abistr = abiname[abi]; \
318 sprintf (buf, "0x%x", abi); \
319 printf ("\t%s:unwabi(abi=%s,context=0x%02x)\n", \
320 fmt, abistr, context); \
324 #define UNW_DEC_PRIUNAT_GR(fmt, r, arg) \
325 printf ("\t%s:priunat_gr(reg=r%u)\n", fmt, r)
327 #define UNW_DEC_PRIUNAT_WHEN_GR(fmt, t, arg) \
328 printf ("\t%s:priunat_when_gr(t=%lu)\n", fmt, (unsigned long) t)
330 #define UNW_DEC_PRIUNAT_WHEN_MEM(fmt, t, arg) \
331 printf ("\t%s:priunat_when_mem(t=%lu)\n", fmt, (unsigned long) t)
333 #define UNW_DEC_PRIUNAT_PSPREL(fmt, pspoff, arg) \
334 printf ("\t%s:priunat_psprel(pspoff=0x10-0x%lx)\n", \
335 fmt, 4*(unsigned long)pspoff)
337 #define UNW_DEC_PRIUNAT_SPREL(fmt, spoff, arg) \
338 printf ("\t%s:priunat_sprel(spoff=0x%lx)\n", \
339 fmt, 4*(unsigned long)spoff)
341 #define UNW_DEC_MEM_STACK_F(fmt, t, size, arg) \
342 printf ("\t%s:mem_stack_f(t=%lu,size=%lu)\n", \
343 fmt, (unsigned long) t, 16*(unsigned long)size)
345 #define UNW_DEC_MEM_STACK_V(fmt, t, arg) \
346 printf ("\t%s:mem_stack_v(t=%lu)\n", fmt, (unsigned long) t)
348 #define UNW_DEC_SPILL_BASE(fmt, pspoff, arg) \
349 printf ("\t%s:spill_base(pspoff=0x10-0x%lx)\n", \
350 fmt, 4*(unsigned long)pspoff)
352 #define UNW_DEC_SPILL_MASK(fmt, dp, arg) \
355 static const char *spill_type = "-frb"; \
356 unsigned const char *imaskp = dp; \
357 unsigned char mask = 0; \
360 printf ("\t%s:spill_mask(imask=[", fmt); \
361 for (insn = 0; insn < unw_rlen; ++insn) \
363 if ((insn % 4) == 0) \
365 if (insn > 0 && (insn % 3) == 0) \
367 putchar (spill_type[(mask >> (2 * (3 - (insn & 0x3)))) & 0x3]); \
374 #define UNW_DEC_SPILL_SPREL(fmt, t, abreg, spoff, arg) \
379 unw_print_abreg (regname, abreg); \
380 printf ("\t%s:spill_sprel(reg=%s,t=%lu,spoff=0x%lx)\n", \
381 fmt, regname, (unsigned long) t, 4*(unsigned long)off); \
385 #define UNW_DEC_SPILL_PSPREL(fmt, t, abreg, pspoff, arg) \
390 unw_print_abreg (regname, abreg); \
391 printf ("\t%s:spill_psprel(reg=%s,t=%lu,pspoff=0x10-0x%lx)\n", \
392 fmt, regname, (unsigned long) t, 4*(unsigned long)pspoff); \
396 #define UNW_DEC_RESTORE(fmt, t, abreg, arg) \
401 unw_print_abreg (regname, abreg); \
402 printf ("\t%s:restore(t=%lu,reg=%s)\n", \
403 fmt, (unsigned long) t, regname); \
407 #define UNW_DEC_SPILL_REG(fmt, t, abreg, x, ytreg, arg) \
410 char abregname[20], tregname[20]; \
412 unw_print_abreg (abregname, abreg); \
413 unw_print_xyreg (tregname, x, ytreg); \
414 printf ("\t%s:spill_reg(t=%lu,reg=%s,treg=%s)\n", \
415 fmt, (unsigned long) t, abregname, tregname); \
419 #define UNW_DEC_SPILL_SPREL_P(fmt, qp, t, abreg, spoff, arg) \
424 unw_print_abreg (regname, abreg); \
425 printf ("\t%s:spill_sprel_p(qp=p%u,t=%lu,reg=%s,spoff=0x%lx)\n", \
426 fmt, qp, (unsigned long) t, regname, 4 * (unsigned long)spoff); \
430 #define UNW_DEC_SPILL_PSPREL_P(fmt, qp, t, abreg, pspoff, arg) \
435 unw_print_abreg (regname, abreg); \
436 printf ("\t%s:spill_psprel_p(qp=p%u,t=%lu,reg=%s,pspoff=0x10-0x%lx)\n",\
437 fmt, qp, (unsigned long) t, regname, 4*(unsigned long)pspoff);\
441 #define UNW_DEC_RESTORE_P(fmt, qp, t, abreg, arg) \
446 unw_print_abreg (regname, abreg); \
447 printf ("\t%s:restore_p(qp=p%u,t=%lu,reg=%s)\n", \
448 fmt, qp, (unsigned long) t, regname); \
452 #define UNW_DEC_SPILL_REG_P(fmt, qp, t, abreg, x, ytreg, arg) \
455 char regname[20], tregname[20]; \
457 unw_print_abreg (regname, abreg); \
458 unw_print_xyreg (tregname, x, ytreg); \
459 printf ("\t%s:spill_reg_p(qp=p%u,t=%lu,reg=%s,treg=%s)\n", \
460 fmt, qp, (unsigned long) t, regname, tregname); \
464 #define UNW_DEC_LABEL_STATE(fmt, label, arg) \
465 printf ("\t%s:label_state(label=%lu)\n", fmt, (unsigned long) label)
467 #define UNW_DEC_COPY_STATE(fmt, label, arg) \
468 printf ("\t%s:copy_state(label=%lu)\n", fmt, (unsigned long) label)
470 #define UNW_DEC_EPILOGUE(fmt, t, ecount, arg) \
471 printf ("\t%s:epilogue(t=%lu,ecount=%lu)\n", \
472 fmt, (unsigned long) t, (unsigned long) ecount)
475 * Generic IA-64 unwind info decoder.
477 * This file is used both by the Linux kernel and objdump. Please
478 * keep the two copies of this file in sync (modulo differences in the
481 * You need to customize the decoder by defining the following
482 * macros/constants before including this file:
485 * unw_word Unsigned integer type with at least 64 bits
499 * Decoder action macros:
500 * UNW_DEC_BAD_CODE(code)
501 * UNW_DEC_ABI(fmt,abi,context,arg)
502 * UNW_DEC_BR_GR(fmt,brmask,gr,arg)
503 * UNW_DEC_BR_MEM(fmt,brmask,arg)
504 * UNW_DEC_COPY_STATE(fmt,label,arg)
505 * UNW_DEC_EPILOGUE(fmt,t,ecount,arg)
506 * UNW_DEC_FRGR_MEM(fmt,grmask,frmask,arg)
507 * UNW_DEC_FR_MEM(fmt,frmask,arg)
508 * UNW_DEC_GR_GR(fmt,grmask,gr,arg)
509 * UNW_DEC_GR_MEM(fmt,grmask,arg)
510 * UNW_DEC_LABEL_STATE(fmt,label,arg)
511 * UNW_DEC_MEM_STACK_F(fmt,t,size,arg)
512 * UNW_DEC_MEM_STACK_V(fmt,t,arg)
513 * UNW_DEC_PRIUNAT_GR(fmt,r,arg)
514 * UNW_DEC_PRIUNAT_WHEN_GR(fmt,t,arg)
515 * UNW_DEC_PRIUNAT_WHEN_MEM(fmt,t,arg)
516 * UNW_DEC_PRIUNAT_WHEN_PSPREL(fmt,pspoff,arg)
517 * UNW_DEC_PRIUNAT_WHEN_SPREL(fmt,spoff,arg)
518 * UNW_DEC_PROLOGUE(fmt,body,rlen,arg)
519 * UNW_DEC_PROLOGUE_GR(fmt,rlen,mask,grsave,arg)
520 * UNW_DEC_REG_PSPREL(fmt,reg,pspoff,arg)
521 * UNW_DEC_REG_REG(fmt,src,dst,arg)
522 * UNW_DEC_REG_SPREL(fmt,reg,spoff,arg)
523 * UNW_DEC_REG_WHEN(fmt,reg,t,arg)
524 * UNW_DEC_RESTORE(fmt,t,abreg,arg)
525 * UNW_DEC_RESTORE_P(fmt,qp,t,abreg,arg)
526 * UNW_DEC_SPILL_BASE(fmt,pspoff,arg)
527 * UNW_DEC_SPILL_MASK(fmt,imaskp,arg)
528 * UNW_DEC_SPILL_PSPREL(fmt,t,abreg,pspoff,arg)
529 * UNW_DEC_SPILL_PSPREL_P(fmt,qp,t,abreg,pspoff,arg)
530 * UNW_DEC_SPILL_REG(fmt,t,abreg,x,ytreg,arg)
531 * UNW_DEC_SPILL_REG_P(fmt,qp,t,abreg,x,ytreg,arg)
532 * UNW_DEC_SPILL_SPREL(fmt,t,abreg,spoff,arg)
533 * UNW_DEC_SPILL_SPREL_P(fmt,qp,t,abreg,pspoff,arg)
536 static unw_word unw_decode_uleb128 (const unsigned char **);
537 static const unsigned char *unw_decode_x1
538 (const unsigned char *, unsigned int, void *);
539 static const unsigned char *unw_decode_x2
540 (const unsigned char *, unsigned int, void *);
541 static const unsigned char *unw_decode_x3
542 (const unsigned char *, unsigned int, void *);
543 static const unsigned char *unw_decode_x4
544 (const unsigned char *, unsigned int, void *);
545 static const unsigned char *unw_decode_r1
546 (const unsigned char *, unsigned int, void *);
547 static const unsigned char *unw_decode_r2
548 (const unsigned char *, unsigned int, void *);
549 static const unsigned char *unw_decode_r3
550 (const unsigned char *, unsigned int, void *);
551 static const unsigned char *unw_decode_p1
552 (const unsigned char *, unsigned int, void *);
553 static const unsigned char *unw_decode_p2_p5
554 (const unsigned char *, unsigned int, void *);
555 static const unsigned char *unw_decode_p6
556 (const unsigned char *, unsigned int, void *);
557 static const unsigned char *unw_decode_p7_p10
558 (const unsigned char *, unsigned int, void *);
559 static const unsigned char *unw_decode_b1
560 (const unsigned char *, unsigned int, void *);
561 static const unsigned char *unw_decode_b2
562 (const unsigned char *, unsigned int, void *);
563 static const unsigned char *unw_decode_b3_x4
564 (const unsigned char *, unsigned int, void *);
567 unw_decode_uleb128 (const unsigned char **dpp)
570 unw_word byte, result = 0;
571 const unsigned char *bp = *dpp;
576 result |= (byte & 0x7f) << shift;
578 if ((byte & 0x80) == 0)
589 static const unsigned char *
590 unw_decode_x1 (const unsigned char *dp, unsigned int code ATTRIBUTE_UNUSED,
591 void *arg ATTRIBUTE_UNUSED)
593 unsigned char byte1, abreg;
597 t = unw_decode_uleb128 (&dp);
598 off = unw_decode_uleb128 (&dp);
599 abreg = (byte1 & 0x7f);
601 UNW_DEC_SPILL_SPREL ("X1", t, abreg, off, arg);
603 UNW_DEC_SPILL_PSPREL ("X1", t, abreg, off, arg);
607 static const unsigned char *
608 unw_decode_x2 (const unsigned char *dp, unsigned int code ATTRIBUTE_UNUSED,
609 void *arg ATTRIBUTE_UNUSED)
611 unsigned char byte1, byte2, abreg, x, ytreg;
616 t = unw_decode_uleb128 (&dp);
617 abreg = (byte1 & 0x7f);
619 x = (byte1 >> 7) & 1;
620 if ((byte1 & 0x80) == 0 && ytreg == 0)
621 UNW_DEC_RESTORE ("X2", t, abreg, arg);
623 UNW_DEC_SPILL_REG ("X2", t, abreg, x, ytreg, arg);
627 static const unsigned char *
628 unw_decode_x3 (const unsigned char *dp, unsigned int code ATTRIBUTE_UNUSED,
629 void *arg ATTRIBUTE_UNUSED)
631 unsigned char byte1, byte2, abreg, qp;
636 t = unw_decode_uleb128 (&dp);
637 off = unw_decode_uleb128 (&dp);
640 abreg = (byte2 & 0x7f);
643 UNW_DEC_SPILL_SPREL_P ("X3", qp, t, abreg, off, arg);
645 UNW_DEC_SPILL_PSPREL_P ("X3", qp, t, abreg, off, arg);
649 static const unsigned char *
650 unw_decode_x4 (const unsigned char *dp, unsigned int code ATTRIBUTE_UNUSED,
651 void *arg ATTRIBUTE_UNUSED)
653 unsigned char byte1, byte2, byte3, qp, abreg, x, ytreg;
659 t = unw_decode_uleb128 (&dp);
662 abreg = (byte2 & 0x7f);
663 x = (byte2 >> 7) & 1;
666 if ((byte2 & 0x80) == 0 && byte3 == 0)
667 UNW_DEC_RESTORE_P ("X4", qp, t, abreg, arg);
669 UNW_DEC_SPILL_REG_P ("X4", qp, t, abreg, x, ytreg, arg);
673 static const unsigned char *
674 unw_decode_r1 (const unsigned char *dp, unsigned int code, void *arg)
676 int body = (code & 0x20) != 0;
679 rlen = (code & 0x1f);
680 UNW_DEC_PROLOGUE ("R1", body, rlen, arg);
684 static const unsigned char *
685 unw_decode_r2 (const unsigned char *dp, unsigned int code, void *arg)
687 unsigned char byte1, mask, grsave;
692 mask = ((code & 0x7) << 1) | ((byte1 >> 7) & 1);
693 grsave = (byte1 & 0x7f);
694 rlen = unw_decode_uleb128 (& dp);
695 UNW_DEC_PROLOGUE_GR ("R2", rlen, mask, grsave, arg);
699 static const unsigned char *
700 unw_decode_r3 (const unsigned char *dp, unsigned int code, void *arg)
704 rlen = unw_decode_uleb128 (& dp);
705 UNW_DEC_PROLOGUE ("R3", ((code & 0x3) == 1), rlen, arg);
709 static const unsigned char *
710 unw_decode_p1 (const unsigned char *dp, unsigned int code,
711 void *arg ATTRIBUTE_UNUSED)
713 unsigned char brmask = (code & 0x1f);
715 UNW_DEC_BR_MEM ("P1", brmask, arg);
719 static const unsigned char *
720 unw_decode_p2_p5 (const unsigned char *dp, unsigned int code,
721 void *arg ATTRIBUTE_UNUSED)
723 if ((code & 0x10) == 0)
725 unsigned char byte1 = *dp++;
727 UNW_DEC_BR_GR ("P2", ((code & 0xf) << 1) | ((byte1 >> 7) & 1),
728 (byte1 & 0x7f), arg);
730 else if ((code & 0x08) == 0)
732 unsigned char byte1 = *dp++, r, dst;
734 r = ((code & 0x7) << 1) | ((byte1 >> 7) & 1);
735 dst = (byte1 & 0x7f);
739 UNW_DEC_REG_GR ("P3", UNW_REG_PSP, dst, arg);
742 UNW_DEC_REG_GR ("P3", UNW_REG_RP, dst, arg);
745 UNW_DEC_REG_GR ("P3", UNW_REG_PFS, dst, arg);
748 UNW_DEC_REG_GR ("P3", UNW_REG_PR, dst, arg);
751 UNW_DEC_REG_GR ("P3", UNW_REG_UNAT, dst, arg);
754 UNW_DEC_REG_GR ("P3", UNW_REG_LC, dst, arg);
757 UNW_DEC_RP_BR ("P3", dst, arg);
760 UNW_DEC_REG_GR ("P3", UNW_REG_RNAT, dst, arg);
763 UNW_DEC_REG_GR ("P3", UNW_REG_BSP, dst, arg);
766 UNW_DEC_REG_GR ("P3", UNW_REG_BSPSTORE, dst, arg);
769 UNW_DEC_REG_GR ("P3", UNW_REG_FPSR, dst, arg);
772 UNW_DEC_PRIUNAT_GR ("P3", dst, arg);
775 UNW_DEC_BAD_CODE (r);
779 else if ((code & 0x7) == 0)
780 UNW_DEC_SPILL_MASK ("P4", dp, arg);
781 else if ((code & 0x7) == 1)
783 unw_word grmask, frmask, byte1, byte2, byte3;
788 grmask = ((byte1 >> 4) & 0xf);
789 frmask = ((byte1 & 0xf) << 16) | (byte2 << 8) | byte3;
790 UNW_DEC_FRGR_MEM ("P5", grmask, frmask, arg);
793 UNW_DEC_BAD_CODE (code);
798 static const unsigned char *
799 unw_decode_p6 (const unsigned char *dp, unsigned int code,
800 void *arg ATTRIBUTE_UNUSED)
802 int gregs = (code & 0x10) != 0;
803 unsigned char mask = (code & 0x0f);
806 UNW_DEC_GR_MEM ("P6", mask, arg);
808 UNW_DEC_FR_MEM ("P6", mask, arg);
812 static const unsigned char *
813 unw_decode_p7_p10 (const unsigned char *dp, unsigned int code, void *arg)
815 unsigned char r, byte1, byte2;
818 if ((code & 0x10) == 0)
821 t = unw_decode_uleb128 (&dp);
825 size = unw_decode_uleb128 (&dp);
826 UNW_DEC_MEM_STACK_F ("P7", t, size, arg);
830 UNW_DEC_MEM_STACK_V ("P7", t, arg);
833 UNW_DEC_SPILL_BASE ("P7", t, arg);
836 UNW_DEC_REG_SPREL ("P7", UNW_REG_PSP, t, arg);
839 UNW_DEC_REG_WHEN ("P7", UNW_REG_RP, t, arg);
842 UNW_DEC_REG_PSPREL ("P7", UNW_REG_RP, t, arg);
845 UNW_DEC_REG_WHEN ("P7", UNW_REG_PFS, t, arg);
848 UNW_DEC_REG_PSPREL ("P7", UNW_REG_PFS, t, arg);
851 UNW_DEC_REG_WHEN ("P7", UNW_REG_PR, t, arg);
854 UNW_DEC_REG_PSPREL ("P7", UNW_REG_PR, t, arg);
857 UNW_DEC_REG_WHEN ("P7", UNW_REG_LC, t, arg);
860 UNW_DEC_REG_PSPREL ("P7", UNW_REG_LC, t, arg);
863 UNW_DEC_REG_WHEN ("P7", UNW_REG_UNAT, t, arg);
866 UNW_DEC_REG_PSPREL ("P7", UNW_REG_UNAT, t, arg);
869 UNW_DEC_REG_WHEN ("P7", UNW_REG_FPSR, t, arg);
872 UNW_DEC_REG_PSPREL ("P7", UNW_REG_FPSR, t, arg);
875 UNW_DEC_BAD_CODE (r);
886 t = unw_decode_uleb128 (&dp);
890 UNW_DEC_REG_SPREL ("P8", UNW_REG_RP, t, arg);
893 UNW_DEC_REG_SPREL ("P8", UNW_REG_PFS, t, arg);
896 UNW_DEC_REG_SPREL ("P8", UNW_REG_PR, t, arg);
899 UNW_DEC_REG_SPREL ("P8", UNW_REG_LC, t, arg);
902 UNW_DEC_REG_SPREL ("P8", UNW_REG_UNAT, t, arg);
905 UNW_DEC_REG_SPREL ("P8", UNW_REG_FPSR, t, arg);
908 UNW_DEC_REG_WHEN ("P8", UNW_REG_BSP, t, arg);
911 UNW_DEC_REG_PSPREL ("P8", UNW_REG_BSP, t, arg);
914 UNW_DEC_REG_SPREL ("P8", UNW_REG_BSP, t, arg);
917 UNW_DEC_REG_WHEN ("P8", UNW_REG_BSPSTORE, t, arg);
920 UNW_DEC_REG_PSPREL ("P8", UNW_REG_BSPSTORE, t, arg);
923 UNW_DEC_REG_SPREL ("P8", UNW_REG_BSPSTORE, t, arg);
926 UNW_DEC_REG_WHEN ("P8", UNW_REG_RNAT, t, arg);
929 UNW_DEC_REG_PSPREL ("P8", UNW_REG_RNAT, t, arg);
932 UNW_DEC_REG_SPREL ("P8", UNW_REG_RNAT, t, arg);
935 UNW_DEC_PRIUNAT_WHEN_GR ("P8", t, arg);
938 UNW_DEC_PRIUNAT_PSPREL ("P8", t, arg);
941 UNW_DEC_PRIUNAT_SPREL ("P8", t, arg);
944 UNW_DEC_PRIUNAT_WHEN_MEM ("P8", t, arg);
947 UNW_DEC_BAD_CODE (r);
956 UNW_DEC_GR_GR ("P9", (byte1 & 0xf), (byte2 & 0x7f), arg);
962 UNW_DEC_ABI ("P10", byte1, byte2, arg);
966 return unw_decode_x1 (dp, code, arg);
969 return unw_decode_x2 (dp, code, arg);
972 return unw_decode_x3 (dp, code, arg);
975 return unw_decode_x4 (dp, code, arg);
978 UNW_DEC_BAD_CODE (code);
985 static const unsigned char *
986 unw_decode_b1 (const unsigned char *dp, unsigned int code,
987 void *arg ATTRIBUTE_UNUSED)
989 unw_word label = (code & 0x1f);
991 if ((code & 0x20) != 0)
992 UNW_DEC_COPY_STATE ("B1", label, arg);
994 UNW_DEC_LABEL_STATE ("B1", label, arg);
998 static const unsigned char *
999 unw_decode_b2 (const unsigned char *dp, unsigned int code,
1000 void *arg ATTRIBUTE_UNUSED)
1004 t = unw_decode_uleb128 (& dp);
1005 UNW_DEC_EPILOGUE ("B2", t, (code & 0x1f), arg);
1009 static const unsigned char *
1010 unw_decode_b3_x4 (const unsigned char *dp, unsigned int code, void *arg)
1012 unw_word t, ecount, label;
1014 if ((code & 0x10) == 0)
1016 t = unw_decode_uleb128 (&dp);
1017 ecount = unw_decode_uleb128 (&dp);
1018 UNW_DEC_EPILOGUE ("B3", t, ecount, arg);
1020 else if ((code & 0x07) == 0)
1022 label = unw_decode_uleb128 (&dp);
1023 if ((code & 0x08) != 0)
1024 UNW_DEC_COPY_STATE ("B4", label, arg);
1026 UNW_DEC_LABEL_STATE ("B4", label, arg);
1032 return unw_decode_x1 (dp, code, arg);
1034 return unw_decode_x2 (dp, code, arg);
1036 return unw_decode_x3 (dp, code, arg);
1038 return unw_decode_x4 (dp, code, arg);
1040 UNW_DEC_BAD_CODE (code);
1046 typedef const unsigned char *(*unw_decoder)
1047 (const unsigned char *, unsigned int, void *);
1049 static const unw_decoder unw_decode_table[2][8] =
1051 /* prologue table: */
1053 unw_decode_r1, /* 0 */
1057 unw_decode_p1, /* 4 */
1063 unw_decode_r1, /* 0 */
1067 unw_decode_b1, /* 4 */
1074 /* Decode one descriptor and return address of next descriptor. */
1075 const unsigned char *
1076 unw_decode (const unsigned char *dp, int inside_body,
1077 void *ptr_inside_body)
1079 unw_decoder decoder;
1083 decoder = unw_decode_table[inside_body][code >> 5];
1084 return (*decoder) (dp, code, ptr_inside_body);