elfmeta

package
v1.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package elfmeta lets a package build pre-compute the ELF facts that filesystem-level consumers otherwise re-derive by opening and parsing every library — most prominently ld.so.cache generation, which needs only each library's machine and SONAMEs but costs a full ELF parse per file to learn them.

A producer (melange, or any packaging tool) runs Extract over a built file and stamps Xattr with the encoded Info. Consumers read the xattr instead of the file; a miss or a malformed value falls back to parsing. When carried in a package, the stamp rides the data section's PAX records like any other xattr and is covered by the package signature. It stays on installed files and persists into images by default. In apko image builds, WithStripElfmetaStamps(true) removes it after ld.so.cache generation, before writing image layers.

Stamps live on regular files only: Linux permits user.* xattrs on neither symlinks nor special files, so a library's facts are stamped on the real file and consumers resolve links before reading.

A stamp is exactly as authoritative as the package carrying it: a producer that stamps wrong facts mis-describes its own contents, just as it could ship a wrong library outright. Consumers trust it accordingly and do not re-derive stamped facts.

Index

Constants

View Source
const Xattr = "user.dev.chainguard.elfmeta"

Xattr is the extended attribute carrying an encoded Info. It rides wherever file metadata rides — tar PAX records, filesystem xattrs — and stays with the file for its lifetime. The name is vendored: user.* is a namespace shared with every tool on the system.

Variables

This section is empty.

Functions

func EligibleName

func EligibleName(realname string) bool

EligibleName reports whether a filename is one an ldconfig-style scan would consider — the shape producers stamp by.

func ParseLibFilename

func ParseLibFilename(realname string) (string, string, error)

ParseLibFilename splits a shared-library filename into its name and version — "libfoo.so.1" into "libfoo" and "1", "libbar.so" into "libbar" and "" — and reports an error for names outside the scheme ldconfig considers: per ldconfig(8), files named lib*.so* (regular shared objects) or ld-*.so* (the dynamic loader itself).

Types

type Info

type Info struct {
	Dyn     bool
	Machine elf.Machine
	Sonames []string
}

Info is the pre-computed metadata: whether the file is a dynamic object at all, and if so its machine and SONAMEs. A stamped Info with Dyn=false is meaningful — it records "checked, not a dynamic object", sparing consumers the parse that would rediscover that.

func Decode

func Decode(b []byte) (Info, error)

Decode parses an Xattr value.

func Extract

func Extract(r io.ReaderAt) (Info, error)

Extract computes Info from an ELF file. A parseable non-dynamic object (an executable, say) yields Dyn=false and no error; content that does not parse as ELF at all is an error, and producers stamping by filename convention typically encode that as Dyn=false too.

func (Info) Encode

func (i Info) Encode() []byte

Encode renders Info as the Xattr value: "none" for a non-dynamic object, else "dyn <machine>" followed by one SONAME per line.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL