diff options
| author | Mark Wielaard <[email protected]> | 2013-07-09 23:09:38 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2013-07-13 23:06:55 +0200 |
| commit | 1ab6e78250293926e90bfe011ff7dc0d7bf311b7 (patch) | |
| tree | d5844be60a48b1c0084c27ba9d72cfde3f5514f1 /src/readelf.c | |
| parent | 352302209525504ae4b5f3528be6516f5e1190c3 (diff) | |
readelf: print actual DIE offsets of DW_OP_GNU_<type> ops.
Like DW_OP_GNU_parameter_ref the DW_OP_GNU type conversion ops
DW_OP_GNU_const_type, DW_OP_GNU_regval_type, DW_OP_GNU_deref_type,
DW_OP_GNU_convert and DW_OP_GNU_reinterpret take a CU relative offset
to a DIE (in these cases a DW_TAG_base_type). So handle the DIE offsets
just like in the DW_OP_GNU_parameter_ref case by adding the cu->start
if known (and -U hasn't been given). For DW_OP_GNU_convert and
DW_OP_GNU_reinterpret handle zero specially since it means to "untype"
the result and so isn't an actual DIE reference.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'src/readelf.c')
| -rw-r--r-- | src/readelf.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/readelf.c b/src/readelf.c index d6208cbd..119c1000 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -4042,10 +4042,13 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest, break; case DW_OP_GNU_const_type: - /* DIE offset, size plus block. */ + /* uleb128 CU relative DW_TAG_base_type DIE offset, 1-byte + unsigned size plus block. */ start = data; NEED (2); get_uleb128 (uleb, data); /* XXX check overrun */ + if (! print_unresolved_addresses && cu != NULL) + uleb += cu->start; uint8_t usize = *(uint8_t *) data++; NEED (usize); printf ("%*s[%4" PRIuMAX "] %s [%6" PRIxMAX "] ", @@ -4057,21 +4060,29 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest, break; case DW_OP_GNU_regval_type: + /* uleb128 register number, uleb128 CU relative + DW_TAG_base_type DIE offset. */ start = data; NEED (2); get_uleb128 (uleb, data); /* XXX check overrun */ get_uleb128 (uleb2, data); /* XXX check overrun */ - printf ("%*s[%4" PRIuMAX "] %s %" PRIu64 " %#" PRIx64 "\n", + if (! print_unresolved_addresses && cu != NULL) + uleb2 += cu->start; + printf ("%*s[%4" PRIuMAX "] %s %" PRIu64 " [%6" PRIx64 "]\n", indent, "", (uintmax_t) offset, op_name, uleb, uleb2); CONSUME (data - start); offset += 1 + (data - start); break; case DW_OP_GNU_deref_type: + /* 1-byte unsigned size of value, uleb128 CU relative + DW_TAG_base_type DIE offset. */ start = data; NEED (2); usize = *(uint8_t *) data++; get_uleb128 (uleb, data); /* XXX check overrun */ + if (! print_unresolved_addresses && cu != NULL) + uleb += cu->start; printf ("%*s[%4" PRIuMAX "] %s %" PRIu8 " [%6" PRIxMAX "]\n", indent, "", (uintmax_t) offset, op_name, usize, uleb); @@ -4081,9 +4092,13 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest, case DW_OP_GNU_convert: case DW_OP_GNU_reinterpret: + /* uleb128 CU relative offset to DW_TAG_base_type, or zero + for conversion to untyped. */ start = data; NEED (1); get_uleb128 (uleb, data); /* XXX check overrun */ + if (uleb != 0 && ! print_unresolved_addresses && cu != NULL) + uleb += cu->start; printf ("%*s[%4" PRIuMAX "] %s [%6" PRIxMAX "]\n", indent, "", (uintmax_t) offset, op_name, uleb); CONSUME (data - start); |
