package exportdata
Import Path
internal/exportdata (on go.dev)
Dependency Relation
imports 13 packages, and imported by one package
Involved Source Files
Package exportdata implements common utilities for finding
and reading gc-generated object files.
support.go
Package-Level Functions (total 5)
FindPackageDefinition positions the reader r at the beginning of a package
definition file ("__.PKGDEF") within a GC-created archive by reading
from it, and returns the size of the package definition file in the archive.
The reader must be positioned at the start of the archive file before calling
this function, and "__.PKGDEF" is assumed to be the first file in the archive.
See cmd/internal/archive for details on the archive format.
FindPkg returns the filename and unique package id for an import
path based on package information provided by build.Import (using
the build.Default build.Context). A relative srcDir is interpreted
relative to the current working directory.
ReadExportDataHeader reads the export data header and format from r.
It returns the number of bytes read, or an error if the format is no longer
supported or it failed to read.
The only currently supported format is binary export data in the
unified export format.
ReadObjectHeaders reads object headers from the reader. Object headers are
lines that do not start with an end-of-section marker "$$". The first header
is the objabi header. On success, the reader will be positioned at the beginning
of the end-of-section marker.
It returns an error if any header does not fit in r.Size() bytes.
ReadUnified reads the contents of the unified export data from a reader r
that contains the contents of a GC-created archive file.
On success, the reader will be positioned after the end-of-section marker "\n$$\n".
Supported GC-created archive files have 4 layers of nesting:
- An archive file containing a package definition file.
- The package definition file contains headers followed by a data section.
Headers are lines (≤ 4kb) that do not start with "$$".
- The data section starts with "$$B\n" followed by export data followed
by an end of section marker "\n$$\n". (The section start "$$\n" is no
longer supported.)
- The export data starts with a format byte ('u') followed by the <data> in
the given format. (See ReadExportDataHeader for older formats.)
Putting this together, the bytes in a GC-created archive files are expected
to look like the following.
See cmd/internal/archive for more details on ar file headers.
| <!arch>\n | ar file signature
| __.PKGDEF...size...\n | ar header for __.PKGDEF including size.
| go object <...>\n | objabi header
| <optional headers>\n | other headers such as build id
| $$B\n | binary format marker
| u<data>\n | unified export <data>
| $$\n | end-of-section marker
| [optional padding] | padding byte (0x0A) if size is odd
| [ar file header] | other ar files
| [ar file data] |
The pages are generated with Golds v0.7.3-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |