Imports #
"bufio"
"bytes"
"cmd/internal/bio"
"cmd/internal/goobj"
"errors"
"fmt"
"io"
"log"
"os"
"strconv"
"strings"
"time"
"unicode/utf8"
"bufio"
"bytes"
"cmd/internal/bio"
"cmd/internal/goobj"
"errors"
"fmt"
"io"
"log"
"os"
"strconv"
"strings"
"time"
"unicode/utf8"
const EntryGoObj
const EntryNativeObj
const EntryPkgDef EntryType = iota
const EntrySentinelNonObj
architecture-independent object file output
const HeaderSize = 60
var archiveHeader = *ast.CallExpr
var archiveMagic = *ast.CallExpr
const entryHeader = "%s%-12d%-6d%-6d%-8o%-10d`\n"
In entryHeader the first entry, the name, is always printed as 16 bytes right-padded.
const entryLen = *ast.BinaryExpr
var errCorruptArchive = *ast.CallExpr
var errCorruptObject = *ast.CallExpr
var errNotObject = *ast.CallExpr
var errTruncatedArchive = *ast.CallExpr
var goobjHeader = *ast.CallExpr
const timeFormat = "Jan _2 15:04 2006"
type EntryType int
type Archive struct {
f *os.File
Entries []Entry
}
A Data is a reference to data stored in an object file. It records the offset and size of the data, so that a client can read the data only if necessary.
type Data struct {
Offset int64
Size int64
}
type Entry struct {
Name string
Type EntryType
Mtime int64
Uid int
Gid int
Mode os.FileMode
Data
Obj *GoObj
}
type ErrGoObjOtherVersion struct {
magic []byte
}
type GoObj struct {
TextHeader []byte
Arch string
Data
}
An objReader is an object file reader.
type objReader struct {
a *Archive
b *bio.Reader
err error
offset int64
limit int64
tmp [256]byte
}
AddEntry adds an entry to the end of a, with the content from r.
func (a *Archive) AddEntry(typ EntryType, name string, mtime int64, uid int, gid int, mode os.FileMode, size int64, r io.Reader)
func (e ErrGoObjOtherVersion) Error() string
func (a *Archive) File() *os.File
func FormatHeader(arhdr []byte, name string, size int64)
New writes to f to make a new archive.
func New(f *os.File) (*Archive, error)
Parse parses an object file or archive from f.
func Parse(f *os.File, verbose bool) (*Archive, error)
func ReadHeader(b *bufio.Reader, name string) int
func (e *Entry) String() string
error records that an error occurred. It returns only the first error, so that an error caused by an earlier error does not discard information about the earlier error.
func (r *objReader) error(err error) error
exactly16Bytes truncates the string if necessary so it is at most 16 bytes long, then pads the result with spaces to be exactly 16 bytes. Fmt uses runes for its width calculation, but we need bytes in the entry header.
func exactly16Bytes(s string) string
func (r *objReader) init(f *os.File)
parseArchive parses a Unix archive of Go object files.
func (r *objReader) parseArchive(verbose bool) error
parseObject parses a single Go object file. The object file consists of a textual header ending in "\n!\n" and then the part we want to parse begins. The format of that part is defined in a comment at the top of cmd/internal/goobj/objfile.go.
func (r *objReader) parseObject(o *GoObj, size int64) error
peek returns the next n bytes without advancing the reader.
func (r *objReader) peek(n int) ([]byte, error)
readByte reads and returns a byte from the input file. On I/O error or EOF, it records the error but returns byte 0. A sequence of 0 bytes will eventually terminate any parsing state in the object file. In particular, it ends the reading of a varint.
func (r *objReader) readByte() byte
readFull reads exactly len(b) bytes from the input file. If an error occurs, read returns the error but also records it, so it is safe for callers to ignore the result as long as delaying the report is not a problem.
func (r *objReader) readFull(b []byte) error
skip skips n bytes in the input.
func (r *objReader) skip(n int64)
trimSpace removes trailing spaces from b and returns the corresponding string. This effectively parses the form used in archive headers.
func trimSpace(b []byte) string
Generated with Arrow