objabi

package
v0.4.206 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	A_AUTO = 1 + iota
	A_PARAM
	A_DELETED_AUTO
)

Auto.name

View Source
const (
	PCDATA_UnsafePoint   = 0
	PCDATA_StackMapIndex = 1
	PCDATA_InlTreeIndex  = 2
	PCDATA_ArgLiveIndex  = 3

	FUNCDATA_ArgsPointerMaps    = 0
	FUNCDATA_LocalsPointerMaps  = 1
	FUNCDATA_StackObjects       = 2
	FUNCDATA_InlTree            = 3
	FUNCDATA_OpenCodedDeferInfo = 4
	FUNCDATA_ArgInfo            = 5
	FUNCDATA_ArgLiveInfo        = 6
	FUNCDATA_WrapInfo           = 7

	// ArgsSizeUnknown is set in Func.argsize to mark all functions
	// whose argument size is unknown (C vararg functions, and
	// assembly code without an explicit specification).
	// This value is generated by the compiler, assembler, or linker.
	ArgsSizeUnknown = -0x80000000
)
View Source
const (
	// PCDATA_UnsafePoint values.
	PCDATA_UnsafePointSafe   = -1 // Safe for async preemption
	PCDATA_UnsafePointUnsafe = -2 // Unsafe for async preemption

	// PCDATA_Restart1(2) apply on a sequence of instructions, within
	// which if an async preemption happens, we should back off the PC
	// to the start of the sequence when resuming.
	// We need two so we can distinguish the start/end of the sequence
	// in case that two sequences are next to each other.
	PCDATA_Restart1 = -3
	PCDATA_Restart2 = -4

	// Like PCDATA_Restart1, but back to function entry if async preempted.
	PCDATA_RestartAtEntry = -5
)

Special PCDATA values.

View Source
const (
	FuncFlag_TOPFRAME = 1 << iota
	FuncFlag_SPWRITE
	FuncFlag_ASM
)

Note: This list must match the list in runtime/symtab.go.

View Source
const (
	STACKSYSTEM = 0
	StackSystem = STACKSYSTEM
	StackBig    = 4096
	StackSmall  = 128
)
View Source
const (
	KindBool = 1 + iota
	KindInt
	KindInt8
	KindInt16
	KindInt32
	KindInt64
	KindUint
	KindUint8
	KindUint16
	KindUint32
	KindUint64
	KindUintptr
	KindFloat32
	KindFloat64
	KindComplex64
	KindComplex128
	KindArray
	KindChan
	KindFunc
	KindInterface
	KindMap
	KindPtr
	KindSlice
	KindString
	KindStruct
	KindUnsafePointer
	KindDirectIface = 1 << 5
	KindGCProg      = 1 << 6
	KindMask        = (1 << 5) - 1
)
View Source
const (
	ElfRelocOffset   = 256
	MachoRelocOffset = 2048    // reserve enough space for ELF relocations
	GlobalDictPrefix = ".dict" // prefix for names of global dictionaries
)

Variables

This section is empty.

Functions

func AbsFile

func AbsFile(dir, file, rewrites string) string

AbsFile returns the absolute filename for file in the given directory, as rewritten by the rewrites argument. For unrewritten paths, AbsFile rewrites a leading $GOROOT prefix to the literal "$GOROOT". If the resulting path is the empty string, the result is "??".

The rewrites argument is a ;-separated list of rewrites. Each rewrite is of the form "prefix" or "prefix=>replace", where prefix must match a leading sequence of path elements and is either removed entirely or replaced by the replacement.

func ApplyRewrites

func ApplyRewrites(file, rewrites string) (string, bool)

ApplyRewrites returns the filename for file in the given directory, as rewritten by the rewrites argument.

The rewrites argument is a ;-separated list of rewrites. Each rewrite is of the form "prefix" or "prefix=>replace", where prefix must match a leading sequence of path elements and is either removed entirely or replaced by the replacement.

func HeaderString

func HeaderString() string

HeaderString returns the toolchain configuration string written in Go object headers. This string ensures we don't attempt to import or link object files that are incompatible with each other. This string always starts with "go object ".

func IsRuntimePackagePath

func IsRuntimePackagePath(pkgpath string) bool

IsRuntimePackagePath examines 'pkgpath' and returns TRUE if it belongs to the collection of "runtime-related" packages, including "runtime" itself, "reflect", "syscall", and the "runtime/internal/*" packages. The compiler and/or assembler in some cases need to be aware of when they are building such a package, for example to enable features such as ABI selectors in assembly sources.

Keep in sync with cmd/dist/build.go:IsRuntimePackagePath.

func PathToPrefix

func PathToPrefix(s string) string

PathToPrefix converts raw string to the prefix that will be used in the symbol table. All control characters, space, '%' and '"', as well as non-7-bit clean bytes turn into %xx. The period needs escaping only in the last segment of the path, and it makes for happier users if we escape that as little as possible.

func StackLimit

func StackLimit(race bool) int

func WorkingDir

func WorkingDir() string

WorkingDir returns the current working directory (or "/???" if the directory cannot be identified), with "/" as separator.

Types

type FuncFlag

type FuncFlag uint8

A FuncFlag records bits about a function, passed to the runtime.

type FuncID

type FuncID uint8

A FuncID identifies particular functions that need to be treated specially by the runtime. Note that in some situations involving plugins, there may be multiple copies of a particular special runtime function.

const (
	FuncID_normal FuncID = iota // not a special function
	FuncID_abort
	FuncID_asmcgocall
	FuncID_asyncPreempt
	FuncID_cgocallback
	FuncID_debugCallV2
	FuncID_gcBgMarkWorker
	FuncID_goexit
	FuncID_gogo
	FuncID_gopanic
	FuncID_handleAsyncEvent
	FuncID_mcall
	FuncID_morestack
	FuncID_mstart
	FuncID_panicwrap
	FuncID_rt0_go
	FuncID_runfinq
	FuncID_runtime_main
	FuncID_sigpanic
	FuncID_systemstack
	FuncID_systemstack_switch
	FuncID_wrapper // any autogenerated code (hash/eq algorithms, method wrappers, etc.)
)

Note: this list must match the list in runtime/symtab.go.

func GetFuncID

func GetFuncID(name string, isWrapper bool) FuncID

Get the function ID for the named function in the named file. The function should be package-qualified.

type HeadType

type HeadType uint8

HeadType is the executable header type.

const (
	Hunknown HeadType = iota
	Hdarwin
	Hdragonfly
	Hfreebsd
	Hjs
	Hlinux
	Hnetbsd
	Hopenbsd
	Hplan9
	Hsolaris
	Hwindows
	Haix
)

func (*HeadType) Set

func (h *HeadType) Set(s string) error

func (HeadType) String

func (h HeadType) String() string

type RelocType

type RelocType int16
const (
	R_ADDR RelocType = 1 + iota
	// R_ADDRPOWER relocates a pair of "D-form" instructions (instructions with 16-bit
	// immediates in the low half of the instruction word), usually addis followed by
	// another add or a load, inserting the "high adjusted" 16 bits of the address of
	// the referenced symbol into the immediate field of the first instruction and the
	// low 16 bits into that of the second instruction.
	R_ADDRPOWER
	// R_ADDRARM64 relocates an adrp, add pair to compute the address of the
	// referenced symbol.
	R_ADDRARM64
	// R_ADDRMIPS (only used on mips/mips64) resolves to the low 16 bits of an external
	// address, by encoding it into the instruction.
	R_ADDRMIPS
	// R_ADDROFF resolves to a 32-bit offset from the beginning of the section
	// holding the data being relocated to the referenced symbol.
	R_ADDROFF
	R_SIZE
	R_CALL
	R_CALLARM
	R_CALLARM64
	R_CALLIND
	R_CALLPOWER
	// R_CALLMIPS (only used on mips64) resolves to non-PC-relative target address
	// of a CALL (JAL) instruction, by encoding the address into the instruction.
	R_CALLMIPS
	R_CONST
	R_PCREL
	// R_TLS_LE, used on 386, amd64, and ARM, resolves to the offset of the
	// thread-local symbol from the thread local base and is used to implement the
	// "local exec" model for tls access (r.Sym is not set on intel platforms but is
	// set to a TLS symbol -- runtime.tlsg -- in the linker when externally linking).
	R_TLS_LE
	// R_TLS_IE, used 386, amd64, and ARM resolves to the PC-relative offset to a GOT
	// slot containing the offset from the thread-local symbol from the thread local
	// base and is used to implemented the "initial exec" model for tls access (r.Sym
	// is not set on intel platforms but is set to a TLS symbol -- runtime.tlsg -- in
	// the linker when externally linking).
	R_TLS_IE
	R_GOTOFF
	R_PLT0
	R_PLT1
	R_PLT2
	R_USEFIELD
	// R_USETYPE resolves to an *rtype, but no relocation is created. The
	// linker uses this as a signal that the pointed-to type information
	// should be linked into the final binary, even if there are no other
	// direct references. (This is used for types reachable by reflection.)
	R_USETYPE
	// R_USEIFACE marks a type is converted to an interface in the function this
	// relocation is applied to. The target is a type descriptor.
	// This is a marker relocation (0-sized), for the linker's reachabililty
	// analysis.
	R_USEIFACE
	// R_USEIFACEMETHOD marks an interface method that is used in the function
	// this relocation is applied to. The target is an interface type descriptor.
	// The addend is the offset of the method in the type descriptor.
	// This is a marker relocation (0-sized), for the linker's reachabililty
	// analysis.
	R_USEIFACEMETHOD
	// Similar to R_USEIFACEMETHOD, except instead of indicating a type +
	// method offset with Sym+Add, Sym points to a symbol containing the name
	// of the method being called. See the description in
	// cmd/compile/internal/reflectdata/reflect.go:MarkUsedIfaceMethod for details.
	R_USEGENERICIFACEMETHOD
	// R_METHODOFF resolves to a 32-bit offset from the beginning of the section
	// holding the data being relocated to the referenced symbol.
	// It is a variant of R_ADDROFF used when linking from the uncommonType of a
	// *rtype, and may be set to zero by the linker if it determines the method
	// text is unreachable by the linked program.
	R_METHODOFF
	// R_KEEP tells the linker to keep the referred-to symbol in the final binary
	// if the symbol containing the R_KEEP relocation is in the final binary.
	R_KEEP
	R_POWER_TOC
	R_GOTPCREL
	// R_JMPMIPS (only used on mips64) resolves to non-PC-relative target address
	// of a JMP instruction, by encoding the address into the instruction.
	// The stack nosplit check ignores this since it is not a function call.
	R_JMPMIPS

	// R_DWARFSECREF resolves to the offset of the symbol from its section.
	// Target of relocation must be size 4 (in current implementation).
	R_DWARFSECREF

	// R_DWARFFILEREF resolves to an index into the DWARF .debug_line
	// file table for the specified file symbol. Must be applied to an
	// attribute of form DW_FORM_data4.
	R_DWARFFILEREF

	// Set a MOV[NZ] immediate field to bits [15:0] of the offset from the thread
	// local base to the thread local variable defined by the referenced (thread
	// local) symbol. Error if the offset does not fit into 16 bits.
	R_ARM64_TLS_LE

	// Relocates an ADRP; LD64 instruction sequence to load the offset between
	// the thread local base and the thread local variable defined by the
	// referenced (thread local) symbol from the GOT.
	R_ARM64_TLS_IE

	// R_ARM64_GOTPCREL relocates an adrp, ld64 pair to compute the address of the GOT
	// slot of the referenced symbol.
	R_ARM64_GOTPCREL

	// R_ARM64_GOT resolves a GOT-relative instruction sequence, usually an adrp
	// followed by another ld instruction.
	R_ARM64_GOT

	// R_ARM64_PCREL resolves a PC-relative addresses instruction sequence, usually an
	// adrp followed by another add instruction.
	R_ARM64_PCREL

	// R_ARM64_PCREL_LDST8 resolves a PC-relative addresses instruction sequence, usually an
	// adrp followed by a LD8 or ST8 instruction.
	R_ARM64_PCREL_LDST8

	// R_ARM64_PCREL_LDST16 resolves a PC-relative addresses instruction sequence, usually an
	// adrp followed by a LD16 or ST16 instruction.
	R_ARM64_PCREL_LDST16

	// R_ARM64_PCREL_LDST32 resolves a PC-relative addresses instruction sequence, usually an
	// adrp followed by a LD32 or ST32 instruction.
	R_ARM64_PCREL_LDST32

	// R_ARM64_PCREL_LDST64 resolves a PC-relative addresses instruction sequence, usually an
	// adrp followed by a LD64 or ST64 instruction.
	R_ARM64_PCREL_LDST64

	// R_ARM64_LDST8 sets a LD/ST immediate value to bits [11:0] of a local address.
	R_ARM64_LDST8

	// R_ARM64_LDST16 sets a LD/ST immediate value to bits [11:1] of a local address.
	R_ARM64_LDST16

	// R_ARM64_LDST32 sets a LD/ST immediate value to bits [11:2] of a local address.
	R_ARM64_LDST32

	// R_ARM64_LDST64 sets a LD/ST immediate value to bits [11:3] of a local address.
	R_ARM64_LDST64

	// R_ARM64_LDST128 sets a LD/ST immediate value to bits [11:4] of a local address.
	R_ARM64_LDST128

	// R_POWER_TLS_LE is used to implement the "local exec" model for tls
	// access. It resolves to the offset of the thread-local symbol from the
	// thread pointer (R13) and is split against a pair of instructions to
	// support a 32 bit displacement.
	R_POWER_TLS_LE

	// R_POWER_TLS_IE is used to implement the "initial exec" model for tls access. It
	// relocates a D-form, DS-form instruction sequence like R_ADDRPOWER_DS. It
	// inserts to the offset of GOT slot for the thread-local symbol from the TOC (the
	// GOT slot is filled by the dynamic linker with the offset of the thread-local
	// symbol from the thread pointer (R13)).
	R_POWER_TLS_IE

	// R_POWER_TLS marks an X-form instruction such as "ADD R3,R13,R4" as completing
	// a sequence of GOT-relative relocations to compute a TLS address. This can be
	// used by the system linker to to rewrite the GOT-relative TLS relocation into a
	// simpler thread-pointer relative relocation. See table 3.26 and 3.28 in the
	// ppc64 elfv2 1.4 ABI on this transformation.  Likewise, the second argument
	// (usually called RB in X-form instructions) is assumed to be R13.
	R_POWER_TLS

	// R_POWER_TLS_IE_PCREL34 is similar to R_POWER_TLS_IE, but marks a single MOVD
	// which has been assembled as a single prefixed load doubleword without using the
	// TOC.
	R_POWER_TLS_IE_PCREL34

	// R_POWER_TLS_LE_TPREL34 is similar to R_POWER_TLS_LE, but computes an offset from
	// the thread pointer in one prefixed instruction.
	R_POWER_TLS_LE_TPREL34

	// R_ADDRPOWER_DS is similar to R_ADDRPOWER above, but assumes the second
	// instruction is a "DS-form" instruction, which has an immediate field occupying
	// bits [15:2] of the instruction word. Bits [15:2] of the address of the
	// relocated symbol are inserted into this field; it is an error if the last two
	// bits of the address are not 0.
	R_ADDRPOWER_DS

	// R_ADDRPOWER_GOT relocates a D-form + DS-form instruction sequence by inserting
	// a relative displacement of referenced symbol's GOT entry to the TOC pointer.
	R_ADDRPOWER_GOT

	// R_ADDRPOWER_GOT_PCREL34 is identical to R_ADDRPOWER_GOT, but uses a PC relative
	// sequence to generate a GOT symbol addresss.
	R_ADDRPOWER_GOT_PCREL34

	// R_ADDRPOWER_PCREL relocates two D-form instructions like R_ADDRPOWER, but
	// inserts the displacement from the place being relocated to the address of the
	// relocated symbol instead of just its address.
	R_ADDRPOWER_PCREL

	// R_ADDRPOWER_TOCREL relocates two D-form instructions like R_ADDRPOWER, but
	// inserts the offset from the TOC to the address of the relocated symbol
	// rather than the symbol's address.
	R_ADDRPOWER_TOCREL

	// R_ADDRPOWER_TOCREL_DS relocates a D-form, DS-form instruction sequence like
	// R_ADDRPOWER_DS but inserts the offset from the TOC to the address of the
	// relocated symbol rather than the symbol's address.
	R_ADDRPOWER_TOCREL_DS

	// R_ADDRPOWER_D34 relocates a single prefixed D-form load/store operation.  All
	// prefixed forms are D form. The high 18 bits are stored in the prefix,
	// and the low 16 are stored in the suffix. The address is absolute.
	R_ADDRPOWER_D34

	// R_ADDRPOWER_PCREL34 relates a single prefixed D-form load/store/add operation.
	// All prefixed forms are D form. The resulting address is relative to the
	// PC. It is a signed 34 bit offset.
	R_ADDRPOWER_PCREL34

	// R_RISCV_CALL relocates a J-type instruction with a 21 bit PC-relative
	// address.
	R_RISCV_CALL

	// R_RISCV_CALL_TRAMP is the same as R_RISCV_CALL but denotes the use of a
	// trampoline, which we may be able to avoid during relocation. These are
	// only used by the linker and are not emitted by the compiler or assembler.
	R_RISCV_CALL_TRAMP

	// R_RISCV_PCREL_ITYPE resolves a 32-bit PC-relative address using an
	// AUIPC + I-type instruction pair.
	R_RISCV_PCREL_ITYPE

	// R_RISCV_PCREL_STYPE resolves a 32-bit PC-relative address using an
	// AUIPC + S-type instruction pair.
	R_RISCV_PCREL_STYPE

	// R_RISCV_TLS_IE_ITYPE resolves a 32-bit TLS initial-exec TOC offset
	// address using an AUIPC + I-type instruction pair.
	R_RISCV_TLS_IE_ITYPE

	// R_RISCV_TLS_IE_STYPE resolves a 32-bit TLS initial-exec TOC offset
	// address using an AUIPC + S-type instruction pair.
	R_RISCV_TLS_IE_STYPE

	// R_PCRELDBL relocates s390x 2-byte aligned PC-relative addresses.
	// TODO(mundaym): remove once variants can be serialized - see issue 14218.
	R_PCRELDBL

	// R_ADDRLOONG64 resolves to the low 12 bits of an external address, by encoding
	// it into the instruction.
	R_ADDRLOONG64

	// R_ADDRLOONG64U resolves to the sign-adjusted "upper" 20 bits (bit 5-24) of an
	// external address, by encoding it into the instruction.
	R_ADDRLOONG64U

	// R_ADDRLOONG64TLS resolves to the low 12 bits of a TLS address (offset from
	// thread pointer), by encoding it into the instruction.
	R_ADDRLOONG64TLS

	// R_ADDRLOONG64TLSU resolves to the high 20 bits of a TLS address (offset from
	// thread pointer), by encoding it into the instruction.
	R_ADDRLOONG64TLSU

	// R_CALLLOONG64 resolves to non-PC-relative target address of a CALL (BL/JIRL)
	// instruction, by encoding the address into the instruction.
	R_CALLLOONG64

	// R_JMPLOONG64 resolves to non-PC-relative target address of a JMP instruction,
	// by encoding the address into the instruction.
	R_JMPLOONG64

	// R_ADDRMIPSU (only used on mips/mips64) resolves to the sign-adjusted "upper" 16
	// bits (bit 16-31) of an external address, by encoding it into the instruction.
	R_ADDRMIPSU
	// R_ADDRMIPSTLS (only used on mips64) resolves to the low 16 bits of a TLS
	// address (offset from thread pointer), by encoding it into the instruction.
	R_ADDRMIPSTLS

	// R_ADDRCUOFF resolves to a pointer-sized offset from the start of the
	// symbol's DWARF compile unit.
	R_ADDRCUOFF

	// R_WASMIMPORT resolves to the index of the WebAssembly function import.
	R_WASMIMPORT

	// R_XCOFFREF (only used on aix/ppc64) prevents garbage collection by ld
	// of a symbol. This isn't a real relocation, it can be placed in anywhere
	// in a symbol and target any symbols.
	R_XCOFFREF

	// R_WEAK marks the relocation as a weak reference.
	// A weak relocation does not make the symbol it refers to reachable,
	// and is only honored by the linker if the symbol is in some other way
	// reachable.
	R_WEAK = -1 << 15

	R_WEAKADDR    = R_WEAK | R_ADDR
	R_WEAKADDROFF = R_WEAK | R_ADDROFF
)

func (RelocType) IsDirectCall

func (r RelocType) IsDirectCall() bool

IsDirectCall reports whether r is a relocation for a direct call. A direct call is a CALL instruction that takes the target address as an immediate. The address is embedded into the instruction, possibly with limited width. An indirect call is a CALL instruction that takes the target address in register or memory.

func (RelocType) IsDirectCallOrJump

func (r RelocType) IsDirectCallOrJump() bool

IsDirectCallOrJump reports whether r is a relocation for a direct call or a direct jump.

func (RelocType) IsDirectJump

func (r RelocType) IsDirectJump() bool

IsDirectJump reports whether r is a relocation for a direct jump. A direct jump is a JMP instruction that takes the target address as an immediate. The address is embedded into the instruction, possibly with limited width. An indirect jump is a JMP instruction that takes the target address in register or memory.

func (RelocType) String

func (i RelocType) String() string

type SymKind

type SymKind uint8

A SymKind describes the kind of memory represented by a symbol.

const (
	// An otherwise invalid zero value for the type
	Sxxx SymKind = iota
	// Executable instructions
	STEXT
	// Read only static data
	SRODATA
	// Static data that does not contain any pointers
	SNOPTRDATA
	// Static data
	SDATA
	// Statically data that is initially all 0s
	SBSS
	// Statically data that is initially all 0s and does not contain pointers
	SNOPTRBSS
	// Thread-local data that is initially all 0s
	STLSBSS
	// Debugging data
	SDWARFCUINFO
	SDWARFCONST
	SDWARFFCN
	SDWARFABSFCN
	SDWARFTYPE
	SDWARFVAR
	SDWARFRANGE
	SDWARFLOC
	SDWARFLINES
	// Coverage instrumentation counter for libfuzzer.
	SLIBFUZZER_8BIT_COUNTER
	// Coverage instrumentation counter, aux variable for cmd/cover
	SCOVERAGE_COUNTER
	SCOVERAGE_AUXVAR
)

Defined SymKind values. These are used to index into cmd/link/internal/sym/AbiSymKindToSymKind

TODO(rsc): Give idiomatic Go names.

func (SymKind) String

func (i SymKind) String() string

Jump to

Keyboard shortcuts

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