debug::image+x86_64 +linux

This module implements functionality for examining executable files. It provides some support code for working with memory-mapped ELF executables.

That this module does not make compatibility guarantees and is subject to change in the future should Hare be ported to a target with a different executable format.

Index

Types

// Undocumented types:
type image = struct {
	fd: io::file,
	data: []u8,
	header: *elf::header64,
	// Cached sections
	shstrtab: nullable *elf::section64,
	symtab: nullable *elf::section64,
	strtab: nullable *elf::section64,
	debug_abbr: nullable *elf::section64,
	debug_aranges: nullable *elf::section64,
	debug_info: nullable *elf::section64,
	debug_line: nullable *elf::section64,
	debug_str: nullable *elf::section64,
};

Functions

fn close(image: *image) void;
fn open(file: io::file) (image | io::error);
fn section_byname(image: *image, name: str) nullable *elf::section64;
fn section_data(image: *image, sec: *elf::section64) []u8;
fn section_name(image: *image, sec: *elf::section64) const str;
fn section_reader(image: *image, sec: *elf::section64) memio::stream;
fn self() (image | io::error | fs::error);

Types

type image[link]

Show undocumented member
type image = struct {
	fd: io::file,
	data: []u8,
	header: *elf::header64,
	// Cached sections
	shstrtab: nullable *elf::section64,
	symtab: nullable *elf::section64,
	strtab: nullable *elf::section64,
	debug_abbr: nullable *elf::section64,
	debug_aranges: nullable *elf::section64,
	debug_info: nullable *elf::section64,
	debug_line: nullable *elf::section64,
	debug_str: nullable *elf::section64,
};

Functions

fn close[link]

fn close(image: *image) void;

Closes a program image.

fn open[link]

fn open(file: io::file) (image | io::error);

Opens an io::file as a program image.

fn section_byname[link]

fn section_byname(image: *image, name: str) nullable *elf::section64;

Returns a program section by name. Returns null if there is no such section, or if the section names are not available in this image (e.g. because it was stripped).

fn section_data[link]

fn section_data(image: *image, sec: *elf::section64) []u8;

Returns a slice of the data contained with a given section.

fn section_name[link]

fn section_name(image: *image, sec: *elf::section64) const str;

Returns the name of this elf::section64, returning "" if the section names are not available in this image (i.e. it has been stripped).

fn section_reader[link]

fn section_reader(image: *image, sec: *elf::section64) memio::stream;

Returns a memio::fixed reader for the given section.

fn self[link]

fn self() (image | io::error | fs::error);

Opens the executing process's binary image.