pclntab

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pclntab contains the Go-style findfunc bucket/index algorithm used by LLGo runtime metadata. It is intentionally free of LLVM dependencies so build-time emitters and tests share one implementation of the pclntab logic.

Index

Constants

View Source
const (
	// These constants intentionally match Go's pclntab findfunc layout:
	// cmd/link builds one 4096-byte text bucket, split into 16 256-byte
	// subbuckets, and runtime.findfunc starts scanning from the recorded
	// bucket base plus subbucket delta.
	MinFuncSize       = uint32(16)
	FuncTabBucketSize = uint32(256) * MinFuncSize
	FindFuncSubbucket = 16
)

Variables

This section is empty.

Functions

func FuncIndexForPC

func FuncIndexForPC(ftab []FuncTabEntry, pcOff uint32) int

FuncIndexForPC is the slow reference lookup over the sorted functab. It is kept for tests and for building the compact bucket table.

func LookupFuncIndex

func LookupFuncIndex(ftab []FuncTabEntry, buckets []FindFuncBucket, pcOff uint32) int

LookupFuncIndex mirrors runtime.findfunc's hot lookup: use the bucket and subbucket to jump near the target function, then linearly scan the remaining entries in that small range.

Types

type FindFuncBucket

type FindFuncBucket struct {
	Idx        uint32
	Subbuckets [FindFuncSubbucket]uint8
}

FindFuncBucket mirrors runtime.findfuncbucket: one uint32 base function index plus 16 one-byte deltas into the sorted functab.

func BuildFindFuncBuckets

func BuildFindFuncBuckets(ftab []FuncTabEntry, textSize uint32) ([]FindFuncBucket, error)

BuildFindFuncBuckets ports Go's cmd/link findfunctab construction for a sorted functab. It deliberately stays independent of LLVM so build/link code can use it without duplicating the algorithm.

type FuncTabEntry

type FuncTabEntry struct {
	EntryOff uint32
	FuncOff  uint32
}

FuncTabEntry mirrors the two pieces of data Go's linker stores in functab: a PC offset sorted by final text address, and an opaque function metadata offset. LLGo's current caller uses FuncOff as a payload index.

Jump to

Keyboard shortcuts

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