NBPR.Elf (NBPR v0.2.1)

Copy Markdown View Source

Minimal ELF introspection: reads a binary's DT_NEEDED shared-library dependencies via readelf.

Used by NBPR.Artifact.LibCheck to find shared libraries an nbpr package's binaries link against but that nothing in the firmware provides. Only the NEEDED list is read — resolution is by soname (filename), matching the dynamic loader, so providers don't need their SONAME inspected.

Summary

Functions

Returns true when readelf is available on PATH.

Returns true when path is a regular file whose first bytes are the ELF magic number. Cheap pre-filter so readelf isn't spawned for scripts, configs, and other non-ELF files in a package's priv/.

Returns the DT_NEEDED sonames of the ELF at path.

Functions

available?()

@spec available?() :: boolean()

Returns true when readelf is available on PATH.

elf?(path)

@spec elf?(Path.t()) :: boolean()

Returns true when path is a regular file whose first bytes are the ELF magic number. Cheap pre-filter so readelf isn't spawned for scripts, configs, and other non-ELF files in a package's priv/.

needed(path)

@spec needed(Path.t()) :: [String.t()]

Returns the DT_NEEDED sonames of the ELF at path.

Returns [] for a non-dynamic ELF, a non-ELF file, or any readelf failure — the caller treats "couldn't read deps" the same as "no deps", so a missing or odd file never aborts a firmware build.