Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

42.13. elfutils-0.196

utilities and libraries for handling ELF files

Version 0.196, release 1
Shelf toolchain — The native compilers, the linker, the C library, and the LLVM family
Phase 30_foundation (Build Foundation), 92 of 127 in build order
Licence GPL-3.0-or-later AND (GPL-2.0-or-later OR LGPL-3.0-or-later)
Homepage https://sourceware.org/elfutils/
Build time 0.7 SBU
Installed size 7.2 MiB in 178 files
Recipe ports/core/toolchain/elfutils/kpkgbuild

About

elfutils is a set of libraries and tools for ELF object files and DWARF debug information. libelf reads and writes ELF files, libdw reads DWARF and unwinds stacks, and libasm assembles and disassembles; the tools (eu-readelf, eu-strip, eu-stack, eu-addr2line and the rest) are built on them.

Most of what KDOS uses elfutils for is the libraries. The kernel build (linux) and perf, libbpf, bpftool, bpftrace, bcc and dwarves read ELF files through libelf; strace prints stack traces with libdw (--with-libdw); glib is built with -D libelf=enabled; and mesa, qemu, gstreamer, ltrace, iproute2 and others name it in depends. It is in 30_foundation with the musl compatibility libraries it is built against, argp-standalone, musl-fts, musl-obstack and musl-rpmatch, listed just above it.

Why it is in KDOS

The comment above the 7 ports from libintl to patchelf in script/phases/30_foundation/packages.txt:

The gettext runtime: musl has no gettext in libc and the gettext port is built --disable-nls, so newsboat's libintl_gettext resolves nowhere without it.

Sources

Dependencies

Depends on: zlib, xz, bzip2, zstd, libarchive, argp-standalone, musl-fts, musl-obstack, musl-rpmatch.

Required by (22): avrdude, bcc, bpftool, bpftrace, dwarves, fastfetch, glib, glib-introspection, gstreamer, iproute2, libbpf, linux, ltrace, mesa, mesa-opencl, mgba, opencpn, perf, qemu, qt-creator, strace, v4l-utils.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/30_foundation/phase.env && kpkg install elfutils'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/toolchain/elfutils.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/toolchain/elfutils
echo 'fd5cc6b77ad6773cac93cb3f415f9318ac3b3455eecf801f6b4a742c4f6c7209  elfutils-0.196.tar.bz2' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/elfutils
SRC=$SRC_ROOT/elfutils-0.196
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf elfutils-0.196.tar.bz2 -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

CFLAGS="$CFLAGS -Wno-error -include libgen.h -include rpmatch.h -DFNM_EXTMATCH=0" \
LDFLAGS="$LDFLAGS -lrpmatch" \
    ./configure --prefix=/usr --program-prefix="eu-" \
	--disable-debuginfod --disable-libdebuginfod \
	--disable-stackprof \
	--with-zlib --with-bzlib --with-lzma --with-zstd \
	--with-libarchive
make
make DESTDIR=$PKG install

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/elfutils, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf elfutils-0.196-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/elfutils, and runs the triggers its paths call for.

Contents

Installed programs: eu-addr2line, eu-ar, eu-elfclassify, eu-elfcmp, eu-elfcompress, eu-elflint, eu-findtextrel, eu-make-debug-archive, eu-nm, eu-objdump, eu-ranlib, eu-readelf, eu-size, eu-srcfiles, eu-stack, eu-strings, eu-strip, eu-unstrip.

Installed libraries: libasm-0.196.so, libasm.a, libasm.so, libdw-0.196.so, libdw.a, libdw.so, libelf-0.196.so, libelf.a, libelf.so.

Installed directories: /usr/include/elfutils, /usr/share/licenses/elfutils.

Short descriptions

eu-elfclassify Determine the type of an ELF file.
eu-readelf Displays information about ELF files.
eu-srcfiles Lists the source files of a DWARF/ELF file.
libdw.pc elfutils library for DWARF data and ELF file or process inspection
libelf.pc elfutils libelf library to read and write ELF files

Notes

argp, fts and obstack need no switch: configure searches for argp_parse, fts_close and _obstack_free in the C library first and then in -largp, -lfts and -lobstack, and stops if none has them. That is why argp-standalone, musl-fts and musl-obstack are build dependencies; musl-rpmatch is one only because build.sh names its header and library. In the built package libdw.so needs libfts.so.0; eu-ar, eu-ranlib and eu-nm need libobstack.so.1; and the argp code is copied into each program from the static libargp.a.