diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2021-02-20 22:38:22 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2021-02-20 22:38:22 (GMT) |
commit | 9a080bc3f8184a5663ce42c3c74ae80e1ae598a0 (patch) | |
tree | fa80229577a84afd58c1dc81ea599cd67036d771 /src/common/leb128.h | |
parent | 170dc35d87e0a858c5400937a1ee2d2dde7f653a (diff) |
Pack and unpack LEB128 values on demand.
Diffstat (limited to 'src/common/leb128.h')
-rw-r--r-- | src/common/leb128.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/common/leb128.h b/src/common/leb128.h index 2093ead..ae1078a 100644 --- a/src/common/leb128.h +++ b/src/common/leb128.h @@ -29,6 +29,7 @@ #include <stdlib.h> +#include "packed.h" #include "../arch/archbase.h" #include "../arch/vmpa.h" @@ -39,10 +40,12 @@ typedef uint64_t uleb128_t; typedef int64_t leb128_t; +/* Quantité de bits utilisés */ +#define LEB128_BITS_COUNT (sizeof(leb128_t) * 8) + /* Récupération de la valeur absolue */ #define leb128_abs(v) llabs(v) - /* Valeurs minimales et maximales */ #define ULEB128_MIN UINT64_MIN #define ULEB128_MAX UINT64_MAX @@ -56,6 +59,17 @@ bool read_uleb128(uleb128_t *, const bin_t *, phys_t *, phys_t); /* Lit un nombre signé encodé au format LEB128. */ bool read_leb128(leb128_t *, const bin_t *, phys_t *, phys_t); +/* Encode un nombre non signé encodé au format LEB128. */ +bool pack_uleb128(const uleb128_t *, packed_buffer_t *); + +/* Encode un nombre signé encodé au format LEB128. */ +bool pack_leb128(const leb128_t *, packed_buffer_t *); + +/* Décode un nombre non signé encodé au format LEB128. */ +bool unpack_uleb128(uleb128_t *, packed_buffer_t *); + +/* Décode un nombre signé encodé au format LEB128. */ +bool unpack_leb128(leb128_t *, packed_buffer_t *); #endif /* _COMMON_LEB128_H */ |