pw_elf#

ELF file support

Experimental C++

pw_elf provides support for interact with Executable and Linkable Format (ELF) files.

Note

This module is currently very limited, primarily supporting other Pigweed modules. Additional functionality (e.g. iterating sections, segments) may be added in the future.

Guides#

Read an ELF section into a buffer#

 1#include "pw_elf/reader.h"
 2
 3#include <vector>
 4
 5#include "pw_status/try.h"
 6#include "pw_stream/std_file_stream.h"
 7
 8pw::Status ReaderExample() {
 9  // Open a file stream for the ELF image.
10  pw::stream::StdFileReader stream("/tmp/example.elf");
11
12  // Create an ElfReader from the file stream.
13  PW_TRY_ASSIGN(auto reader, pw::elf::ElfReader::FromStream(stream));
14
15  // Read the .example section into a vector.
16  PW_TRY_ASSIGN(std::vector<std::byte> section_data,
17                reader.ReadSection(".example"));
18
19  return pw::OkStatus();
20}

API reference#

Moved: pw_elf

Python#

The pw_elf Python package provides utilities to programmatically build ELF32 and ELF64 binary files from scratch. See pw_elf Python package for details.