From cbeeb5b6fe9afcc78bd7714b52cf16a0f8582723 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Mon, 23 Nov 2009 13:50:11 +0100 Subject: [PATCH] dwarflint: Support decoding DW_OP_stack_value, DW_OP_implicit_value --- src/dwarf-opcodes.h | 5 ++++- src/dwarflint/low.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/dwarf-opcodes.h b/src/dwarf-opcodes.h index 739676b24..875dcc071 100644 --- a/src/dwarf-opcodes.h +++ b/src/dwarf-opcodes.h @@ -201,4 +201,7 @@ 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) diff --git a/src/dwarflint/low.c b/src/dwarflint/low.c index b20358725..0cc085d7f 100644 --- a/src/dwarflint/low.c +++ b/src/dwarflint/low.c @@ -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", \ -- 2.47.2