diff options
author | Evan Huus <eapache@gmail.com> | 2013-10-23 01:36:49 +0000 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2013-10-23 01:36:49 +0000 |
commit | 328a05630c1c29782e15e1d02277b2dc64931c3c (patch) | |
tree | 33e8b17d2d488a0f6feb821404c9d0bfa0226c73 /epan/dwarf.c | |
parent | cbd3194bcf87f2e5146343170b4a595ace599ff1 (diff) |
From Michal Labedzki via
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8818
Add support for dissection ELF files. It opens as a "capture" file via wiretap
at the moment for simplicity's sake, but the intention is eventually to have
this (and other file types we dissect) open through some other program sharing
much of the libwireshark infrastructure.
svn path=/trunk/; revision=52775
Diffstat (limited to 'epan/dwarf.c')
-rw-r--r-- | epan/dwarf.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/epan/dwarf.c b/epan/dwarf.c new file mode 100644 index 0000000000..435328d6c0 --- /dev/null +++ b/epan/dwarf.c @@ -0,0 +1,45 @@ +#include "config.h" +#include <epan/packet.h> + +gint +dissect_uleb128(tvbuff_t *tvb, gint offset, guint64 *value) +{ + guint start_offset = offset; + guint shift = 0; + guint8 byte; + + *value = 0; + + do { + byte = tvb_get_guint8(tvb, offset); + offset += 1; + + *value |= (byte & 0x7F) << shift; + shift += 7; + } while (byte & 0x80); + + return offset - start_offset; +} + +gint +dissect_leb128(tvbuff_t *tvb, gint offset, gint64 *value) +{ + guint start_offset = offset; + guint shift = 0; + guint8 byte; + + *value = 0; + + do { + byte = tvb_get_guint8(tvb, offset); + offset += 1; + + *value |= (byte & 0x7F) << shift; + shift += 7; + } while (byte & 0x80); + + if (shift < 64 && byte & 0x40) + *value |= - (1 << shift); + + return offset - start_offset; +} |