testbin

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package testbin builds the small binaries the Brotli detector's tests read: decoder error tables exactly as each upstream release lays them out, and ELF, PE and Mach-O files that define or import decoder symbols.

Index

Constants

This section is empty.

Variables

View Source
var Releases = map[string]struct {
	Names    []string
	Prefixed bool
}{
	"1.0.2":  {list(success, common, compound, tail), false},
	"1.0.3":  {list(success, common, distance, compound, tail), false},
	"1.0.9":  {list(success, common, distance, tail), false},
	"1.0.10": {list(success, common, distance, blockSwitch, tail), false},
	"1.1.0":  {list(success, common, distance, compound, tail), true},
	"1.1.1":  {list(success, common, distance, blockSwitch, compound, tail), true},
	"1.2.0":  {list(success, common, distance, compound, tail), true},
	"1.2.1":  {list(success, common, distance, blockSwitch, compound, tail), true},
}

Releases maps a Brotli release to its error names and whether it stores them prefixed. 1.0.4 to 1.0.9 dropped COMPOUND_DICTIONARY; 1.1.0 brought it back and the prefixed form.

Functions

func DecoderTables

func DecoderTables(gap int) []byte

DecoderTables returns the decoder's two code-length tables (kCodeLengthPrefixLength, then kCodeLengthPrefixValue) as a compiler lays them out, with gap bytes between them.

func ELF

func ELF(syms []Symbol, extra []byte) []byte

ELF returns a little-endian ELF64 shared object whose .dynsym holds syms, followed by extra (a table, a version stamp) in a data section.

func ELFAt

func ELFAt(syms []Symbol, extra []byte, addr, value uint64, machine uint16) []byte

ELFAt is ELF with the data section loaded at addr (0: not loaded), each defined symbol's value set to value, and the given machine (62 x86-64, 183 arm64). The data section is also marked executable, so extra can hold code.

func Executable

func Executable(extra ...[]byte) []byte

Executable returns extra behind an ELF header and padding: a file the engine reads as an executable, with no symbol tables.

func MachO

func MachO(syms []Symbol, extra []byte) []byte

MachO returns a 64-bit Mach-O dylib whose symbol table holds syms (defined ones as exported N_SECT symbols), followed by extra.

func PE

func PE(exports []string, extra []byte) []byte

PE returns a 64-bit PE DLL whose export directory names exports, followed by extra.

func Table

func Table(release string) []byte

Table returns release's BrotliDecoderErrorString strings as a compiler lays them out: NUL-terminated, one after another, preceded by a NUL.

Types

type Symbol

type Symbol struct {
	Name    string
	Defined bool
}

Symbol is one dynamic symbol: defined in the file, or imported.

Jump to

Keyboard shortcuts

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