|
@@ -79,17 +79,17 @@ public:
|
|
/// pointed to by \a offset_ptr is out of bounds, or if the
|
|
/// 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,
|
|
/// offset plus the length of the C string is out of bounds,
|
|
/// NULL will be returned.
|
|
/// NULL will be returned.
|
|
- const char *getCStr(uint32_t *offset_ptr) const;
|
|
|
|
|
|
+ const char *getCStr(uint64_t *offset_ptr) const;
|
|
|
|
|
|
- /// Extract a C string from \a *OffsetPtr.
|
|
|
|
|
|
+ /// Extract a C string from \a *offset_ptr.
|
|
///
|
|
///
|
|
/// Returns a StringRef for the C String from the data at the offset
|
|
/// Returns a StringRef for the C String from the data at the offset
|
|
- /// pointed to by \a OffsetPtr. A variable length NULL terminated C
|
|
|
|
- /// string will be extracted and the \a OffsetPtr will be
|
|
|
|
|
|
+ /// 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
|
|
/// updated with the offset of the byte that follows the NULL
|
|
/// terminator byte.
|
|
/// terminator byte.
|
|
///
|
|
///
|
|
- /// \param[in,out] OffsetPtr
|
|
|
|
|
|
+ /// \param[in,out] offset_ptr
|
|
/// A pointer to an offset within the data that will be advanced
|
|
/// A pointer to an offset within the data that will be advanced
|
|
/// by the appropriate number of bytes if the value is extracted
|
|
/// by the appropriate number of bytes if the value is extracted
|
|
/// correctly. If the offset is out of bounds or there are not
|
|
/// correctly. If the offset is out of bounds or there are not
|
|
@@ -98,10 +98,10 @@ public:
|
|
///
|
|
///
|
|
/// \return
|
|
/// \return
|
|
/// A StringRef for the C string value in the data. If the offset
|
|
/// 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
|
|
|
|
|
|
+ /// 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,
|
|
/// offset plus the length of the C string is out of bounds,
|
|
/// a default-initialized StringRef will be returned.
|
|
/// a default-initialized StringRef will be returned.
|
|
- StringRef getCStrRef(uint32_t *OffsetPtr) const;
|
|
|
|
|
|
+ StringRef getCStrRef(uint64_t *offset_ptr) const;
|
|
|
|
|
|
/// Extract an unsigned integer of size \a byte_size from \a
|
|
/// Extract an unsigned integer of size \a byte_size from \a
|
|
/// *offset_ptr.
|
|
/// *offset_ptr.
|
|
@@ -127,7 +127,7 @@ public:
|
|
/// @return
|
|
/// @return
|
|
/// The unsigned integer value that was extracted, or zero on
|
|
/// The unsigned integer value that was extracted, or zero on
|
|
/// failure.
|
|
/// failure.
|
|
- uint64_t getUnsigned(uint32_t *offset_ptr, uint32_t byte_size) const;
|
|
|
|
|
|
+ uint64_t getUnsigned(uint64_t *offset_ptr, uint32_t byte_size) const;
|
|
|
|
|
|
/// Extract an signed integer of size \a byte_size from \a *offset_ptr.
|
|
/// Extract an signed integer of size \a byte_size from \a *offset_ptr.
|
|
///
|
|
///
|
|
@@ -152,7 +152,7 @@ public:
|
|
/// @return
|
|
/// @return
|
|
/// The sign extended signed integer value that was extracted,
|
|
/// The sign extended signed integer value that was extracted,
|
|
/// or zero on failure.
|
|
/// or zero on failure.
|
|
- int64_t getSigned(uint32_t *offset_ptr, uint32_t size) const;
|
|
|
|
|
|
+ int64_t getSigned(uint64_t *offset_ptr, uint32_t size) const;
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
//------------------------------------------------------------------
|
|
/// Extract an pointer from \a *offset_ptr.
|
|
/// Extract an pointer from \a *offset_ptr.
|
|
@@ -171,7 +171,7 @@ public:
|
|
///
|
|
///
|
|
/// @return
|
|
/// @return
|
|
/// The extracted pointer value as a 64 integer.
|
|
/// The extracted pointer value as a 64 integer.
|
|
- uint64_t getAddress(uint32_t *offset_ptr) const {
|
|
|
|
|
|
+ uint64_t getAddress(uint64_t *offset_ptr) const {
|
|
return getUnsigned(offset_ptr, AddressSize);
|
|
return getUnsigned(offset_ptr, AddressSize);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -189,7 +189,7 @@ public:
|
|
///
|
|
///
|
|
/// @return
|
|
/// @return
|
|
/// The extracted uint8_t value.
|
|
/// The extracted uint8_t value.
|
|
- uint8_t getU8(uint32_t *offset_ptr) const;
|
|
|
|
|
|
+ uint8_t getU8(uint64_t *offset_ptr) const;
|
|
|
|
|
|
/// Extract \a count uint8_t values from \a *offset_ptr.
|
|
/// Extract \a count uint8_t values from \a *offset_ptr.
|
|
///
|
|
///
|
|
@@ -214,7 +214,7 @@ public:
|
|
/// @return
|
|
/// @return
|
|
/// \a dst if all values were properly extracted and copied,
|
|
/// \a dst if all values were properly extracted and copied,
|
|
/// NULL otherise.
|
|
/// NULL otherise.
|
|
- uint8_t *getU8(uint32_t *offset_ptr, uint8_t *dst, uint32_t count) const;
|
|
|
|
|
|
+ uint8_t *getU8(uint64_t *offset_ptr, uint8_t *dst, uint32_t count) const;
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
//------------------------------------------------------------------
|
|
/// Extract a uint16_t value from \a *offset_ptr.
|
|
/// Extract a uint16_t value from \a *offset_ptr.
|
|
@@ -232,7 +232,7 @@ public:
|
|
/// @return
|
|
/// @return
|
|
/// The extracted uint16_t value.
|
|
/// The extracted uint16_t value.
|
|
//------------------------------------------------------------------
|
|
//------------------------------------------------------------------
|
|
- uint16_t getU16(uint32_t *offset_ptr) const;
|
|
|
|
|
|
+ uint16_t getU16(uint64_t *offset_ptr) const;
|
|
|
|
|
|
/// Extract \a count uint16_t values from \a *offset_ptr.
|
|
/// Extract \a count uint16_t values from \a *offset_ptr.
|
|
///
|
|
///
|
|
@@ -257,7 +257,7 @@ public:
|
|
/// @return
|
|
/// @return
|
|
/// \a dst if all values were properly extracted and copied,
|
|
/// \a dst if all values were properly extracted and copied,
|
|
/// NULL otherise.
|
|
/// NULL otherise.
|
|
- uint16_t *getU16(uint32_t *offset_ptr, uint16_t *dst, uint32_t count) const;
|
|
|
|
|
|
+ uint16_t *getU16(uint64_t *offset_ptr, uint16_t *dst, uint32_t count) const;
|
|
|
|
|
|
/// Extract a 24-bit unsigned value from \a *offset_ptr and return it
|
|
/// Extract a 24-bit unsigned value from \a *offset_ptr and return it
|
|
/// in a uint32_t.
|
|
/// in a uint32_t.
|
|
@@ -274,7 +274,7 @@ public:
|
|
///
|
|
///
|
|
/// @return
|
|
/// @return
|
|
/// The extracted 24-bit value represented in a uint32_t.
|
|
/// The extracted 24-bit value represented in a uint32_t.
|
|
- uint32_t getU24(uint32_t *offset_ptr) const;
|
|
|
|
|
|
+ uint32_t getU24(uint64_t *offset_ptr) const;
|
|
|
|
|
|
/// Extract a uint32_t value from \a *offset_ptr.
|
|
/// Extract a uint32_t value from \a *offset_ptr.
|
|
///
|
|
///
|
|
@@ -290,7 +290,7 @@ public:
|
|
///
|
|
///
|
|
/// @return
|
|
/// @return
|
|
/// The extracted uint32_t value.
|
|
/// The extracted uint32_t value.
|
|
- uint32_t getU32(uint32_t *offset_ptr) const;
|
|
|
|
|
|
+ uint32_t getU32(uint64_t *offset_ptr) const;
|
|
|
|
|
|
/// Extract \a count uint32_t values from \a *offset_ptr.
|
|
/// Extract \a count uint32_t values from \a *offset_ptr.
|
|
///
|
|
///
|
|
@@ -315,7 +315,7 @@ public:
|
|
/// @return
|
|
/// @return
|
|
/// \a dst if all values were properly extracted and copied,
|
|
/// \a dst if all values were properly extracted and copied,
|
|
/// NULL otherise.
|
|
/// NULL otherise.
|
|
- uint32_t *getU32(uint32_t *offset_ptr, uint32_t *dst, uint32_t count) const;
|
|
|
|
|
|
+ uint32_t *getU32(uint64_t *offset_ptr, uint32_t *dst, uint32_t count) const;
|
|
|
|
|
|
/// Extract a uint64_t value from \a *offset_ptr.
|
|
/// Extract a uint64_t value from \a *offset_ptr.
|
|
///
|
|
///
|
|
@@ -331,7 +331,7 @@ public:
|
|
///
|
|
///
|
|
/// @return
|
|
/// @return
|
|
/// The extracted uint64_t value.
|
|
/// The extracted uint64_t value.
|
|
- uint64_t getU64(uint32_t *offset_ptr) const;
|
|
|
|
|
|
+ uint64_t getU64(uint64_t *offset_ptr) const;
|
|
|
|
|
|
/// Extract \a count uint64_t values from \a *offset_ptr.
|
|
/// Extract \a count uint64_t values from \a *offset_ptr.
|
|
///
|
|
///
|
|
@@ -356,7 +356,7 @@ public:
|
|
/// @return
|
|
/// @return
|
|
/// \a dst if all values were properly extracted and copied,
|
|
/// \a dst if all values were properly extracted and copied,
|
|
/// NULL otherise.
|
|
/// NULL otherise.
|
|
- uint64_t *getU64(uint32_t *offset_ptr, uint64_t *dst, uint32_t count) const;
|
|
|
|
|
|
+ uint64_t *getU64(uint64_t *offset_ptr, uint64_t *dst, uint32_t count) const;
|
|
|
|
|
|
/// Extract a signed LEB128 value from \a *offset_ptr.
|
|
/// Extract a signed LEB128 value from \a *offset_ptr.
|
|
///
|
|
///
|
|
@@ -374,7 +374,7 @@ public:
|
|
///
|
|
///
|
|
/// @return
|
|
/// @return
|
|
/// The extracted signed integer value.
|
|
/// The extracted signed integer value.
|
|
- int64_t getSLEB128(uint32_t *offset_ptr) const;
|
|
|
|
|
|
+ int64_t getSLEB128(uint64_t *offset_ptr) const;
|
|
|
|
|
|
/// Extract a unsigned LEB128 value from \a *offset_ptr.
|
|
/// Extract a unsigned LEB128 value from \a *offset_ptr.
|
|
///
|
|
///
|
|
@@ -392,21 +392,21 @@ public:
|
|
///
|
|
///
|
|
/// @return
|
|
/// @return
|
|
/// The extracted unsigned integer value.
|
|
/// The extracted unsigned integer value.
|
|
- uint64_t getULEB128(uint32_t *offset_ptr) const;
|
|
|
|
|
|
+ uint64_t getULEB128(uint64_t *offset_ptr) const;
|
|
|
|
|
|
/// Test the validity of \a offset.
|
|
/// Test the validity of \a offset.
|
|
///
|
|
///
|
|
/// @return
|
|
/// @return
|
|
/// \b true if \a offset is a valid offset into the data in this
|
|
/// \b true if \a offset is a valid offset into the data in this
|
|
/// object, \b false otherwise.
|
|
/// object, \b false otherwise.
|
|
- bool isValidOffset(uint32_t offset) const { return Data.size() > offset; }
|
|
|
|
|
|
+ bool isValidOffset(uint64_t offset) const { return Data.size() > offset; }
|
|
|
|
|
|
/// Test the availability of \a length bytes of data from \a offset.
|
|
/// Test the availability of \a length bytes of data from \a offset.
|
|
///
|
|
///
|
|
/// @return
|
|
/// @return
|
|
/// \b true if \a offset is a valid offset and there are \a
|
|
/// \b true if \a offset is a valid offset and there are \a
|
|
/// length bytes available at that offset, \b false otherwise.
|
|
/// length bytes available at that offset, \b false otherwise.
|
|
- bool isValidOffsetForDataOfSize(uint32_t offset, uint32_t length) const {
|
|
|
|
|
|
+ bool isValidOffsetForDataOfSize(uint64_t offset, uint64_t length) const {
|
|
return offset + length >= offset && isValidOffset(offset + length - 1);
|
|
return offset + length >= offset && isValidOffset(offset + length - 1);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -417,9 +417,32 @@ public:
|
|
/// \b true if \a offset is a valid offset and there are enough
|
|
/// \b true if \a offset is a valid offset and there are enough
|
|
/// bytes for a pointer available at that offset, \b false
|
|
/// bytes for a pointer available at that offset, \b false
|
|
/// otherwise.
|
|
/// otherwise.
|
|
- bool isValidOffsetForAddress(uint32_t offset) const {
|
|
|
|
|
|
+ bool isValidOffsetForAddress(uint64_t offset) const {
|
|
return isValidOffsetForDataOfSize(offset, AddressSize);
|
|
return isValidOffsetForDataOfSize(offset, AddressSize);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // The following methods are temporarily kept in order to preserve
|
|
|
|
+ // compatibility with existing code and migrate to 64-bit offsets smoothly.
|
|
|
|
+ // They will be removed when the migration is finished.
|
|
|
|
+ // Please do not use them in new code.
|
|
|
|
+ const char *getCStr(uint32_t *offset_ptr) const;
|
|
|
|
+ StringRef getCStrRef(uint32_t *offset_ptr) const;
|
|
|
|
+ uint64_t getUnsigned(uint32_t *offset_ptr, uint32_t byte_size) const;
|
|
|
|
+ int64_t getSigned(uint32_t *offset_ptr, uint32_t size) const;
|
|
|
|
+ uint64_t getAddress(uint32_t *offset_ptr) const {
|
|
|
|
+ return getUnsigned(offset_ptr, AddressSize);
|
|
|
|
+ }
|
|
|
|
+ uint8_t getU8(uint32_t *offset_ptr) const;
|
|
|
|
+ uint8_t *getU8(uint32_t *offset_ptr, uint8_t *dst, uint32_t count) const;
|
|
|
|
+ uint16_t getU16(uint32_t *offset_ptr) const;
|
|
|
|
+ uint16_t *getU16(uint32_t *offset_ptr, uint16_t *dst, uint32_t count) const;
|
|
|
|
+ uint32_t getU24(uint32_t *offset_ptr) const;
|
|
|
|
+ uint32_t getU32(uint32_t *offset_ptr) const;
|
|
|
|
+ uint32_t *getU32(uint32_t *offset_ptr, uint32_t *dst, uint32_t count) const;
|
|
|
|
+ uint64_t getU64(uint32_t *offset_ptr) const;
|
|
|
|
+ uint64_t *getU64(uint32_t *offset_ptr, uint64_t *dst, uint32_t count) const;
|
|
|
|
+ int64_t getSLEB128(uint32_t *offset_ptr) const;
|
|
|
|
+ uint64_t getULEB128(uint32_t *offset_ptr) const;
|
|
};
|
|
};
|
|
|
|
|
|
} // namespace llvm
|
|
} // namespace llvm
|