summaryrefslogtreecommitdiffstats
path: root/libdw/memory-access.h
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2017-11-26 17:51:11 +0100
committerMark Wielaard <[email protected]>2018-02-21 17:19:33 +0100
commit8961f33e2a72a9430455cbb0368c71d22574dc3d (patch)
treec9b7a9a9a5301f66a6b4c058ce7dddaef6488616 /libdw/memory-access.h
parenteb11b0f15c0fd06aa8fcc59feba36b6b091f30f7 (diff)
libdw: Handle DWARF5 DW_FORM_implicit_const. Add dwarf_getabbrevattr_data.
Handle the new DW_FORM_implicit_const. The value of this form is embedded in the abbrev data (as sleb128) and not in the info DIE data. This also adds a new function dwarf_getabbrevattr_data which allows getting any data/value associated with a form. eu-readelf will use this new function to show the DW_FORM_implicit_const value. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libdw/memory-access.h')
-rw-r--r--libdw/memory-access.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/libdw/memory-access.h b/libdw/memory-access.h
index ed68bdb9..5f96a14a 100644
--- a/libdw/memory-access.h
+++ b/libdw/memory-access.h
@@ -139,7 +139,26 @@ __libdw_get_sleb128 (const unsigned char **addrp, const unsigned char *end)
return INT64_MAX;
}
+static inline int64_t
+__libdw_get_sleb128_unchecked (const unsigned char **addrp)
+{
+ int64_t acc = 0;
+
+ /* Unroll the first step to help the compiler optimize
+ for the common single-byte case. */
+ get_sleb128_step (acc, *addrp, 0);
+
+ /* Subtract one step, so we don't shift into sign bit. */
+ const size_t max = len_leb128 (int64_t) - 1;
+ for (size_t i = 1; i < max; ++i)
+ get_sleb128_step (acc, *addrp, i);
+ /* Other implementations set VALUE to INT_MAX in this
+ case. So we better do this as well. */
+ return INT64_MAX;
+}
+
#define get_sleb128(var, addr, end) ((var) = __libdw_get_sleb128 (&(addr), end))
+#define get_sleb128_unchecked(var, addr) ((var) = __libdw_get_sleb128_unchecked (&(addr)))
/* We use simple memory access functions in case the hardware allows it.