asmjit::OffsetFormat Struct Reference

Provides information about formatting offsets, absolute addresses, or their parts.

Offset format is used by both RelocEntry and LabelLink. The illustration below describes the relation of region size and offset size. Region size is the size of the whole unit whereas offset size is the size of the unit that will be patched.

+-> Code buffer | The subject of the relocation (region) |
| | (Word-Offset) (Word-Size) |
|xxxxxxxxxxxxxxx|................|*PATCHED*|................|xxxxxxxxxxxx->
| |
[Word Offset points here]----+ +--- [WordOffset + WordSize]

Once the offset word has been located it can be patched like this:

|ImmDiscardLSB (discard LSB bits).
|..
[0000000000000iiiiiiiiiiiiiiiiiDD] - Offset value (32-bit)
[000000000000000iiiiiiiiiiiiiiiii] - Offset value after discard LSB.
[00000000000iiiiiiiiiiiiiiiii0000] - Offset value shifted by ImmBitShift.
[xxxxxxxxxxxiiiiiiiiiiiiiiiiixxxx] - Patched word (32-bit)
|...............|
(ImmBitCount) +- ImmBitShift

Public Members

Members

Member Functions

Accessors

Member Function Documentation

OffsetType OffsetFormat::type() constnoexcept◆ 

Returns the type of the offset.

bool OffsetFormat::hasSignBit() constnoexcept◆ 

Returns whether the offset is encoded as an absolute value of the offset with additional field(s) that represent the sign (AArch32 U/N fields in the opcode).

If true, the offset itself is always positive and a separate U/N field is used to indicate the sign of the offset (usually U==1 means ADD, but sometimes N==1 means negative offset, which implies SUB).

uint32_t OffsetFormat::flags() constnoexcept◆ 

Returns flags.

uint32_t OffsetFormat::regionSize() constnoexcept◆ 

Returns the size of the region/instruction where the offset is encoded.

uint32_t OffsetFormat::valueOffset() constnoexcept◆ 

Returns the offset of the word relative to the start of the region where the offset is.

uint32_t OffsetFormat::valueSize() constnoexcept◆ 

Returns the size of the data-type (word) that contains the offset, in bytes.

uint32_t OffsetFormat::immBitCount() constnoexcept◆ 

Returns the count of bits of the offset value in the data it's stored in.

uint32_t OffsetFormat::immBitShift() constnoexcept◆ 

Returns the bit-shift of the offset value in the data it's stored in.

uint32_t OffsetFormat::immDiscardLsb() constnoexcept◆ 

Returns the number of least significant bits of the offset value, that must be zero and that are not part of the encoded data.

void OffsetFormat::resetToSimpleValue(OffsetType type, size_t valueSize)noexcept◆ 

Resets this offset format to a simple data value of dataSize bytes.

The region will be the same size as data and immediate bits would correspond to dataSize * 8. There will be no immediate bit shift or discarded bits.

Member Data Documentation

OffsetType OffsetFormat::_type◆ 

Type of the offset.

uint8_t OffsetFormat::_flags◆ 

Encoding flags.

uint8_t OffsetFormat::_regionSize◆ 

Size of the region (in bytes) containing the offset value, if the offset value is part of an instruction, otherwise it would be the same as _valueSize.

uint8_t OffsetFormat::_valueSize◆ 

Size of the offset value, in bytes (1, 2, 4, or 8).

uint8_t OffsetFormat::_valueOffset◆ 

Offset of the offset value, in bytes, relative to the start of the region or data.

Value offset would be zero if both region size and value size are equal.

uint8_t OffsetFormat::_immBitCount◆ 

Size of the offset immediate value in bits.

uint8_t OffsetFormat::_immBitShift◆ 

Shift of the offset immediate value in bits in the target word.

uint8_t OffsetFormat::_immDiscardLsb◆ 

Number of least significant bits to discard before writing the immediate to the destination.

All discarded bits must be zero otherwise the value is invalid.