...

Package goobj

import "cmd/internal/goobj"
Overview
Index

Overview ▾

Index ▾

Constants
func BuiltinIdx(name string, abi int) int
func BuiltinName(i int) (string, int)
func NBuiltin() int
type Aux
    func (a *Aux) SetSym(x SymRef)
    func (a *Aux) SetType(x uint8)
    func (a *Aux) Sym() SymRef
    func (a *Aux) Type() uint8
    func (a *Aux) Write(w *Writer)
type CUFileIndex
type FingerprintType
    func (fp FingerprintType) IsZero() bool
type FuncInfo
    func (*FuncInfo) ReadArgs(b []byte) uint32
    func (*FuncInfo) ReadFile(b []byte, filesoff uint32, k uint32) CUFileIndex
    func (*FuncInfo) ReadFuncFlag(b []byte) abi.FuncFlag
    func (*FuncInfo) ReadFuncID(b []byte) abi.FuncID
    func (*FuncInfo) ReadFuncInfoLengths(b []byte) FuncInfoLengths
    func (*FuncInfo) ReadInlTree(b []byte, inltreeoff uint32, k uint32) InlTreeNode
    func (*FuncInfo) ReadLocals(b []byte) uint32
    func (*FuncInfo) ReadStartLine(b []byte) int32
    func (a *FuncInfo) Write(w *bytes.Buffer)
type FuncInfoLengths
type Hash64Type
type HashType
type Header
    func (h *Header) Read(r *Reader) error
    func (h *Header) Size() int
    func (h *Header) Write(w *Writer)
type ImportedPkg
    func (p *ImportedPkg) Write(w *Writer)
type InlTreeNode
    func (inl *InlTreeNode) Read(b []byte) []byte
    func (inl *InlTreeNode) Write(w *bytes.Buffer)
type Reader
    func NewReaderFromBytes(b []byte, readonly bool) *Reader
    func (r *Reader) Autolib() []ImportedPkg
    func (r *Reader) Aux(i uint32, j int) *Aux
    func (r *Reader) AuxOff(i uint32, j int) uint32
    func (r *Reader) Auxs(i uint32) []Aux
    func (r *Reader) BytesAt(off uint32, len int) []byte
    func (r *Reader) Data(i uint32) []byte
    func (r *Reader) DataOff(i uint32) uint32
    func (r *Reader) DataSize(i uint32) int
    func (r *Reader) DataString(i uint32) string
    func (r *Reader) File(i int) string
    func (r *Reader) Fingerprint() FingerprintType
    func (r *Reader) Flags() uint32
    func (r *Reader) FromAssembly() bool
    func (r *Reader) Hash(i uint32) *HashType
    func (r *Reader) Hash64(i uint32) uint64
    func (r *Reader) NAux(i uint32) int
    func (r *Reader) NFile() int
    func (r *Reader) NHashed64def() int
    func (r *Reader) NHasheddef() int
    func (r *Reader) NNonpkgdef() int
    func (r *Reader) NNonpkgref() int
    func (r *Reader) NPkg() int
    func (r *Reader) NRefFlags() int
    func (r *Reader) NRefName() int
    func (r *Reader) NReloc(i uint32) int
    func (r *Reader) NSym() int
    func (r *Reader) Pkg(i int) string
    func (r *Reader) Pkglist() []string
    func (r *Reader) ReadOnly() bool
    func (r *Reader) RefFlags(i int) *RefFlags
    func (r *Reader) RefName(i int) *RefName
    func (r *Reader) Reloc(i uint32, j int) *Reloc
    func (r *Reader) RelocOff(i uint32, j int) uint32
    func (r *Reader) Relocs(i uint32) []Reloc
    func (r *Reader) Shared() bool
    func (r *Reader) Std() bool
    func (r *Reader) StringAt(off uint32, len uint32) string
    func (r *Reader) StringRef(off uint32) string
    func (r *Reader) Sym(i uint32) *Sym
    func (r *Reader) SymOff(i uint32) uint32
    func (r *Reader) Unlinkable() bool
type RefFlags
    func (r *RefFlags) Flag() uint8
    func (r *RefFlags) Flag2() uint8
    func (r *RefFlags) SetFlag(x uint8)
    func (r *RefFlags) SetFlag2(x uint8)
    func (r *RefFlags) SetSym(x SymRef)
    func (r *RefFlags) Sym() SymRef
    func (r *RefFlags) Write(w *Writer)
type RefName
    func (n *RefName) Name(r *Reader) string
    func (n *RefName) SetName(x string, w *Writer)
    func (n *RefName) SetSym(x SymRef)
    func (n *RefName) Sym() SymRef
    func (n *RefName) Write(w *Writer)
type Reloc
    func (r *Reloc) Add() int64
    func (r *Reloc) Off() int32
    func (r *Reloc) Set(off int32, size uint8, typ uint16, add int64, sym SymRef)
    func (r *Reloc) SetAdd(x int64)
    func (r *Reloc) SetOff(x int32)
    func (r *Reloc) SetSiz(x uint8)
    func (r *Reloc) SetSym(x SymRef)
    func (r *Reloc) SetType(x uint16)
    func (r *Reloc) Siz() uint8
    func (r *Reloc) Sym() SymRef
    func (r *Reloc) Type() uint16
    func (r *Reloc) Write(w *Writer)
type Sym
    func (s *Sym) ABI() uint16
    func (s *Sym) ABIWrapper() bool
    func (s *Sym) Align() uint32
    func (s *Sym) Dupok() bool
    func (s *Sym) Flag() uint8
    func (s *Sym) Flag2() uint8
    func (s *Sym) IsDict() bool
    func (s *Sym) IsGoType() bool
    func (s *Sym) IsItab() bool
    func (s *Sym) IsLinkname() bool
    func (s *Sym) IsPkgInit() bool
    func (s *Sym) Leaf() bool
    func (s *Sym) Local() bool
    func (s *Sym) Name(r *Reader) string
    func (s *Sym) NameLen(r *Reader) int
    func (s *Sym) NoSplit() bool
    func (s *Sym) ReflectMethod() bool
    func (s *Sym) SetABI(x uint16)
    func (s *Sym) SetAlign(x uint32)
    func (s *Sym) SetFlag(x uint8)
    func (s *Sym) SetFlag2(x uint8)
    func (s *Sym) SetName(x string, w *Writer)
    func (s *Sym) SetSiz(x uint32)
    func (s *Sym) SetType(x uint8)
    func (s *Sym) Siz() uint32
    func (s *Sym) Type() uint8
    func (s *Sym) Typelink() bool
    func (s *Sym) UsedInIface() bool
    func (s *Sym) Write(w *Writer)
type SymRef
    func (s SymRef) IsZero() bool
type Writer
    func NewWriter(wr *bio.Writer) *Writer
    func (w *Writer) AddString(s string)
    func (w *Writer) Bytes(s []byte)
    func (w *Writer) Offset() uint32
    func (w *Writer) RawString(s string)
    func (w *Writer) StringRef(s string)
    func (w *Writer) Uint16(x uint16)
    func (w *Writer) Uint32(x uint32)
    func (w *Writer) Uint64(x uint64)
    func (w *Writer) Uint8(x uint8)

Package files

builtin.go builtinlist.go funcinfo.go objfile.go

Constants

Package Index.

const (
    PkgIdxNone     = (1<<31 - 1) - iota // Non-package symbols
    PkgIdxHashed64                      // Short hashed (content-addressable) symbols
    PkgIdxHashed                        // Hashed (content-addressable) symbols
    PkgIdxBuiltin                       // Predefined runtime symbols (ex: runtime.newobject)
    PkgIdxSelf                          // Symbols defined in the current package
    PkgIdxSpecial  = PkgIdxSelf         // Indices above it has special meanings
    PkgIdxInvalid  = 0
)

Blocks

const (
    BlkAutolib = iota
    BlkPkgIdx
    BlkFile
    BlkSymdef
    BlkHashed64def
    BlkHasheddef
    BlkNonpkgdef
    BlkNonpkgref
    BlkRefFlags
    BlkHash64
    BlkHash
    BlkRelocIdx
    BlkAuxIdx
    BlkDataIdx
    BlkReloc
    BlkAux
    BlkData
    BlkRefName
    BlkEnd
    NBlk
)
const (
    ObjFlagShared = 1 << iota // this object is built with -shared

    ObjFlagFromAssembly // object is from asm src, not go
    ObjFlagUnlinkable   // unlinkable package (linker will emit an error)
    ObjFlagStd          // standard library package
)

Sym.Flag

const (
    SymFlagDupok = 1 << iota
    SymFlagLocal
    SymFlagTypelink
    SymFlagLeaf
    SymFlagNoSplit
    SymFlagReflectMethod
    SymFlagGoType
)

Sym.Flag2

const (
    SymFlagUsedInIface = 1 << iota
    SymFlagItab
    SymFlagDict
    SymFlagPkgInit
    SymFlagLinkname
    SymFlagABIWrapper
)

Aux Type

const (
    AuxGotype = iota
    AuxFuncInfo
    AuxFuncdata
    AuxDwarfInfo
    AuxDwarfLoc
    AuxDwarfRanges
    AuxDwarfLines
    AuxPcsp
    AuxPcfile
    AuxPcline
    AuxPcinline
    AuxPcdata
    AuxWasmImport
    AuxSehUnwindInfo
)
const AuxSize = 1 + 8
const Hash64Size = 8
const HashSize = 16 // truncated SHA256
const Magic = "\x00go120ld"
const RefFlagsSize = 8 + 1 + 1
const RefNameSize = 8 + stringRefSize
const RelocSize = 4 + 1 + 2 + 8 + 8
const SymABIstatic = ^uint16(0)
const SymSize = stringRefSize + 2 + 1 + 1 + 1 + 4 + 4

func BuiltinIdx

func BuiltinIdx(name string, abi int) int

BuiltinIdx returns the index of the builtin with the given name and abi, or -1 if it is not a builtin.

func BuiltinName

func BuiltinName(i int) (string, int)

BuiltinName returns the name and ABI of the i-th builtin symbol.

func NBuiltin

func NBuiltin() int

NBuiltin returns the number of listed builtin symbols.

type Aux

Aux symbol info.

Serialized format:

Aux struct {
   Type uint8
   Sym  SymRef
}
type Aux [AuxSize]byte

func (*Aux) SetSym

func (a *Aux) SetSym(x SymRef)

func (*Aux) SetType

func (a *Aux) SetType(x uint8)

func (*Aux) Sym

func (a *Aux) Sym() SymRef

func (*Aux) Type

func (a *Aux) Type() uint8

func (*Aux) Write

func (a *Aux) Write(w *Writer)

type CUFileIndex

CUFileIndex is used to index the filenames that are stored in the per-package/per-CU FileList.

type CUFileIndex uint32

type FingerprintType

type FingerprintType [8]byte

func (FingerprintType) IsZero

func (fp FingerprintType) IsZero() bool

type FuncInfo

FuncInfo is serialized as a symbol (aux symbol). The symbol data is the binary encoding of the struct below.

type FuncInfo struct {
    Args      uint32
    Locals    uint32
    FuncID    abi.FuncID
    FuncFlag  abi.FuncFlag
    StartLine int32
    File      []CUFileIndex
    InlTree   []InlTreeNode
}

func (*FuncInfo) ReadArgs

func (*FuncInfo) ReadArgs(b []byte) uint32

func (*FuncInfo) ReadFile

func (*FuncInfo) ReadFile(b []byte, filesoff uint32, k uint32) CUFileIndex

func (*FuncInfo) ReadFuncFlag

func (*FuncInfo) ReadFuncFlag(b []byte) abi.FuncFlag

func (*FuncInfo) ReadFuncID

func (*FuncInfo) ReadFuncID(b []byte) abi.FuncID

func (*FuncInfo) ReadFuncInfoLengths

func (*FuncInfo) ReadFuncInfoLengths(b []byte) FuncInfoLengths

func (*FuncInfo) ReadInlTree

func (*FuncInfo) ReadInlTree(b []byte, inltreeoff uint32, k uint32) InlTreeNode

func (*FuncInfo) ReadLocals

func (*FuncInfo) ReadLocals(b []byte) uint32

func (*FuncInfo) ReadStartLine

func (*FuncInfo) ReadStartLine(b []byte) int32

func (*FuncInfo) Write

func (a *FuncInfo) Write(w *bytes.Buffer)

type FuncInfoLengths

FuncInfoLengths is a cache containing a roadmap of offsets and lengths for things within a serialized FuncInfo. Each length field stores the number of items (e.g. files, inltree nodes, etc), and the corresponding "off" field stores the byte offset of the start of the items in question.

type FuncInfoLengths struct {
    NumFile     uint32
    FileOff     uint32
    NumInlTree  uint32
    InlTreeOff  uint32
    Initialized bool
}

type Hash64Type

Hash64

type Hash64Type [Hash64Size]byte

type HashType

Hash

type HashType [HashSize]byte

File header. TODO: probably no need to export this.

type Header struct {
    Magic       string
    Fingerprint FingerprintType
    Flags       uint32
    Offsets     [NBlk]uint32
}

func (*Header) Read

func (h *Header) Read(r *Reader) error

func (*Header) Size

func (h *Header) Size() int

func (*Header) Write

func (h *Header) Write(w *Writer)

type ImportedPkg

Autolib

type ImportedPkg struct {
    Pkg         string
    Fingerprint FingerprintType
}

func (*ImportedPkg) Write

func (p *ImportedPkg) Write(w *Writer)

type InlTreeNode

InlTreeNode is the serialized form of FileInfo.InlTree.

type InlTreeNode struct {
    Parent   int32
    File     CUFileIndex
    Line     int32
    Func     SymRef
    ParentPC int32
}

func (*InlTreeNode) Read

func (inl *InlTreeNode) Read(b []byte) []byte

Read an InlTreeNode from b, return the remaining bytes.

func (*InlTreeNode) Write

func (inl *InlTreeNode) Write(w *bytes.Buffer)

type Reader

type Reader struct {
    // contains filtered or unexported fields
}

func NewReaderFromBytes

func NewReaderFromBytes(b []byte, readonly bool) *Reader

func (*Reader) Autolib

func (r *Reader) Autolib() []ImportedPkg

func (*Reader) Aux

func (r *Reader) Aux(i uint32, j int) *Aux

Aux returns a pointer to the j-th aux symbol of the i-th symbol.

func (*Reader) AuxOff

func (r *Reader) AuxOff(i uint32, j int) uint32

AuxOff returns the offset of the j-th aux symbol of the i-th symbol.

func (*Reader) Auxs

func (r *Reader) Auxs(i uint32) []Aux

Auxs returns the aux symbols of the i-th symbol.

func (*Reader) BytesAt

func (r *Reader) BytesAt(off uint32, len int) []byte

func (*Reader) Data

func (r *Reader) Data(i uint32) []byte

Data returns the i-th symbol's data.

func (*Reader) DataOff

func (r *Reader) DataOff(i uint32) uint32

DataOff returns the offset of the i-th symbol's data.

func (*Reader) DataSize

func (r *Reader) DataSize(i uint32) int

DataSize returns the size of the i-th symbol's data.

func (*Reader) DataString

func (r *Reader) DataString(i uint32) string

DataString returns the i-th symbol's data as a string.

func (*Reader) File

func (r *Reader) File(i int) string

func (*Reader) Fingerprint

func (r *Reader) Fingerprint() FingerprintType

func (*Reader) Flags

func (r *Reader) Flags() uint32

Flags returns the flag bits read from the object file header.

func (*Reader) FromAssembly

func (r *Reader) FromAssembly() bool

func (*Reader) Hash

func (r *Reader) Hash(i uint32) *HashType

Hash returns a pointer to the i-th hashed symbol's hash. Note: here i is the index of hashed symbols, not all symbols (unlike other accessors).

func (*Reader) Hash64

func (r *Reader) Hash64(i uint32) uint64

Hash64 returns the i-th short hashed symbol's hash. Note: here i is the index of short hashed symbols, not all symbols (unlike other accessors).

func (*Reader) NAux

func (r *Reader) NAux(i uint32) int

NAux returns the number of aux symbols of the i-th symbol.

func (*Reader) NFile

func (r *Reader) NFile() int

func (*Reader) NHashed64def

func (r *Reader) NHashed64def() int

func (*Reader) NHasheddef

func (r *Reader) NHasheddef() int

func (*Reader) NNonpkgdef

func (r *Reader) NNonpkgdef() int

func (*Reader) NNonpkgref

func (r *Reader) NNonpkgref() int

func (*Reader) NPkg

func (r *Reader) NPkg() int

func (*Reader) NRefFlags

func (r *Reader) NRefFlags() int

NRefFlags returns the number of referenced symbol flags.

func (*Reader) NRefName

func (r *Reader) NRefName() int

NRefName returns the number of referenced symbol names.

func (*Reader) NReloc

func (r *Reader) NReloc(i uint32) int

NReloc returns the number of relocations of the i-th symbol.

func (*Reader) NSym

func (r *Reader) NSym() int

func (*Reader) Pkg

func (r *Reader) Pkg(i int) string

func (*Reader) Pkglist

func (r *Reader) Pkglist() []string

func (*Reader) ReadOnly

func (r *Reader) ReadOnly() bool

ReadOnly returns whether r.BytesAt returns read-only bytes.

func (*Reader) RefFlags

func (r *Reader) RefFlags(i int) *RefFlags

RefFlags returns a pointer to the i-th referenced symbol flags. Note: here i is not a local symbol index, just a counter.

func (*Reader) RefName

func (r *Reader) RefName(i int) *RefName

RefName returns a pointer to the i-th referenced symbol name. Note: here i is not a local symbol index, just a counter.

func (*Reader) Reloc

func (r *Reader) Reloc(i uint32, j int) *Reloc

Reloc returns a pointer to the j-th relocation of the i-th symbol.

func (*Reader) RelocOff

func (r *Reader) RelocOff(i uint32, j int) uint32

RelocOff returns the offset of the j-th relocation of the i-th symbol.

func (*Reader) Relocs

func (r *Reader) Relocs(i uint32) []Reloc

Relocs returns a pointer to the relocations of the i-th symbol.

func (*Reader) Shared

func (r *Reader) Shared() bool

func (*Reader) Std

func (r *Reader) Std() bool

func (*Reader) StringAt

func (r *Reader) StringAt(off uint32, len uint32) string

func (*Reader) StringRef

func (r *Reader) StringRef(off uint32) string

func (*Reader) Sym

func (r *Reader) Sym(i uint32) *Sym

Sym returns a pointer to the i-th symbol.

func (*Reader) SymOff

func (r *Reader) SymOff(i uint32) uint32

SymOff returns the offset of the i-th symbol.

func (*Reader) Unlinkable

func (r *Reader) Unlinkable() bool

type RefFlags

Referenced symbol flags.

Serialized format:

RefFlags struct {
   Sym   symRef
   Flag  uint8
   Flag2 uint8
}
type RefFlags [RefFlagsSize]byte

func (*RefFlags) Flag

func (r *RefFlags) Flag() uint8

func (*RefFlags) Flag2

func (r *RefFlags) Flag2() uint8

func (*RefFlags) SetFlag

func (r *RefFlags) SetFlag(x uint8)

func (*RefFlags) SetFlag2

func (r *RefFlags) SetFlag2(x uint8)

func (*RefFlags) SetSym

func (r *RefFlags) SetSym(x SymRef)

func (*RefFlags) Sym

func (r *RefFlags) Sym() SymRef

func (*RefFlags) Write

func (r *RefFlags) Write(w *Writer)

type RefName

Referenced symbol name.

Serialized format:

RefName struct {
   Sym  symRef
   Name string
}
type RefName [RefNameSize]byte

func (*RefName) Name

func (n *RefName) Name(r *Reader) string

func (*RefName) SetName

func (n *RefName) SetName(x string, w *Writer)

func (*RefName) SetSym

func (n *RefName) SetSym(x SymRef)

func (*RefName) Sym

func (n *RefName) Sym() SymRef

func (*RefName) Write

func (n *RefName) Write(w *Writer)

type Reloc

Relocation.

Serialized format:

Reloc struct {
   Off  int32
   Siz  uint8
   Type uint16
   Add  int64
   Sym  SymRef
}
type Reloc [RelocSize]byte

func (*Reloc) Add

func (r *Reloc) Add() int64

func (*Reloc) Off

func (r *Reloc) Off() int32

func (*Reloc) Set

func (r *Reloc) Set(off int32, size uint8, typ uint16, add int64, sym SymRef)

func (*Reloc) SetAdd

func (r *Reloc) SetAdd(x int64)

func (*Reloc) SetOff

func (r *Reloc) SetOff(x int32)

func (*Reloc) SetSiz

func (r *Reloc) SetSiz(x uint8)

func (*Reloc) SetSym

func (r *Reloc) SetSym(x SymRef)

func (*Reloc) SetType

func (r *Reloc) SetType(x uint16)

func (*Reloc) Siz

func (r *Reloc) Siz() uint8

func (*Reloc) Sym

func (r *Reloc) Sym() SymRef

func (*Reloc) Type

func (r *Reloc) Type() uint16

func (*Reloc) Write

func (r *Reloc) Write(w *Writer)

type Sym

Symbol definition.

Serialized format:

Sym struct {
   Name  string
   ABI   uint16
   Type  uint8
   Flag  uint8
   Flag2 uint8
   Siz   uint32
   Align uint32
}
type Sym [SymSize]byte

func (*Sym) ABI

func (s *Sym) ABI() uint16

func (*Sym) ABIWrapper

func (s *Sym) ABIWrapper() bool

func (*Sym) Align

func (s *Sym) Align() uint32

func (*Sym) Dupok

func (s *Sym) Dupok() bool

func (*Sym) Flag

func (s *Sym) Flag() uint8

func (*Sym) Flag2

func (s *Sym) Flag2() uint8

func (*Sym) IsDict

func (s *Sym) IsDict() bool

func (*Sym) IsGoType

func (s *Sym) IsGoType() bool

func (*Sym) IsItab

func (s *Sym) IsItab() bool

func (*Sym) IsLinkname

func (s *Sym) IsLinkname() bool

func (*Sym) IsPkgInit

func (s *Sym) IsPkgInit() bool

func (*Sym) Leaf

func (s *Sym) Leaf() bool

func (*Sym) Local

func (s *Sym) Local() bool

func (*Sym) Name

func (s *Sym) Name(r *Reader) string

func (*Sym) NameLen

func (s *Sym) NameLen(r *Reader) int

Returns the length of the name of the symbol.

func (*Sym) NoSplit

func (s *Sym) NoSplit() bool

func (*Sym) ReflectMethod

func (s *Sym) ReflectMethod() bool

func (*Sym) SetABI

func (s *Sym) SetABI(x uint16)

func (*Sym) SetAlign

func (s *Sym) SetAlign(x uint32)

func (*Sym) SetFlag

func (s *Sym) SetFlag(x uint8)

func (*Sym) SetFlag2

func (s *Sym) SetFlag2(x uint8)

func (*Sym) SetName

func (s *Sym) SetName(x string, w *Writer)

func (*Sym) SetSiz

func (s *Sym) SetSiz(x uint32)

func (*Sym) SetType

func (s *Sym) SetType(x uint8)

func (*Sym) Siz

func (s *Sym) Siz() uint32

func (*Sym) Type

func (s *Sym) Type() uint8
func (s *Sym) Typelink() bool

func (*Sym) UsedInIface

func (s *Sym) UsedInIface() bool

func (*Sym) Write

func (s *Sym) Write(w *Writer)

type SymRef

Symbol reference.

type SymRef struct {
    PkgIdx uint32
    SymIdx uint32
}

func (SymRef) IsZero

func (s SymRef) IsZero() bool

type Writer

type Writer struct {
    // contains filtered or unexported fields
}

func NewWriter

func NewWriter(wr *bio.Writer) *Writer

func (*Writer) AddString

func (w *Writer) AddString(s string)

func (*Writer) Bytes

func (w *Writer) Bytes(s []byte)

func (*Writer) Offset

func (w *Writer) Offset() uint32

func (*Writer) RawString

func (w *Writer) RawString(s string)

func (*Writer) StringRef

func (w *Writer) StringRef(s string)

func (*Writer) Uint16

func (w *Writer) Uint16(x uint16)

func (*Writer) Uint32

func (w *Writer) Uint32(x uint32)

func (*Writer) Uint64

func (w *Writer) Uint64(x uint64)

func (*Writer) Uint8

func (w *Writer) Uint8(x uint8)