aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/file-elf.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2017-11-18 22:31:45 -0500
committerMichael Mann <mmann78@netscape.net>2017-11-19 05:14:57 +0000
commitbb47a68e0983fa4da5b607dd775e227528da1955 (patch)
tree7a1b5d63cb183f807620eaab28291b82633b2507 /epan/dissectors/file-elf.c
parent752d0ef753983b45142e76a71dcdf3ab3c082439 (diff)
Move dissect_leb128 to file-elf.c
This allows for the removal of epan/dwarf.[ch] Functionality could probably be handled by an encoding (like dissect_uleb128), but for now keep it in file-elf.c as that's the only functionality currently using it. Change-Id: I84cf6af02abb3d53ea7d9b774e3313d77a1ff497 Reviewed-on: https://code.wireshark.org/review/24486 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/file-elf.c')
-rw-r--r--epan/dissectors/file-elf.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/epan/dissectors/file-elf.c b/epan/dissectors/file-elf.c
index 3452524b86..509742b820 100644
--- a/epan/dissectors/file-elf.c
+++ b/epan/dissectors/file-elf.c
@@ -34,7 +34,6 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
-#include "dwarf.h"
static dissector_handle_t elf_handle;
@@ -596,6 +595,28 @@ typedef struct _segment_info_t {
void proto_register_elf(void);
void proto_reg_handoff_elf(void);
+static 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 |= ((guint64)(byte & 0x7F) << shift);
+ shift += 7;
+ } while ((byte & 0x80) && (shift < 64));
+
+ if (shift < 64 && byte & 0x40)
+ *value |= - ((gint64)1 << shift);
+
+ return offset - start_offset;
+}
/* Wireshark support "offset" as gint, but ELF needed guint64 size, so check if there is no overflow */
static gint