1 /* libunwind - a platform-independent unwind library
2    Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P.
3         Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4 
5 This file is part of libunwind.
6 
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
14 
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
25 
26 #include "dwarf_i.h"
27 #include "libunwind_i.h"
28 
29 /* The "pick" operator provides an index range of 0..255 indicating
30    that the stack could at least have a depth of up to 256 elements,
31    but the GCC unwinder restricts the depth to 64, which seems
32    reasonable so we use the same value here.  */
33 #define MAX_EXPR_STACK_SIZE     64
34 
35 #define NUM_OPERANDS(signature) (((signature) >> 6) & 0x3)
36 #define OPND1_TYPE(signature)   (((signature) >> 3) & 0x7)
37 #define OPND2_TYPE(signature)   (((signature) >> 0) & 0x7)
38 
39 #define OPND_SIGNATURE(n, t1, t2) (((n) << 6) | ((t1) << 3) | ((t2) << 0))
40 #define OPND1(t1)               OPND_SIGNATURE(1, t1, 0)
41 #define OPND2(t1, t2)           OPND_SIGNATURE(2, t1, t2)
42 
43 #define VAL8    0x0
44 #define VAL16   0x1
45 #define VAL32   0x2
46 #define VAL64   0x3
47 #define ULEB128 0x4
48 #define SLEB128 0x5
49 #define OFFSET  0x6     /* 32-bit offset for 32-bit DWARF, 64-bit otherwise */
50 #define ADDR    0x7     /* Machine address.  */
51 
52 static const uint8_t operands[256] =
53   {
54     [DW_OP_addr] =              OPND1 (ADDR),
55     [DW_OP_const1u] =           OPND1 (VAL8),
56     [DW_OP_const1s] =           OPND1 (VAL8),
57     [DW_OP_const2u] =           OPND1 (VAL16),
58     [DW_OP_const2s] =           OPND1 (VAL16),
59     [DW_OP_const4u] =           OPND1 (VAL32),
60     [DW_OP_const4s] =           OPND1 (VAL32),
61     [DW_OP_const8u] =           OPND1 (VAL64),
62     [DW_OP_const8s] =           OPND1 (VAL64),
63     [DW_OP_pick] =              OPND1 (VAL8),
64     [DW_OP_plus_uconst] =       OPND1 (ULEB128),
65     [DW_OP_skip] =              OPND1 (VAL16),
66     [DW_OP_bra] =               OPND1 (VAL16),
67     [DW_OP_breg0 +  0] =        OPND1 (SLEB128),
68     [DW_OP_breg0 +  1] =        OPND1 (SLEB128),
69     [DW_OP_breg0 +  2] =        OPND1 (SLEB128),
70     [DW_OP_breg0 +  3] =        OPND1 (SLEB128),
71     [DW_OP_breg0 +  4] =        OPND1 (SLEB128),
72     [DW_OP_breg0 +  5] =        OPND1 (SLEB128),
73     [DW_OP_breg0 +  6] =        OPND1 (SLEB128),
74     [DW_OP_breg0 +  7] =        OPND1 (SLEB128),
75     [DW_OP_breg0 +  8] =        OPND1 (SLEB128),
76     [DW_OP_breg0 +  9] =        OPND1 (SLEB128),
77     [DW_OP_breg0 + 10] =        OPND1 (SLEB128),
78     [DW_OP_breg0 + 11] =        OPND1 (SLEB128),
79     [DW_OP_breg0 + 12] =        OPND1 (SLEB128),
80     [DW_OP_breg0 + 13] =        OPND1 (SLEB128),
81     [DW_OP_breg0 + 14] =        OPND1 (SLEB128),
82     [DW_OP_breg0 + 15] =        OPND1 (SLEB128),
83     [DW_OP_breg0 + 16] =        OPND1 (SLEB128),
84     [DW_OP_breg0 + 17] =        OPND1 (SLEB128),
85     [DW_OP_breg0 + 18] =        OPND1 (SLEB128),
86     [DW_OP_breg0 + 19] =        OPND1 (SLEB128),
87     [DW_OP_breg0 + 20] =        OPND1 (SLEB128),
88     [DW_OP_breg0 + 21] =        OPND1 (SLEB128),
89     [DW_OP_breg0 + 22] =        OPND1 (SLEB128),
90     [DW_OP_breg0 + 23] =        OPND1 (SLEB128),
91     [DW_OP_breg0 + 24] =        OPND1 (SLEB128),
92     [DW_OP_breg0 + 25] =        OPND1 (SLEB128),
93     [DW_OP_breg0 + 26] =        OPND1 (SLEB128),
94     [DW_OP_breg0 + 27] =        OPND1 (SLEB128),
95     [DW_OP_breg0 + 28] =        OPND1 (SLEB128),
96     [DW_OP_breg0 + 29] =        OPND1 (SLEB128),
97     [DW_OP_breg0 + 30] =        OPND1 (SLEB128),
98     [DW_OP_breg0 + 31] =        OPND1 (SLEB128),
99     [DW_OP_regx] =              OPND1 (ULEB128),
100     [DW_OP_fbreg] =             OPND1 (SLEB128),
101     [DW_OP_bregx] =             OPND2 (ULEB128, SLEB128),
102     [DW_OP_piece] =             OPND1 (ULEB128),
103     [DW_OP_deref_size] =        OPND1 (VAL8),
104     [DW_OP_xderef_size] =       OPND1 (VAL8),
105     [DW_OP_call2] =             OPND1 (VAL16),
106     [DW_OP_call4] =             OPND1 (VAL32),
107     [DW_OP_call_ref] =          OPND1 (OFFSET)
108   };
109 
110 static inline unw_sword_t
sword(unw_addr_space_t as,unw_word_t val)111 sword (unw_addr_space_t as, unw_word_t val)
112 {
113   switch (dwarf_addr_size (as))
114     {
115     case 1: return (int8_t) val;
116     case 2: return (int16_t) val;
117     case 4: return (int32_t) val;
118     case 8: return (int64_t) val;
119     default: assert (0);
120     }
121 }
122 
123 static inline unw_word_t
read_operand(unw_addr_space_t as,unw_accessors_t * a,unw_word_t * addr,int operand_type,unw_word_t * val,void * arg)124 read_operand (unw_addr_space_t as, unw_accessors_t *a,
125               unw_word_t *addr, int operand_type, unw_word_t *val, void *arg)
126 {
127   uint8_t u8;
128   uint16_t u16;
129   uint32_t u32;
130   uint64_t u64;
131   int ret;
132 
133   if (operand_type == ADDR)
134     switch (dwarf_addr_size (as))
135       {
136       case 1: operand_type = VAL8; break;
137       case 2: operand_type = VAL16; break;
138       case 4: operand_type = VAL32; break;
139       case 8: operand_type = VAL64; break;
140       default: assert (0);
141       }
142 
143   switch (operand_type)
144     {
145     case VAL8:
146       ret = dwarf_readu8 (as, a, addr, &u8, arg);
147       if (ret < 0)
148         return ret;
149       *val = u8;
150       break;
151 
152     case VAL16:
153       u16 = 0;
154       ret = dwarf_readu16 (as, a, addr, &u16, arg);
155       if (ret < 0)
156         return ret;
157       *val = u16;
158       break;
159 
160     case VAL32:
161       u32 = 0;
162       ret = dwarf_readu32 (as, a, addr, &u32, arg);
163       if (ret < 0)
164         return ret;
165       *val = u32;
166       break;
167 
168     case VAL64:
169       u64 = 0;
170       ret = dwarf_readu64 (as, a, addr, &u64, arg);
171       if (ret < 0)
172         return ret;
173       *val = u64;
174       break;
175 
176     case ULEB128:
177       ret = dwarf_read_uleb128 (as, a, addr, val, arg);
178       break;
179 
180     case SLEB128:
181       ret = dwarf_read_sleb128 (as, a, addr, val, arg);
182       break;
183 
184     case OFFSET: /* only used by DW_OP_call_ref, which we don't implement */
185     default:
186       Debug (1, "Unexpected operand type %d\n", operand_type);
187       ret = -UNW_EINVAL;
188     }
189   return ret;
190 }
191 
192 HIDDEN int
dwarf_eval_expr(struct dwarf_cursor * c,unw_word_t * addr,unw_word_t len,unw_word_t * valp,int * is_register)193 dwarf_eval_expr (struct dwarf_cursor *c, unw_word_t *addr, unw_word_t len,
194                  unw_word_t *valp, int *is_register)
195 {
196   unw_word_t operand1 = 0, operand2 = 0, tmp1, tmp2, tmp3, end_addr;
197   uint8_t opcode, operands_signature, u8;
198   unw_addr_space_t as;
199   unw_accessors_t *a;
200   void *arg;
201   unw_word_t stack[MAX_EXPR_STACK_SIZE];
202   unsigned int tos = 0;
203   uint16_t u16;
204   uint32_t u32;
205   uint64_t u64;
206   int ret;
207 # define pop()                                  \
208 ({                                              \
209   if ((tos - 1) >= MAX_EXPR_STACK_SIZE)         \
210     {                                           \
211       Debug (1, "Stack underflow\n");           \
212       return -UNW_EINVAL;                       \
213     }                                           \
214   stack[--tos];                                 \
215 })
216 # define push(x)                                \
217 do {                                            \
218   unw_word_t _x = (x);                          \
219   if (tos >= MAX_EXPR_STACK_SIZE)               \
220     {                                           \
221       Debug (1, "Stack overflow\n");            \
222       return -UNW_EINVAL;                       \
223     }                                           \
224   stack[tos++] = _x;                            \
225 } while (0)
226 # define pick(n)                                \
227 ({                                              \
228   unsigned int _index = tos - 1 - (n);          \
229   if (_index >= MAX_EXPR_STACK_SIZE)            \
230     {                                           \
231       Debug (1, "Out-of-stack pick\n");         \
232       return -UNW_EINVAL;                       \
233     }                                           \
234   stack[_index];                                \
235 })
236 
237   as = c->as;
238   arg = c->as_arg;
239   a = unw_get_accessors (as);
240   end_addr = *addr + len;
241   *is_register = 0;
242 
243   Debug (14, "len=%lu, pushing cfa=0x%lx\n",
244          (unsigned long) len, (unsigned long) c->cfa);
245 
246   push (c->cfa);        /* push current CFA as required by DWARF spec */
247 
248   while (*addr < end_addr)
249     {
250       if ((ret = dwarf_readu8 (as, a, addr, &opcode, arg)) < 0)
251         return ret;
252 
253       operands_signature = operands[opcode];
254 
255       if (unlikely (NUM_OPERANDS (operands_signature) > 0))
256         {
257           if ((ret = read_operand (as, a, addr,
258                                    OPND1_TYPE (operands_signature),
259                                    &operand1, arg)) < 0)
260             return ret;
261           if (NUM_OPERANDS (operands_signature) > 1)
262             if ((ret = read_operand (as, a, addr,
263                                      OPND2_TYPE (operands_signature),
264                                      &operand2, arg)) < 0)
265               return ret;
266         }
267 
268       switch ((dwarf_expr_op_t) opcode)
269         {
270         case DW_OP_lit0:  case DW_OP_lit1:  case DW_OP_lit2:
271         case DW_OP_lit3:  case DW_OP_lit4:  case DW_OP_lit5:
272         case DW_OP_lit6:  case DW_OP_lit7:  case DW_OP_lit8:
273         case DW_OP_lit9:  case DW_OP_lit10: case DW_OP_lit11:
274         case DW_OP_lit12: case DW_OP_lit13: case DW_OP_lit14:
275         case DW_OP_lit15: case DW_OP_lit16: case DW_OP_lit17:
276         case DW_OP_lit18: case DW_OP_lit19: case DW_OP_lit20:
277         case DW_OP_lit21: case DW_OP_lit22: case DW_OP_lit23:
278         case DW_OP_lit24: case DW_OP_lit25: case DW_OP_lit26:
279         case DW_OP_lit27: case DW_OP_lit28: case DW_OP_lit29:
280         case DW_OP_lit30: case DW_OP_lit31:
281           Debug (15, "OP_lit(%d)\n", (int) opcode - DW_OP_lit0);
282           push (opcode - DW_OP_lit0);
283           break;
284 
285         case DW_OP_breg0:  case DW_OP_breg1:  case DW_OP_breg2:
286         case DW_OP_breg3:  case DW_OP_breg4:  case DW_OP_breg5:
287         case DW_OP_breg6:  case DW_OP_breg7:  case DW_OP_breg8:
288         case DW_OP_breg9:  case DW_OP_breg10: case DW_OP_breg11:
289         case DW_OP_breg12: case DW_OP_breg13: case DW_OP_breg14:
290         case DW_OP_breg15: case DW_OP_breg16: case DW_OP_breg17:
291         case DW_OP_breg18: case DW_OP_breg19: case DW_OP_breg20:
292         case DW_OP_breg21: case DW_OP_breg22: case DW_OP_breg23:
293         case DW_OP_breg24: case DW_OP_breg25: case DW_OP_breg26:
294         case DW_OP_breg27: case DW_OP_breg28: case DW_OP_breg29:
295         case DW_OP_breg30: case DW_OP_breg31:
296           Debug (15, "OP_breg(r%d,0x%lx)\n",
297                  (int) opcode - DW_OP_breg0, (unsigned long) operand1);
298           if ((ret = unw_get_reg (dwarf_to_cursor (c),
299                                   dwarf_to_unw_regnum (opcode - DW_OP_breg0),
300                                   &tmp1)) < 0)
301             return ret;
302           push (tmp1 + operand1);
303           break;
304 
305         case DW_OP_bregx:
306           Debug (15, "OP_bregx(r%d,0x%lx)\n",
307                  (int) operand1, (unsigned long) operand2);
308           if ((ret = unw_get_reg (dwarf_to_cursor (c),
309                                   dwarf_to_unw_regnum (operand1), &tmp1)) < 0)
310             return ret;
311           push (tmp1 + operand2);
312           break;
313 
314         case DW_OP_reg0:  case DW_OP_reg1:  case DW_OP_reg2:
315         case DW_OP_reg3:  case DW_OP_reg4:  case DW_OP_reg5:
316         case DW_OP_reg6:  case DW_OP_reg7:  case DW_OP_reg8:
317         case DW_OP_reg9:  case DW_OP_reg10: case DW_OP_reg11:
318         case DW_OP_reg12: case DW_OP_reg13: case DW_OP_reg14:
319         case DW_OP_reg15: case DW_OP_reg16: case DW_OP_reg17:
320         case DW_OP_reg18: case DW_OP_reg19: case DW_OP_reg20:
321         case DW_OP_reg21: case DW_OP_reg22: case DW_OP_reg23:
322         case DW_OP_reg24: case DW_OP_reg25: case DW_OP_reg26:
323         case DW_OP_reg27: case DW_OP_reg28: case DW_OP_reg29:
324         case DW_OP_reg30: case DW_OP_reg31:
325           Debug (15, "OP_reg(r%d)\n", (int) opcode - DW_OP_reg0);
326           *valp = dwarf_to_unw_regnum (opcode - DW_OP_reg0);
327           *is_register = 1;
328           return 0;
329 
330         case DW_OP_regx:
331           Debug (15, "OP_regx(r%d)\n", (int) operand1);
332           *valp = dwarf_to_unw_regnum (operand1);
333           *is_register = 1;
334           return 0;
335 
336         case DW_OP_addr:
337         case DW_OP_const1u:
338         case DW_OP_const2u:
339         case DW_OP_const4u:
340         case DW_OP_const8u:
341         case DW_OP_constu:
342         case DW_OP_const8s:
343         case DW_OP_consts:
344           Debug (15, "OP_const(0x%lx)\n", (unsigned long) operand1);
345           push (operand1);
346           break;
347 
348         case DW_OP_const1s:
349           if (operand1 & 0x80)
350             operand1 |= ((unw_word_t) -1) << 8;
351           Debug (15, "OP_const1s(%ld)\n", (long) operand1);
352           push (operand1);
353           break;
354 
355         case DW_OP_const2s:
356           if (operand1 & 0x8000)
357             operand1 |= ((unw_word_t) -1) << 16;
358           Debug (15, "OP_const2s(%ld)\n", (long) operand1);
359           push (operand1);
360           break;
361 
362         case DW_OP_const4s:
363           if (operand1 & 0x80000000)
364             operand1 |= (((unw_word_t) -1) << 16) << 16;
365           Debug (15, "OP_const4s(%ld)\n", (long) operand1);
366           push (operand1);
367           break;
368 
369         case DW_OP_deref:
370           Debug (15, "OP_deref\n");
371           tmp1 = pop ();
372           if ((ret = dwarf_readw (as, a, &tmp1, &tmp2, arg)) < 0)
373             return ret;
374           push (tmp2);
375           break;
376 
377         case DW_OP_deref_size:
378           Debug (15, "OP_deref_size(%d)\n", (int) operand1);
379           tmp1 = pop ();
380           switch (operand1)
381             {
382             default:
383               Debug (1, "Unexpected DW_OP_deref_size size %d\n",
384                      (int) operand1);
385               return -UNW_EINVAL;
386 
387             case 1:
388               if ((ret = dwarf_readu8 (as, a, &tmp1, &u8, arg)) < 0)
389                 return ret;
390               tmp2 = u8;
391               break;
392 
393             case 2:
394               if ((ret = dwarf_readu16 (as, a, &tmp1, &u16, arg)) < 0)
395                 return ret;
396               tmp2 = u16;
397               break;
398 
399             case 3:
400             case 4:
401               if ((ret = dwarf_readu32 (as, a, &tmp1, &u32, arg)) < 0)
402                 return ret;
403               tmp2 = u32;
404               if (operand1 == 3)
405                 {
406                   if (tdep_big_endian (as))
407                     tmp2 >>= 8;
408                   else
409                     tmp2 &= 0xffffff;
410                 }
411               break;
412             case 5:
413             case 6:
414             case 7:
415             case 8:
416               if ((ret = dwarf_readu64 (as, a, &tmp1, &u64, arg)) < 0)
417                 return ret;
418               tmp2 = u64;
419               if (operand1 != 8)
420                 {
421                   if (tdep_big_endian (as))
422                     tmp2 >>= 64 - 8 * operand1;
423                   else
424                     tmp2 &= (~ (unw_word_t) 0) << (8 * operand1);
425                 }
426               break;
427             }
428           push (tmp2);
429           break;
430 
431         case DW_OP_dup:
432           Debug (15, "OP_dup\n");
433           push (pick (0));
434           break;
435 
436         case DW_OP_drop:
437           Debug (15, "OP_drop\n");
438           (void) pop ();
439           break;
440 
441         case DW_OP_pick:
442           Debug (15, "OP_pick(%d)\n", (int) operand1);
443           push (pick (operand1));
444           break;
445 
446         case DW_OP_over:
447           Debug (15, "OP_over\n");
448           push (pick (1));
449           break;
450 
451         case DW_OP_swap:
452           Debug (15, "OP_swap\n");
453           tmp1 = pop ();
454           tmp2 = pop ();
455           push (tmp1);
456           push (tmp2);
457           break;
458 
459         case DW_OP_rot:
460           Debug (15, "OP_rot\n");
461           tmp1 = pop ();
462           tmp2 = pop ();
463           tmp3 = pop ();
464           push (tmp1);
465           push (tmp3);
466           push (tmp2);
467           break;
468 
469         case DW_OP_abs:
470           Debug (15, "OP_abs\n");
471           tmp1 = pop ();
472           if (tmp1 & ((unw_word_t) 1 << (8 * dwarf_addr_size (as) - 1)))
473             tmp1 = -tmp1;
474           push (tmp1);
475           break;
476 
477         case DW_OP_and:
478           Debug (15, "OP_and\n");
479           tmp1 = pop ();
480           tmp2 = pop ();
481           push (tmp1 & tmp2);
482           break;
483 
484         case DW_OP_div:
485           Debug (15, "OP_div\n");
486           tmp1 = pop ();
487           tmp2 = pop ();
488           if (tmp1)
489             tmp1 = sword (as, tmp2) / sword (as, tmp1);
490           push (tmp1);
491           break;
492 
493         case DW_OP_minus:
494           Debug (15, "OP_minus\n");
495           tmp1 = pop ();
496           tmp2 = pop ();
497           tmp1 = tmp2 - tmp1;
498           push (tmp1);
499           break;
500 
501         case DW_OP_mod:
502           Debug (15, "OP_mod\n");
503           tmp1 = pop ();
504           tmp2 = pop ();
505           if (tmp1)
506             tmp1 = tmp2 % tmp1;
507           push (tmp1);
508           break;
509 
510         case DW_OP_mul:
511           Debug (15, "OP_mul\n");
512           tmp1 = pop ();
513           tmp2 = pop ();
514           if (tmp1)
515             tmp1 = tmp2 * tmp1;
516           push (tmp1);
517           break;
518 
519         case DW_OP_neg:
520           Debug (15, "OP_neg\n");
521           push (-pop ());
522           break;
523 
524         case DW_OP_not:
525           Debug (15, "OP_not\n");
526           push (~pop ());
527           break;
528 
529         case DW_OP_or:
530           Debug (15, "OP_or\n");
531           tmp1 = pop ();
532           tmp2 = pop ();
533           push (tmp1 | tmp2);
534           break;
535 
536         case DW_OP_plus:
537           Debug (15, "OP_plus\n");
538           tmp1 = pop ();
539           tmp2 = pop ();
540           push (tmp1 + tmp2);
541           break;
542 
543         case DW_OP_plus_uconst:
544           Debug (15, "OP_plus_uconst(%lu)\n", (unsigned long) operand1);
545           tmp1 = pop ();
546           push (tmp1 + operand1);
547           break;
548 
549         case DW_OP_shl:
550           Debug (15, "OP_shl\n");
551           tmp1 = pop ();
552           tmp2 = pop ();
553           push (tmp2 << tmp1);
554           break;
555 
556         case DW_OP_shr:
557           Debug (15, "OP_shr\n");
558           tmp1 = pop ();
559           tmp2 = pop ();
560           push (tmp2 >> tmp1);
561           break;
562 
563         case DW_OP_shra:
564           Debug (15, "OP_shra\n");
565           tmp1 = pop ();
566           tmp2 = pop ();
567           push (sword (as, tmp2) >> tmp1);
568           break;
569 
570         case DW_OP_xor:
571           Debug (15, "OP_xor\n");
572           tmp1 = pop ();
573           tmp2 = pop ();
574           push (tmp1 ^ tmp2);
575           break;
576 
577         case DW_OP_le:
578           Debug (15, "OP_le\n");
579           tmp1 = pop ();
580           tmp2 = pop ();
581           push (sword (as, tmp2) <= sword (as, tmp1));
582           break;
583 
584         case DW_OP_ge:
585           Debug (15, "OP_ge\n");
586           tmp1 = pop ();
587           tmp2 = pop ();
588           push (sword (as, tmp2) >= sword (as, tmp1));
589           break;
590 
591         case DW_OP_eq:
592           Debug (15, "OP_eq\n");
593           tmp1 = pop ();
594           tmp2 = pop ();
595           push (sword (as, tmp2) == sword (as, tmp1));
596           break;
597 
598         case DW_OP_lt:
599           Debug (15, "OP_lt\n");
600           tmp1 = pop ();
601           tmp2 = pop ();
602           push (sword (as, tmp2) < sword (as, tmp1));
603           break;
604 
605         case DW_OP_gt:
606           Debug (15, "OP_gt\n");
607           tmp1 = pop ();
608           tmp2 = pop ();
609           push (sword (as, tmp2) > sword (as, tmp1));
610           break;
611 
612         case DW_OP_ne:
613           Debug (15, "OP_ne\n");
614           tmp1 = pop ();
615           tmp2 = pop ();
616           push (sword (as, tmp2) != sword (as, tmp1));
617           break;
618 
619         case DW_OP_skip:
620           Debug (15, "OP_skip(%d)\n", (int16_t) operand1);
621           *addr += (int16_t) operand1;
622           break;
623 
624         case DW_OP_bra:
625           Debug (15, "OP_skip(%d)\n", (int16_t) operand1);
626           tmp1 = pop ();
627           if (tmp1)
628             *addr += (int16_t) operand1;
629           break;
630 
631         case DW_OP_nop:
632           Debug (15, "OP_nop\n");
633           break;
634 
635         case DW_OP_call2:
636         case DW_OP_call4:
637         case DW_OP_call_ref:
638         case DW_OP_fbreg:
639         case DW_OP_piece:
640         case DW_OP_push_object_address:
641         case DW_OP_xderef:
642         case DW_OP_xderef_size:
643         default:
644           Debug (1, "Unexpected opcode 0x%x\n", opcode);
645           return -UNW_EINVAL;
646         }
647     }
648   *valp = pop ();
649   Debug (14, "final value = 0x%lx\n", (unsigned long) *valp);
650   return 0;
651 }
652