Help us shape the future of Go! Take the 2026 Go Developer Survey

elftest

package
v0.46.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package elftest builds minimal, REAL ELF64 files for tests.

⛔ IT EXISTS BECAUSE A PLACEHOLDER FIXTURE CANNOT WITNESS A CHECK THAT READS BYTES. In go-pkgx/bk, every "shared library" in the tests of `bk unlinked` contained the single byte "x". The suite was green, coverage was complete and every mutation was caught — while the shipped command counted `libstdc++.so.6.0.33-gdb.py` (a Python script) as a library in v0.43, and then refused `libfolly.so.0.58.0-dev` (an ELF shared object) in v0.44.0. Two opposite errors in one day, both invisible to fixtures that were not ELF files.

The builders here are deliberately hand-assembled rather than produced by a linker: a test that needs a toolchain to make its input does not run on the lane where the input is foreign, which is exactly the lane a cross-platform reader has to be right on.

Each builder verifies its own output with debug/elf before returning, so a malformed fixture fails as a fixture rather than as the thing under test.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteExports

func WriteExports(t *testing.T, path string, defined []string, undef ...string)

WriteExports writes an ELF64 whose .dynsym DEFINES the given symbols, and leaves `undef` as undefined references.

⛔ THE SPLIT IS THE POINT. An undefined symbol is one the file NEEDS; a defined one is what it PROVIDES. A reader that does not separate them answers "does it use gettext" when asked "does it provide gettext", and those have opposite consequences for a dependency.

func WriteNeeded

func WriteNeeded(t *testing.T, path string, needed ...string)

WriteNeeded writes an ELF64 whose .dynamic names the given DT_NEEDED entries, creating parent directories as required.

Types

This section is empty.

Jump to

Keyboard shortcuts

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