C/C++ API Reference
Loading...
Searching...
No Matches
pw_elf

Overview

ELF file support.

Main docs: Home

Classes

class  pw::elf::ElfReader
 A basic reader for ELF files. More...
 

Functions

static Result< ElfReaderpw::elf::ElfReader::FromStream (stream::SeekableReader &stream)
 
stream::SeekableReaderpw::elf::ElfReader::stream () const
 Gets the associated stream.
 
StatusWithSize pw::elf::ElfReader::SeekToSection (std::string_view name)
 
Result< std::vector< std::byte > > pw::elf::ElfReader::ReadSection (std::string_view name)
 

Function Documentation

◆ FromStream()

static Result< ElfReader > pw::elf::ElfReader::FromStream ( stream::SeekableReader stream)
static

Creates an ElfReader from a stream.

Returns
A Result containing the initialized reader on success or one of the following error codes on failure:
  • DATA_LOSS: The input file was invalid.
  • OUT_OF_RANGE: Input stream exhausted (EOF).
  • UNIMPLEMENTED: Some aspect of the ELF file is not (yet) supported by this class, e.g., non-native endianness, or 64-bit ELF on a 32-bit host.
  • May return other error codes from the underlying stream.

◆ ReadSection()

Result< std::vector< std::byte > > pw::elf::ElfReader::ReadSection ( std::string_view  name)

Reads a section with the given name.

Parameters
[in]nameThe name of the desired section.
Returns
  • OK: Successfully read the desired section. The result value is a vector of the section data.
  • NOT_FOUND: No section was found with the desired name.
  • May return other error codes from the underlying stream.

◆ SeekToSection()

StatusWithSize pw::elf::ElfReader::SeekToSection ( std::string_view  name)
inline

Seeks the associated stream to the beginning of the data of the section with the given name.

Parameters
[in]nameThe name of the desired section.
Returns
  • OK: Successfully found the desired section and seeked the stream to it. The associated size is the size of the associated section.
  • NOT_FOUND: No section was found with the desired name.
  • May return other error codes from the underlying stream.