Capstone disassembly/disassembler framework: Core (Arm, Arm64, BPF, EVM, M68K, M680X, MOS65xx, Mips, PPC, RISCV, Sparc, SystemZ, TMS320C64x, Web Assembly, X86, X86_64, XCore) + bindings.
(bloaty 依赖)
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
//===- llvm/Support/LEB128.h - [SU]LEB128 utility functions -----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares some utility functions for encoding SLEB128 and
|
|
|
|
// ULEB128 values.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
/* Capstone Disassembly Engine */
|
|
|
|
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2015 */
|
|
|
|
|
|
|
|
#ifndef CS_LLVM_SUPPORT_LEB128_H
|
|
|
|
#define CS_LLVM_SUPPORT_LEB128_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
/// Utility function to decode a ULEB128 value.
|
|
|
|
static inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n)
|
|
|
|
{
|
|
|
|
const uint8_t *orig_p = p;
|
|
|
|
uint64_t Value = 0;
|
|
|
|
unsigned Shift = 0;
|
|
|
|
do {
|
|
|
|
Value += (*p & 0x7f) << Shift;
|
|
|
|
Shift += 7;
|
|
|
|
} while (*p++ >= 128);
|
|
|
|
if (n)
|
|
|
|
*n = (unsigned)(p - orig_p);
|
|
|
|
return Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // LLVM_SYSTEM_LEB128_H
|