class DataExtractor

Declaration

class DataExtractor { /* full declaration omitted */ };

Declared at: llvm/include/llvm/Support/DataExtractor.h:41

Member Variables

private llvm::StringRef Data
private uint8_t IsLittleEndian
private uint8_t AddressSize

Method Overview

  • public DataExtractor(ArrayRef<uint8_t> Data, bool IsLittleEndian, uint8_t AddressSize)
  • public DataExtractor(llvm::StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
  • public bool eof(const llvm::DataExtractor::Cursor & C) const
  • public uint64_t getAddress(llvm::DataExtractor::Cursor & C) const
  • public uint64_t getAddress(uint64_t * offset_ptr) const
  • public uint8_t getAddressSize() const
  • public llvm::StringRef getBytes(uint64_t * OffsetPtr, uint64_t Length, llvm::Error * Err = nullptr) const
  • public llvm::StringRef getBytes(llvm::DataExtractor::Cursor & C, uint64_t Length)
  • public const char * getCStr(llvm::DataExtractor::Cursor & C) const
  • public const char * getCStr(uint64_t * OffsetPtr, llvm::Error * Err = nullptr) const
  • public llvm::StringRef getCStrRef(uint64_t * OffsetPtr, llvm::Error * Err = nullptr) const
  • public llvm::StringRef getCStrRef(llvm::DataExtractor::Cursor & C) const
  • public llvm::StringRef getData() const
  • protected static llvm::Error & getError(llvm::DataExtractor::Cursor & C)
  • public llvm::StringRef getFixedLengthString(uint64_t * OffsetPtr, uint64_t Length, llvm::StringRef TrimChars = {"\000", 1}) const
  • protected static uint64_t & getOffset(llvm::DataExtractor::Cursor & C)
  • public int64_t getSLEB128(llvm::DataExtractor::Cursor & C) const
  • public int64_t getSLEB128(uint64_t * OffsetPtr, llvm::Error * Err = nullptr) const
  • public int64_t getSigned(uint64_t * offset_ptr, uint32_t size) const
  • private template <typename T>T getU(uint64_t * OffsetPtr, llvm::Error * Err) const
  • public uint16_t getU16(llvm::DataExtractor::Cursor & C) const
  • public uint16_t * getU16(uint64_t * offset_ptr, uint16_t * dst, uint32_t count) const
  • public uint16_t getU16(uint64_t * offset_ptr, llvm::Error * Err = nullptr) const
  • public uint32_t getU24(uint64_t * OffsetPtr, llvm::Error * Err = nullptr) const
  • public uint32_t getU24(llvm::DataExtractor::Cursor & C) const
  • public uint32_t getU32(uint64_t * offset_ptr, llvm::Error * Err = nullptr) const
  • public uint32_t getU32(llvm::DataExtractor::Cursor & C) const
  • public uint32_t * getU32(uint64_t * offset_ptr, uint32_t * dst, uint32_t count) const
  • public uint64_t getU64(uint64_t * offset_ptr, llvm::Error * Err = nullptr) const
  • public uint64_t getU64(llvm::DataExtractor::Cursor & C) const
  • public uint64_t * getU64(uint64_t * offset_ptr, uint64_t * dst, uint32_t count) const
  • public uint8_t * getU8(llvm::DataExtractor::Cursor & C, uint8_t * Dst, uint32_t Count) const
  • public uint8_t * getU8(uint64_t * offset_ptr, uint8_t * dst, uint32_t count) const
  • public uint8_t getU8(llvm::DataExtractor::Cursor & C) const
  • public uint8_t getU8(uint64_t * offset_ptr, llvm::Error * Err = nullptr) const
  • public void getU8(llvm::DataExtractor::Cursor & C, SmallVectorImpl<uint8_t> & Dst, uint32_t Count) const
  • public uint64_t getULEB128(uint64_t * offset_ptr, llvm::Error * Err = nullptr) const
  • public uint64_t getULEB128(llvm::DataExtractor::Cursor & C) const
  • public uint64_t getUnsigned(llvm::DataExtractor::Cursor & C, uint32_t Size) const
  • public uint64_t getUnsigned(uint64_t * offset_ptr, uint32_t byte_size, llvm::Error * Err = nullptr) const
  • private template <typename T>T * getUs(uint64_t * OffsetPtr, T * Dst, uint32_t Count, llvm::Error * Err) const
  • public bool isLittleEndian() const
  • public bool isValidOffset(uint64_t offset) const
  • public bool isValidOffsetForAddress(uint64_t offset) const
  • public bool isValidOffsetForDataOfSize(uint64_t offset, uint64_t length) const
  • private bool prepareRead(uint64_t Offset, uint64_t Size, llvm::Error * E) const
  • public void setAddressSize(uint8_t Size)
  • public size_t size() const
  • public void skip(llvm::DataExtractor::Cursor & C, uint64_t Length) const

Methods

DataExtractor(ArrayRef<uint8_t> Data,
              bool IsLittleEndian,
              uint8_t AddressSize)

Declared at: llvm/include/llvm/Support/DataExtractor.h:88

Parameters

ArrayRef<uint8_t> Data
bool IsLittleEndian
uint8_t AddressSize

DataExtractor(llvm::StringRef Data,
              bool IsLittleEndian,
              uint8_t AddressSize)

Description

Construct with a buffer that is owned by the caller. This constructor allows us to use data that is owned by the caller. The data must stay around as long as this object is valid.

Declared at: llvm/include/llvm/Support/DataExtractor.h:86

Parameters

llvm::StringRef Data
bool IsLittleEndian
uint8_t AddressSize

bool eof(
    const llvm::DataExtractor::Cursor& C) const

Description

Return true iff the cursor is at the end of the buffer, regardless of the error state of the cursor. The only way both eof and error states can be true is if one attempts a read while the cursor is at the very end of the data buffer.

Declared at: llvm/include/llvm/Support/DataExtractor.h:658

Parameters

const llvm::DataExtractor::Cursor& C

uint64_t getAddress(
    llvm::DataExtractor::Cursor& C) const

Description

Extract a pointer-sized unsigned integer from the location given by the cursor. In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:332

Parameters

llvm::DataExtractor::Cursor& C

uint64_t getAddress(uint64_t* offset_ptr) const

Description

Extract an pointer from \a *offset_ptr. Extract a single pointer from the data and update the offset pointed to by \a offset_ptr. The size of the extracted pointer is \a getAddressSize(), so the address size has to be set correctly prior to extracting any pointer values.

Declared at: llvm/include/llvm/Support/DataExtractor.h:325

Parameters

uint64_t* offset_ptr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.

Returns

The extracted pointer value as a 64 integer.

uint8_t getAddressSize() const

Description

Get the address size for this extractor.

Declared at: llvm/include/llvm/Support/DataExtractor.h:99

llvm::StringRef getBytes(
    uint64_t* OffsetPtr,
    uint64_t Length,
    llvm::Error* Err = nullptr) const

Description

Extract a fixed number of bytes from the specified offset. Returns a StringRef for the bytes from the data at the offset pointed to by \a OffsetPtr. A fixed length C string will be extracted and the \a OffsetPtr will be advanced by \a Length bytes.

Declared at: llvm/include/llvm/Support/DataExtractor.h:233

Parameters

uint64_t* OffsetPtr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
uint64_t Length
The number of bytes to extract. If there are not enough bytes in the data to extract all of the bytes, the offset will be left unmodified.
llvm::Error* Err = nullptr
A pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.

Returns

A StringRef for the extracted bytes. If the offset pointed to by\a OffsetPtr is out of bounds, or if the offset plus the length is out of bounds, a default-initialized StringRef will be returned.

llvm::StringRef getBytes(
    llvm::DataExtractor::Cursor& C,
    uint64_t Length)

Description

Extract a fixed number of bytes from the location given by the cursor. In case of an extraction error, or if the cursor is already in an error state, a default-initialized StringRef is returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:239

Parameters

llvm::DataExtractor::Cursor& C
uint64_t Length

const char* getCStr(
    llvm::DataExtractor::Cursor& C) const

Description

Extract a C string from the location given by the cursor. In case of an extraction error, or if the cursor is already in an error state, a nullptr is returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:136

Parameters

llvm::DataExtractor::Cursor& C

const char* getCStr(
    uint64_t* OffsetPtr,
    llvm::Error* Err = nullptr) const

Description

Extract a C string from \a *offset_ptr. Returns a pointer to a C String from the data at the offset pointed to by \a offset_ptr. A variable length NULL terminated C string will be extracted and the \a offset_ptr will be updated with the offset of the byte that follows the NULL terminator byte.

Declared at: llvm/include/llvm/Support/DataExtractor.h:129

Parameters

uint64_t* OffsetPtr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
llvm::Error* Err = nullptr
A pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.

Returns

A pointer to the C string value in the data. If the offset pointed to by \a offset_ptr is out of bounds, or if the offset plus the length of the C string is out of bounds, NULL will be returned.

llvm::StringRef getCStrRef(
    uint64_t* OffsetPtr,
    llvm::Error* Err = nullptr) const

Description

Extract a C string from \a *offset_ptr. Returns a StringRef for the C String from the data at the offset pointed to by \a offset_ptr. A variable length NULL terminated C string will be extracted and the \a offset_ptr will be updated with the offset of the byte that follows the NULL terminator byte.

Declared at: llvm/include/llvm/Support/DataExtractor.h:164

Parameters

uint64_t* OffsetPtr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
llvm::Error* Err = nullptr
A pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.

Returns

A StringRef for the C string value in the data. If the offset pointed to by \a offset_ptr is out of bounds, or if the offset plus the length of the C string is out of bounds, a default-initialized StringRef will be returned.

llvm::StringRef getCStrRef(
    llvm::DataExtractor::Cursor& C) const

Description

Extract a C string (as a StringRef) from the location given by the cursor. In case of an extraction error, or if the cursor is already in an error state, a default-initialized StringRef is returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:169

Parameters

llvm::DataExtractor::Cursor& C

llvm::StringRef getData() const

Description

Get the data pointed to by this extractor.

Declared at: llvm/include/llvm/Support/DataExtractor.h:95

static llvm::Error& getError(
    llvm::DataExtractor::Cursor& C)

Declared at: llvm/include/llvm/Support/DataExtractor.h:694

Parameters

llvm::DataExtractor::Cursor& C

llvm::StringRef getFixedLengthString(
    uint64_t* OffsetPtr,
    uint64_t Length,
    llvm::StringRef TrimChars = {"\000", 1}) const

Description

Extract a fixed length string from \a *OffsetPtr and consume \a Length bytes. Returns a StringRef for the string from the data at the offset pointed to by \a OffsetPtr. A fixed length C string will be extracted and the \a OffsetPtr will be advanced by \a Length bytes.

Declared at: llvm/include/llvm/Support/DataExtractor.h:203

Parameters

uint64_t* OffsetPtr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
uint64_t Length
The length of the fixed length string to extract. If there are not enough bytes in the data to extract the full string, the offset will be left unmodified.
llvm::StringRef TrimChars = {"\000", 1}
A set of characters to trim from the end of the string. Fixed length strings are commonly either NULL terminated by one or more zero bytes. Some clients have one or more spaces at the end of the string, but a good default is to trim the NULL characters.

Returns

A StringRef for the C string value in the data. If the offset pointed to by \a OffsetPtr is out of bounds, or if the offset plus the length of the C string is out of bounds, a default-initialized StringRef will be returned.

static uint64_t& getOffset(
    llvm::DataExtractor::Cursor& C)

Declared at: llvm/include/llvm/Support/DataExtractor.h:693

Parameters

llvm::DataExtractor::Cursor& C

int64_t getSLEB128(
    llvm::DataExtractor::Cursor& C) const

Description

Extract an signed LEB128 value from the location given by the cursor. In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:619

Parameters

llvm::DataExtractor::Cursor& C

int64_t getSLEB128(
    uint64_t* OffsetPtr,
    llvm::Error* Err = nullptr) const

Description

Extract a signed LEB128 value from \a *offset_ptr. Extracts an signed LEB128 number from this object's data starting at the offset pointed to by \a offset_ptr. The offset pointed to by \a offset_ptr will be updated with the offset of the byte following the last extracted byte.

Declared at: llvm/include/llvm/Support/DataExtractor.h:614

Parameters

uint64_t* OffsetPtr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
llvm::Error* Err = nullptr
A pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.

Returns

The extracted signed integer value.

int64_t getSigned(uint64_t* offset_ptr,
                  uint32_t size) const

Description

Extract an signed integer of size \a byte_size from \a *offset_ptr. Extract a single signed integer value (sign extending if required) and update the offset pointed to by \a offset_ptr. The size of the extracted integer is specified by the \a byte_size argument.\a byte_size should have a value greater than or equal to one and less than or equal to eight since the return value is 64 bits wide. Any \a byte_size values less than 1 or greater than 8 will result in nothing being extracted, and zero being returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:306

Parameters

uint64_t* offset_ptr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
uint32_t size
The size in bytes of the integer to extract.

Returns

The sign extended signed integer value that was extracted, or zero on failure.

template <typename T>
T getU(uint64_t* OffsetPtr,
       llvm::Error* Err) const

Declared at: llvm/include/llvm/Support/DataExtractor.h:702

Templates

T

Parameters

uint64_t* OffsetPtr
llvm::Error* Err

uint16_t getU16(
    llvm::DataExtractor::Cursor& C) const

Description

Extract a single uint16_t value from the location given by the cursor. In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:433

Parameters

llvm::DataExtractor::Cursor& C

uint16_t* getU16(uint64_t* offset_ptr,
                 uint16_t* dst,
                 uint32_t count) const

Description

Extract \a count uint16_t values from \a *offset_ptr. Extract \a count uint16_t values from the binary data at the offset pointed to by \a offset_ptr, and advance the offset on success. The extracted values are copied into \a dst.

Declared at: llvm/include/llvm/Support/DataExtractor.h:458

Parameters

uint64_t* offset_ptr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
uint16_t* dst
A buffer to copy \a count uint16_t values into. \a dst must be large enough to hold all requested data.
uint32_t count
The number of uint16_t values to extract.

Returns

\a dst if all values were properly extracted and copied, NULL otherise.

uint16_t getU16(uint64_t* offset_ptr,
                llvm::Error* Err = nullptr) const

Description

Extract a uint16_t value from \a *offset_ptr. Extract a single uint16_t from the binary data at the offset pointed to by \a offset_ptr, and update the offset on success.

Declared at: llvm/include/llvm/Support/DataExtractor.h:428

Parameters

uint64_t* offset_ptr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
llvm::Error* Err = nullptr
A pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.

Returns

The extracted uint16_t value.

uint32_t getU24(uint64_t* OffsetPtr,
                llvm::Error* Err = nullptr) const

Description

Extract a 24-bit unsigned value from \a *offset_ptr and return it in a uint32_t. Extract 3 bytes from the binary data at the offset pointed to by\a offset_ptr, construct a uint32_t from them and update the offset on success.

Declared at: llvm/include/llvm/Support/DataExtractor.h:481

Parameters

uint64_t* OffsetPtr
A pointer to an offset within the data that will be advanced by the 3 bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
llvm::Error* Err = nullptr
A pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.

Returns

The extracted 24-bit value represented in a uint32_t.

uint32_t getU24(
    llvm::DataExtractor::Cursor& C) const

Description

Extract a single 24-bit unsigned value from the location given by the cursor. In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:486

Parameters

llvm::DataExtractor::Cursor& C

uint32_t getU32(uint64_t* offset_ptr,
                llvm::Error* Err = nullptr) const

Description

Extract a uint32_t value from \a *offset_ptr. Extract a single uint32_t from the binary data at the offset pointed to by \a offset_ptr, and update the offset on success.

Declared at: llvm/include/llvm/Support/DataExtractor.h:508

Parameters

uint64_t* offset_ptr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
llvm::Error* Err = nullptr
A pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.

Returns

The extracted uint32_t value.

uint32_t getU32(
    llvm::DataExtractor::Cursor& C) const

Description

Extract a single uint32_t value from the location given by the cursor. In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:513

Parameters

llvm::DataExtractor::Cursor& C

uint32_t* getU32(uint64_t* offset_ptr,
                 uint32_t* dst,
                 uint32_t count) const

Description

Extract \a count uint32_t values from \a *offset_ptr. Extract \a count uint32_t values from the binary data at the offset pointed to by \a offset_ptr, and advance the offset on success. The extracted values are copied into \a dst.

Declared at: llvm/include/llvm/Support/DataExtractor.h:538

Parameters

uint64_t* offset_ptr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
uint32_t* dst
A buffer to copy \a count uint32_t values into. \a dst must be large enough to hold all requested data.
uint32_t count
The number of uint32_t values to extract.

Returns

\a dst if all values were properly extracted and copied, NULL otherise.

uint64_t getU64(uint64_t* offset_ptr,
                llvm::Error* Err = nullptr) const

Description

Extract a uint64_t value from \a *offset_ptr. Extract a single uint64_t from the binary data at the offset pointed to by \a offset_ptr, and update the offset on success.

Declared at: llvm/include/llvm/Support/DataExtractor.h:560

Parameters

uint64_t* offset_ptr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
llvm::Error* Err = nullptr
A pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.

Returns

The extracted uint64_t value.

uint64_t getU64(
    llvm::DataExtractor::Cursor& C) const

Description

Extract a single uint64_t value from the location given by the cursor. In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:565

Parameters

llvm::DataExtractor::Cursor& C

uint64_t* getU64(uint64_t* offset_ptr,
                 uint64_t* dst,
                 uint32_t count) const

Description

Extract \a count uint64_t values from \a *offset_ptr. Extract \a count uint64_t values from the binary data at the offset pointed to by \a offset_ptr, and advance the offset on success. The extracted values are copied into \a dst.

Declared at: llvm/include/llvm/Support/DataExtractor.h:590

Parameters

uint64_t* offset_ptr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
uint64_t* dst
A buffer to copy \a count uint64_t values into. \a dst must be large enough to hold all requested data.
uint32_t count
The number of uint64_t values to extract.

Returns

\a dst if all values were properly extracted and copied, NULL otherise.

uint8_t* getU8(llvm::DataExtractor::Cursor& C,
               uint8_t* Dst,
               uint32_t Count) const

Description

Extract \a Count uint8_t values from the location given by the cursor and store them into the destination buffer. In case of an extraction error, or if the cursor is already in an error state, a nullptr is returned and the destination buffer is left unchanged.

Declared at: llvm/include/llvm/Support/DataExtractor.h:390

Parameters

llvm::DataExtractor::Cursor& C
uint8_t* Dst
uint32_t Count

uint8_t* getU8(uint64_t* offset_ptr,
               uint8_t* dst,
               uint32_t count) const

Description

Extract \a count uint8_t values from \a *offset_ptr. Extract \a count uint8_t values from the binary data at the offset pointed to by \a offset_ptr, and advance the offset on success. The extracted values are copied into \a dst.

Declared at: llvm/include/llvm/Support/DataExtractor.h:384

Parameters

uint64_t* offset_ptr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
uint8_t* dst
A buffer to copy \a count uint8_t values into. \a dst must be large enough to hold all requested data.
uint32_t count
The number of uint8_t values to extract.

Returns

\a dst if all values were properly extracted and copied, NULL otherise.

uint8_t getU8(
    llvm::DataExtractor::Cursor& C) const

Description

Extract a single uint8_t value from the location given by the cursor. In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:359

Parameters

llvm::DataExtractor::Cursor& C

uint8_t getU8(uint64_t* offset_ptr,
              llvm::Error* Err = nullptr) const

Description

Extract a uint8_t value from \a *offset_ptr. Extract a single uint8_t from the binary data at the offset pointed to by \a offset_ptr, and advance the offset on success.

Declared at: llvm/include/llvm/Support/DataExtractor.h:354

Parameters

uint64_t* offset_ptr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
llvm::Error* Err = nullptr
A pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.

Returns

The extracted uint8_t value.

void getU8(llvm::DataExtractor::Cursor& C,
           SmallVectorImpl<uint8_t>& Dst,
           uint32_t Count) const

Description

Extract \a Count uint8_t values from the location given by the cursor and store them into the destination vector. The vector is resized to fit the extracted data. In case of an extraction error, or if the cursor is already in an error state, the destination vector is left unchanged and cursor is placed into an error state.

Declared at: llvm/include/llvm/Support/DataExtractor.h:397

Parameters

llvm::DataExtractor::Cursor& C
SmallVectorImpl<uint8_t>& Dst
uint32_t Count

uint64_t getULEB128(
    uint64_t* offset_ptr,
    llvm::Error* Err = nullptr) const

Description

Extract a unsigned LEB128 value from \a *offset_ptr. Extracts an unsigned LEB128 number from this object's data starting at the offset pointed to by \a offset_ptr. The offset pointed to by \a offset_ptr will be updated with the offset of the byte following the last extracted byte.

Declared at: llvm/include/llvm/Support/DataExtractor.h:643

Parameters

uint64_t* offset_ptr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
llvm::Error* Err = nullptr
A pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.

Returns

The extracted unsigned integer value.

uint64_t getULEB128(
    llvm::DataExtractor::Cursor& C) const

Description

Extract an unsigned LEB128 value from the location given by the cursor. In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:648

Parameters

llvm::DataExtractor::Cursor& C

uint64_t getUnsigned(
    llvm::DataExtractor::Cursor& C,
    uint32_t Size) const

Description

Extract an unsigned integer of the given size from the location given by the cursor. In case of an extraction error, or if the cursor is already in an error state, zero is returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:279

Parameters

llvm::DataExtractor::Cursor& C
uint32_t Size

uint64_t getUnsigned(
    uint64_t* offset_ptr,
    uint32_t byte_size,
    llvm::Error* Err = nullptr) const

Description

Extract an unsigned integer of size \a byte_size from \a *offset_ptr. Extract a single unsigned integer value and update the offset pointed to by \a offset_ptr. The size of the extracted integer is specified by the \a byte_size argument. \a byte_size should have a value greater than or equal to one and less than or equal to eight since the return value is 64 bits wide. Any\a byte_size values less than 1 or greater than 8 will result in nothing being extracted, and zero being returned.

Declared at: llvm/include/llvm/Support/DataExtractor.h:273

Parameters

uint64_t* offset_ptr
A pointer to an offset within the data that will be advanced by the appropriate number of bytes if the value is extracted correctly. If the offset is out of bounds or there are not enough bytes to extract this value, the offset will be left unmodified.
uint32_t byte_size
The size in byte of the integer to extract.
llvm::Error* Err = nullptr
A pointer to an Error object. Upon return the Error object is set to indicate the result (success/failure) of the function. If the Error object is already set when calling this function, no extraction is performed.

Returns

The unsigned integer value that was extracted, or zero on failure.

template <typename T>
T* getUs(uint64_t* OffsetPtr,
         T* Dst,
         uint32_t Count,
         llvm::Error* Err) const

Declared at: llvm/include/llvm/Support/DataExtractor.h:704

Templates

T

Parameters

uint64_t* OffsetPtr
T* Dst
uint32_t Count
llvm::Error* Err

bool isLittleEndian() const

Description

Get the endianness for this extractor.

Declared at: llvm/include/llvm/Support/DataExtractor.h:97

bool isValidOffset(uint64_t offset) const

Description

Test the validity of \a offset.

Declared at: llvm/include/llvm/Support/DataExtractor.h:665

Parameters

uint64_t offset

Returns

\b true if \a offset is a valid offset into the data in this object, \b false otherwise.

bool isValidOffsetForAddress(
    uint64_t offset) const

Description

Test the availability of enough bytes of data for a pointer from\a offset. The size of a pointer is \a getAddressSize().

Declared at: llvm/include/llvm/Support/DataExtractor.h:683

Parameters

uint64_t offset

Returns

\b true if \a offset is a valid offset and there are enough bytes for a pointer available at that offset, \b false otherwise.

bool isValidOffsetForDataOfSize(
    uint64_t offset,
    uint64_t length) const

Description

Test the availability of \a length bytes of data from \a offset.

Declared at: llvm/include/llvm/Support/DataExtractor.h:672

Parameters

uint64_t offset
uint64_t length

Returns

\b true if \a offset is a valid offset and there are \a length bytes available at that offset, \b false otherwise.

bool prepareRead(uint64_t Offset,
                 uint64_t Size,
                 llvm::Error* E) const

Description

If it is possible to read \a Size bytes at offset \a Offset, returns \b true. Otherwise, returns \b false. If \a E is not nullptr, also sets the error object to indicate an error.

Declared at: llvm/include/llvm/Support/DataExtractor.h:700

Parameters

uint64_t Offset
uint64_t Size
llvm::Error* E

void setAddressSize(uint8_t Size)

Description

Set the address size for this extractor.

Declared at: llvm/include/llvm/Support/DataExtractor.h:101

Parameters

uint8_t Size

size_t size() const

Description

Return the number of bytes in the underlying buffer.

Declared at: llvm/include/llvm/Support/DataExtractor.h:688

void skip(llvm::DataExtractor::Cursor& C,
          uint64_t Length) const

Description

Advance the Cursor position by the given number of bytes. No-op if the cursor is in an error state.

Declared at: llvm/include/llvm/Support/DataExtractor.h:652

Parameters

llvm::DataExtractor::Cursor& C
uint64_t Length