class SectionData

Defined at line 53 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

elfldltl::dwarf::SectionData represents a DWARF data unit in memory. It

identifies the DWARF format (offset size) used inside the unit, and

holds a std::span

<const

std::byte> of the unit's contents. SectionData

objects are small and trivially copyable like std::span.

Public Methods

void SectionData ()

Defined at line 63 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

void SectionData (const SectionData & )

Defined at line 65 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

void SectionData (std::span<const std::byte> contents, Format format)

Defined at line 67 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

SectionData & operator= (const SectionData & )

Defined at line 70 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

size_t size_bytes ()

The total size of this data unit, including its initial length header.

This is the amount of the data that is consumed by Read (see below).

Defined at line 74 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

std::span<const std::byte> contents ()

The contents of this data unit, not including its initial length header.

Defined at line 77 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

Format format ()

The format of this data unit.

Defined at line 80 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

uint8_t initial_length_size ()

The size of this data unit's initial length header.

Defined at line 83 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

uint8_t InitialLengthSize (Format format)

The size of any data unit's initial length header given the format.

Defined at line 86 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

uint8_t offset_size ()

The size in bytes of DWARF offsets (4 or 8) used in this data unit.

Defined at line 91 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

uint8_t OffsetSize (Format format)

The size of DWARF offsets used in any data unit given the format.

Defined at line 94 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

template <class Elf = Elf<>>
std::optional<uint64_t> read_offset (size_t pos)

Read an offset in this data unit's format from the byte buffer.

Returns std::nullopt if the buffer is too small. The Elf template

parameter indicates the byte order used in the data unit.

Defined at line 102 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

template <class Elf = Elf<>>
std::optional<uint64_t> ReadOffset (Format format, std::span<const std::byte> bytes)

Read an offset in the indicated DWARF format from the byte buffer.

A 32-bit offset is zero-extended to uint64_t.

Defined at line 109 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

template <class Elf = Elf<>, class Diagnostics, typename... ErrorArgs>
std::pair<std::optional<SectionData>, std::span<const std::byte>> Consume (Diagnostics & diag, std::span<const std::byte> bytes, ErrorArgs &&... error_args)

This combines Read with peeling off the size_bytes() consumed from the

byte stream, returning the new tail:

```

auto [data, bytes] = SectionData::Consume(diag, bytes);

if (data) {

Decode(data->contents);

}

```

On failure (when `data == std::nullopt`), `bytes` is returned unchanged.

Defined at line 141 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

template <class Elf = Elf<>, class Diagnostics, typename... ErrorArgs>
std::optional<SectionData> Read (Diagnostics & diag, std::span<const std::byte> bytes, ErrorArgs &&... error_args)

This identifies the size and format of a data unit in the byte stream.

If there is a fundamental format error, it's reported via the

Diagnostics object with the error_args appended after the generic

message and std::nullopt is returned. Otherwise, size_bytes()

indicates how much of the byte stream was consumed by this unit, and

contents() holds the data unit bytes after the initial length: where

the header for the particular kind of data starts.

Defined at line 163 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h

Enumerations

enum Format
Name Value
kDwarf32 0
kDwarf64 1

This indicates the DWARF format used in a single data unit. This

implies the offset size used in its data, as well as the form and size

of its initial length header.

Defined at line 58 of file ../../src/lib/elfldltl/include/lib/elfldltl/dwarf/section-data.h