Documentation ¶
Overview ¶
Package fatbin implements a simple fat binary format, and provides facilities for creating fat binaries and accessing its variants.
A fatbin binary is a base binary with a zip archive appended, containing copies of the same binary targeted to different GOOS/GOARCH combinations. The zip archive contains one entry for each supported architecture and operating system combination. At the end of a fatbin image is a footer, storing the offset of the zip archive as well as a magic constant used to identify fatbin images:
[8]offset[4]magic[8]checksum
The checksum is a 64-bit xxhash checksum of the offset and magic fields. The magic value is 0x5758ba2c.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoSuchImage is returned when the fatbin does not contain an // image for the requested GOOS/GOARCH combination. ErrNoSuchImage = errors.New("image does not exist") // ErrCorruptedImage is returned when the fatbin image has been // corrupted. ErrCorruptedImage = errors.New("corrupted fatbin image") )
Functions ¶
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads images from a fatbin.
func NewReader ¶
NewReader returns a new fatbin reader from the provided reader. The offset should be the offset of the fatbin archive; size is the total file size. The provided goos and goarch are that of the base binary.
func OpenFile ¶
OpenFile parses the provided ReaderAt with the provided size. The file's contents is parsed to determine the offset of the fatbin's archive. OpenFile returns an error if the file is not a fatbin.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is used to append fatbin images to an existing binary.
func NewFileWriter ¶
NewFileWriter returns a writer that can be used to append fatbin images to the binary represented by the provided file. NewFileWriter removes any existing fatbin images that may be attached to the binary. It relies on content sniffing (see Sniff) to determine its offset.
func NewWriter ¶
NewWriter returns a writer that may be used to append fatbin images to the writer w. The writer should be positioned at the end of the base binary image.
func (*Writer) Close ¶
Close should be called after all images have been written. No more images can be written after a call to Close.