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
elfutils-0.196.tar.bz2(11.6 MiB)
sha256fd5cc6b77ad6773cac93cb3f415f9318ac3b3455eecf801f6b4a742c4f6c7209
upstream: https://sourceware.org/ftp/elfutils/0.196/elfutils-0.196.tar.bz2
archive copy: sources-4/toolchain--elfutils-0.196.tar.bz2
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:
-Wno-error— elfutils compiles its sources with-Werror(AM_CFLAGSandAM_CXXFLAGSinconfig/eu.am). automake putsCFLAGSafter the project’s own flags, so for the C sources this later switch turns warnings back into warnings, and a new warning from a newer compiler or C library header does not stop the build. It is not inCXXFLAGS, so the one C++ source this build compiles,eu-srcfiles’src/srcfiles.cxx, still builds with-Werror.-include libgen.h— forces<libgen.h>, which declares musl’sbasename(), into every compile ahead of the source’s own includes. elfutils’lib/system.hdefines its ownxbasename()and then poisons the bare name with#pragma GCC poison basename, which forbids any later use; a declaration seen before the pragma is not an error.-include rpmatch.h,-lrpmatch(inLDFLAGS) — force musl-rpmatch’s header into every compile and add its library to every link. The elfutils source in this version callsrpmatch()nowhere, so neither has an effect: the header adds an unused declaration, and the tree’s-Wl,--as-neededdrops the library from every link, so no installed file needslibrpmatch.-DFNM_EXTMATCH=0— musl’s<fnmatch.h>has noFNM_EXTMATCH, the glibc flag that lets a pattern use ksh-style groups such as@(a|b). elfutils passes it ineu-strip’s--remove-sectionand--keep-sectionpatterns andeu-elfcompress’s--name; defined as 0, those patterns are plain shell globs, although--helpstill calls them “extended wildcard” patterns. One default is lost with it:eu-elfcompressgiven no--namematches sections against.?(z)debug*, which as a plain glob matches no real section name, so it reports “Nothing to do.” Name the sections, as ineu-elfcompress --name='.debug*' file.o.--program-prefix="eu-"— installs every tool aseu-<name>, soeu-strip,eu-arandeu-readelfsit beside binutils’strip,arandreadelfinstead of overwriting them.eu-is upstream’s default when no prefix is given; the recipe states it.--disable-debuginfod,--disable-libdebuginfod— build neither the debuginfod server nor the client library. debuginfod serves debug information and sources over HTTP, and the client lets libdw and theeu-tools fetch what a binary lacks from such a server. With the client off,libdwmakes no network request when it looks for missing debug files, and the package needs neither libcurl nor json-c.--disable-stackprof— do not buildeu-stackprof, a sampling profiler built onperf_event_open. Without the switch,configurebuilds it whenever it findsjson-c, a C++20<format>and a kernel header with build-id support inperf_event_attr, so the package would gain a program depending on what happened to be installed in the chroot.--with-zlib,--with-bzlib,--with-lzma,--with-zstd— let libdwfl read ELF and debug files compressed with gzip, bzip2, xz and zstd. Each is otherwise used only if found; named,configurestops when its library is missing, so the package cannot lose a format silently. libelf also uses zstd and zlib for compressed ELF sections.--with-libarchive— linkeu-srcfilesagainst libarchive, which gives it--zip: collect every source file a binary’s DWARF names into one zip archive on standard output. Without libarchive the option is not compiled in.
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.