struct EncodedPtr

Defined at line 65 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

This is the encoding byte used in the DW_OP_GNU_encoded_addr extension,

in GNU ..eh_frame_hdr format, and in GNU de facto standard augmentation

for .debug_frame formats. This is a struct with non-scoped enums rather

than using `enum class`, so that the names are scoped to the struct type

but the values are convertible to uint8_t and implicitly usable with

bitwise operations.

The default-constructed EncodedPtr object represents an omitted value.

This gives an integer value of zero, but takes no space to encode.

Public Members

 
uint8_t encoding
uint8_t encoded_size
static const uint8_t kIndirect
static const uint8_t kDynamicSize

Public Methods

PtrType Type (uint8_t encoding)

This yields just the basic encoding, regardless of indirection or

adjustments. This is all that's needed to determine the encoded size.

Defined at line 105 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

PtrModifier Modifier (uint8_t encoding)

This yields just the modifier for a relative address. After the basic

value is decoded according to Type(encoding), this is what adjustment must

be done to the value.

Defined at line 112 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

bool Indirect (uint8_t encoding)

This indicates that the value is actually stored elsewhere in memory. The

Type(encoding) still indicates the type of that stored pointer, as well as

the basic type of the encoding used to locate it. After applying the

Modifier(encoding) adjustments to the encoded pointer, that pointer must

be dereferenced to fetch the desired value.

Defined at line 121 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

bool Signed (uint8_t encoding)

This indicates if the encoded value is signed, so it should be

sign-extended from narrower encoding to a wider integer type.

Defined at line 127 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

uint8_t EncodedSize (uint8_t encoding, uint8_t address_size)

This returns the encoded size, which may depend on the contextual address

size. It returns kDynamicSize for LEB128 types whose exact size cannot be

known without the actual data.

Defined at line 139 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

template <class Elf = Elf<>>
uint8_t Normalize (uint8_t encoding, uint8_t address_size)

This normalizes the encoding so that it's unambiguous with respect to

address size. After normalization, an encoding can be used directly

without keeping track of the address size that's indicated by, or implicit

in, the context it came from.

Defined at line 167 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

template <class Elf = Elf<>, auto& memory>
std::optional<uint64_t> FromMemory (uint8_t encoding, MemoryReader<typename Elf::size_type, std::byte, typename Elf::Addr> auto & memory, typename Elf::size_type vaddr, uint8_t address_size)

Read an encoded value via the Memory object. Both the vaddr argument and

the encoded addresses (in case of indirection) are in whatever address

space the Memory object provides. To support the indirection case

properly, don't adjust the vaddr argument for use with a generic Memory

object. Instead use a Memory object that takes the unadjusted address and

implicitly applies the runtime load bias for the module containing the

DWARF metadata being read; this ensures that a possible second call to the

Memory object will correctly handle an address read from the metadata

rather than the given vaddr argument. When reading variable-sized

(LEB128) data, the single-argument ReadArray method of the Memory object

is expected to return at least as much data as the value encoding requires

in the single call. Returns std::nullopt if the Memory object fails.

Otherwise the value is extended to 64 bits. In the case of a signed

encoding, bit_cast

<int64

_t> should be used on the value.

Defined at line 190 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

template <class Elf = Elf<>, auto& memory>
std::optional<uint64_t> FromMemory (uint8_t encoding, MemoryReader<typename Elf::size_type, std::byte, typename Elf::Addr> auto & memory, typename Elf::size_type vaddr, uint8_t address_size)

Read an encoded value via the Memory object. Both the vaddr argument and

the encoded addresses (in case of indirection) are in whatever address

space the Memory object provides. To support the indirection case

properly, don't adjust the vaddr argument for use with a generic Memory

object. Instead use a Memory object that takes the unadjusted address and

implicitly applies the runtime load bias for the module containing the

DWARF metadata being read; this ensures that a possible second call to the

Memory object will correctly handle an address read from the metadata

rather than the given vaddr argument. When reading variable-sized

(LEB128) data, the single-argument ReadArray method of the Memory object

is expected to return at least as much data as the value encoding requires

in the single call. Returns std::nullopt if the Memory object fails.

Otherwise the value is extended to 64 bits. In the case of a signed

encoding, bit_cast

<int64

_t> should be used on the value.

Defined at line 190 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

template <class Elf = Elf<>, auto& memory>
std::optional<uint64_t> FromMemory (uint8_t encoding, MemoryReader<typename Elf::size_type, std::byte, typename Elf::Addr> auto & memory, typename Elf::size_type vaddr, uint8_t address_size)

Read an encoded value via the Memory object. Both the vaddr argument and

the encoded addresses (in case of indirection) are in whatever address

space the Memory object provides. To support the indirection case

properly, don't adjust the vaddr argument for use with a generic Memory

object. Instead use a Memory object that takes the unadjusted address and

implicitly applies the runtime load bias for the module containing the

DWARF metadata being read; this ensures that a possible second call to the

Memory object will correctly handle an address read from the metadata

rather than the given vaddr argument. When reading variable-sized

(LEB128) data, the single-argument ReadArray method of the Memory object

is expected to return at least as much data as the value encoding requires

in the single call. Returns std::nullopt if the Memory object fails.

Otherwise the value is extended to 64 bits. In the case of a signed

encoding, bit_cast

<int64

_t> should be used on the value.

Defined at line 190 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

template <class Elf = Elf<>, auto& memory>
std::optional<uint64_t> FromMemory (uint8_t encoding, MemoryReader<typename Elf::size_type, std::byte, typename Elf::Addr> auto & memory, typename Elf::size_type vaddr, uint8_t address_size)

Read an encoded value via the Memory object. Both the vaddr argument and

the encoded addresses (in case of indirection) are in whatever address

space the Memory object provides. To support the indirection case

properly, don't adjust the vaddr argument for use with a generic Memory

object. Instead use a Memory object that takes the unadjusted address and

implicitly applies the runtime load bias for the module containing the

DWARF metadata being read; this ensures that a possible second call to the

Memory object will correctly handle an address read from the metadata

rather than the given vaddr argument. When reading variable-sized

(LEB128) data, the single-argument ReadArray method of the Memory object

is expected to return at least as much data as the value encoding requires

in the single call. Returns std::nullopt if the Memory object fails.

Otherwise the value is extended to 64 bits. In the case of a signed

encoding, bit_cast

<int64

_t> should be used on the value.

Defined at line 190 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

template <class Elf = Elf<>>
std::optional<EncodedPtr> Read (uint8_t encoding, std::span<const std::byte> bytes, uint8_t address_size)

Read an encoded value from the byte buffer. This returns an

EncodedPtr object rather than the resolved value. The caller is

responsible for applying modifiers and indirection to the value.

Defined at line 235 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

template <class Elf = Elf<>>
std::optional<EncodedPtr> Read (uint8_t encoding, std::span<const std::byte> bytes, uint8_t address_size)

Read an encoded value from the byte buffer. This returns an

EncodedPtr object rather than the resolved value. The caller is

responsible for applying modifiers and indirection to the value.

Defined at line 235 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

template <class Elf = Elf<>>
std::optional<EncodedPtr> Read (uint8_t encoding, std::span<const std::byte> bytes, uint8_t address_size)

Read an encoded value from the byte buffer. This returns an

EncodedPtr object rather than the resolved value. The caller is

responsible for applying modifiers and indirection to the value.

Defined at line 235 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

template <class Elf = Elf<>>
std::optional<EncodedPtr> Read (uint8_t encoding, std::span<const std::byte> bytes, uint8_t address_size)

Read an encoded value from the byte buffer. This returns an

EncodedPtr object rather than the resolved value. The caller is

responsible for applying modifiers and indirection to the value.

Defined at line 235 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

template <class Elf = Elf<>>
std::optional<EncodedPtr> Read (uint8_t encoding, std::span<const std::byte> bytes, uint8_t address_size)

Read an encoded value from the byte buffer. This returns an

EncodedPtr object rather than the resolved value. The caller is

responsible for applying modifiers and indirection to the value.

Defined at line 235 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

Enumerations

enum PtrType
Name Value
kOmit 0xff
kPtr 0x00
kUleb128 0x01
kUdata2 0x02
kUdata4 0x03
kUdata8 0x04
kSigned 0x08
kSleb128 0x09
kSdata2 0x0a
kSdata4 0x0b
kSdata8 0x0c

These are the primary values that indicate basic integer encoding.

Defined at line 67 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

enum PtrModifier
Name Value
kAbs 0x00
kPcrel 0x10
kTextrel 0x20
kDatarel 0x30
kFuncrel 0x40
kAligned 0x50

One of these can be OR'd in with one of the basic encodings above. Note

that the relative encodings implicitly refer to different base addresses

in different contexts, e.g. kDatarel inside .eh_frame_hdr is relative to

the beginning of .eh_frame_hdr itself.

Defined at line 90 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/encoding.h

Records