eb-local.elfcheck

module eb-local.elfcheck  src/elfcheck.zig[source][autodoc]

eb-local check: what a program built by hand on EESSI depends on, and whether it can run here. It reads the ELF file’s loader (PT_INTERP), run paths (DT_RPATH, DT_RUNPATH) and needed libraries (DT_NEEDED), finds each library as the loader would, and reports what breaks the “no LD_LIBRARY_PATH, one CPU target” rule: a foreign architecture, the host’s loader or libraries under an EESSI stack, RUNPATH, a library not found, and run paths into another CPU target’s software tree.

Types

pub const Elf = struct[source][autodoc]

What an ELF file says about its dynamic linking: its machine, its program interpreter (the loader), the libraries it names as DT_NEEDED, and its DT_RPATH and DT_RUNPATH; null where it has none.

machine: u16[source]
interp: ?[]const u8 = null[source]
needed: []const []const u8 = &.{}[source]
rpath: ?[]const u8 = null[source]
runpath: ?[]const u8 = null[source]

Error sets

pub const ParseError = error{ NotElf64, Unsupported, Truncated, Damaged } || sys.Error || Allocator.Error[source][autodoc]

Why parse read nothing: NotElf64 for a file too short for an ELF header or without the ELF magic, Unsupported for a 32-bit or big-endian one, Truncated when the file ends before a part its headers name, and Damaged for a header field out of bounds, a string with no end, or a read that fails.

Functions

pub fn parse(a: Allocator, fd: sys.fd_t) ParseError!Elf[source][autodoc]

The dynamic-linking facts of the 64-bit little-endian ELF file open as fd; every string is copied into a.

pub fn hostMachine() u16[source][autodoc]

The ELF machine of this build, which is the node’s.

pub fn machineName(m: u16) []const u8[source][autodoc]

The name check prints for the ELF machine m: x86_64, aarch64, riscv64, i386, arm, or “another architecture”.

pub fn loaderRoot(interp: []const u8) []const u8[source][autodoc]

The loader’s root directory from PT_INTERP (dirname(dirname(interp))), or "/" when the interpreter path has fewer than two parent directories.

pub fn expandOrigin(a: Allocator, dir: []const u8, origin: []const u8) Allocator.Error![]const u8[source][autodoc]

dir with $ORIGIN and ${ORIGIN} replaced by origin.

pub fn targetOf(path: []const u8) ?[]const u8[source][autodoc]

The CPU target of an EESSI software tree a path lies in: the parts after /software/linux/ up to the next software, modules or accel, as EESSI and EESSI-extend lay out their trees; null outside one.

pub fn isHostPath(path: []const u8) bool[source][autodoc]

A host directory the EESSI compatibility layer replaces.

pub fn parseLdSoConf(a: Allocator, text: []const u8, dirs: *std.ArrayList([]const u8), includes: *std.ArrayList([]const u8)) Allocator.Error!void[source][autodoc]

One ld.so.conf file: the directories it names go to dirs and the patterns of its include lines to includes, in file order.