]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Support decoding DW_OP_stack_value, DW_OP_implicit_value
authorPetr Machata <pmachata@redhat.com>
Mon, 23 Nov 2009 12:50:11 +0000 (13:50 +0100)
committerPetr Machata <pmachata@redhat.com>
Wed, 18 Aug 2010 12:55:13 +0000 (14:55 +0200)
src/dwarf-opcodes.h
src/dwarflint/low.c

index 739676b24f5b04fbbddf79d2748154cea69966a6..875dcc0711629133e31d6cb098860d80288727aa 100644 (file)
   DW_OP_0 (DW_OP_GNU_push_tls_address)                         \
   DW_OP_0 (DW_OP_call_frame_cfa)                               \
   DW_OP_2 (DW_OP_bit_piece, DW_FORM_udata, DW_FORM_udata)      \
-  DW_OP_0 (DW_OP_GNU_uninit)
+  DW_OP_0 (DW_OP_GNU_uninit)                                   \
+  /* DWARF 4 */                                                        \
+  DW_OP_0 (DW_OP_stack_value)                                  \
+  DW_OP_1 (DW_OP_implicit_value, DW_FORM_block)
index b20358725d25ea0496cbcefc775412f33b322fe5..0cc085d7f176e82f1a70e0f60c7ddf4120b7e2d9 100644 (file)
@@ -120,7 +120,8 @@ checked_read_sleb128 (struct read_ctx *ctx, int64_t *ret,
    context for LEB128 loading.  */
 static bool
 read_ctx_read_form (struct read_ctx *ctx, int address_size, uint8_t form,
-                   uint64_t *valuep, struct where *where, const char *what)
+                   uint64_t *valuep, struct where *where, const char *what,
+                   bool allow_block)
 {
   switch (form)
     {
@@ -161,6 +162,30 @@ read_ctx_read_form (struct read_ctx *ctx, int address_size, uint8_t form,
       return read_ctx_read_8ubyte (ctx, valuep);
     };
 
+  if (allow_block)
+    {
+      int dform;
+      switch (form)
+       {
+#define HANDLE(BFORM, DFORM)                   \
+         case BFORM:                           \
+           dform = DFORM;                      \
+           break
+         HANDLE (DW_FORM_block, DW_FORM_udata);
+         HANDLE (DW_FORM_block1, DW_FORM_data1);
+         HANDLE (DW_FORM_block2, DW_FORM_data2);
+         HANDLE (DW_FORM_block4, DW_FORM_data4);
+#undef HANDLE
+       default:
+         return false;
+       }
+
+      uint64_t length;
+      return read_ctx_read_form (ctx, address_size, dform,
+                                &length, where, what, false)
+       && read_ctx_skip (ctx, length);
+    }
+
   return false;
 }
 
@@ -1872,7 +1897,7 @@ check_location_expression (struct elf_file *file,
            uint64_t _off = read_ctx_get_offset (&ctx) + init_off;      \
            uint64_t *_ptr = (PTR);                                     \
            if (!read_ctx_read_form (&ctx, cu->head->address_size, (OP), \
-                                    _ptr, &where, STR " operand"))     \
+                                    _ptr, &where, STR " operand", true)) \
              {                                                         \
                wr_error (&where, ": opcode \"%s\""                     \
                          ": can't read " STR " operand (form \"%s\").\n", \