Help us shape the future of Go! Take the 2026 Go Developer Survey

objcreader

package
v1.1.296 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrObjCSelectorBaseUnavailable = errors.New(
	"ObjC relative method selectors require the shared cache's selector base, " +
		"which is unavailable in a standalone dylib")

ErrObjCSelectorBaseUnavailable indicates a relative ObjC method list whose selectors are offsets into the shared cache's global selector-string table, which is not present when parsing a dylib in isolation (e.g. one extracted from a dyld_shared_cache). Such method names can only be resolved against the full cache.

View Source
var ErrObjcFragileRuntimeUnsupported = errors.New(
	"objective-c fragile runtime metadata is unsupported")
View Source
var ErrObjcSectionNEmpty = errors.New("required ObjC section is empty")
View Source
var ErrObjcSectionNotFound = errors.New("missing required ObjC section")

Functions

func NormalizeSwiftIvarTypeEncoding

func NormalizeSwiftIvarTypeEncoding(enc string) string

Types

type MethodHandler

type MethodHandler func(uint64, objc.Method, *bool)

MethodHandler receives the method entry's VM address in either list format.

type Reader

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

Reader parses Objective-C metadata and owns the per-image ObjC cache.

func New

func New(source Source) *Reader

New returns a Reader that parses Objective-C metadata from source.

func (*Reader) ForEachMethod

func (f *Reader) ForEachMethod(addr uint64, handler MethodHandler) error

ForEachMethod decodes the method list at addr and calls handler for each entry until handler sets stop.

func (*Reader) GetCFStrings

func (f *Reader) GetCFStrings() ([]objc.CFString, error)

GetCFStrings returns the Objective-C CFStrings

func (*Reader) GetObjC

func (f *Reader) GetObjC(addr uint64) (any, bool)

func (*Reader) GetObjCCategories

func (f *Reader) GetObjCCategories() ([]objc.Category, error)

GetObjCCategories returns the Objective-C categories in __objc_catlist.

func (*Reader) GetObjCClass

func (f *Reader) GetObjCClass(vmaddr uint64) (*objc.Class, error)

GetObjCClass parses an Objective-C class at a given virtual memory address.

func (*Reader) GetObjCClass2

func (f *Reader) GetObjCClass2(vmaddr uint64) (*objc.Class, error)

GetObjCClass2 preserves the raw method-cache bucket field.

func (*Reader) GetObjCClassInfo

func (f *Reader) GetObjCClassInfo(vmaddr uint64) (*objc.ClassRO64, error)

GetObjCClassInfo returns the ClassRO64 (class_ro_t) for a given virtual memory address

func (*Reader) GetObjCClassNames

func (f *Reader) GetObjCClassNames() (map[uint64]string, error)

GetObjCClassNames returns a map of section data virtual memory address to their class names

func (*Reader) GetObjCClassReferences

func (f *Reader) GetObjCClassReferences() (map[uint64]*objc.Class, error)

GetObjCClassReferences returns a map of classes to their section data virtual memory address

func (*Reader) GetObjCClasses

func (f *Reader) GetObjCClasses() ([]objc.Class, error)

GetObjCClasses returns an array of Objective-C classes

func (*Reader) GetObjCImageInfo

func (f *Reader) GetObjCImageInfo() (*objc.ImageInfo, error)

GetObjCImageInfo returns the parsed __objc_imageinfo data

func (*Reader) GetObjCIntegerObjects

func (f *Reader) GetObjCIntegerObjects() (map[uint64]*objc.IntObj, error)

GetObjCIntObj parses the __objc_intobj section and returns a map of

func (*Reader) GetObjCIvars

func (f *Reader) GetObjCIvars(vmaddr uint64) ([]objc.Ivar, error)

GetObjCIvars returns the Objective-C instance variables

func (*Reader) GetObjCMethodLists

func (f *Reader) GetObjCMethodLists() ([]objc.Method, error)

GetObjCMethodLists parses the method lists in the __objc_methlist section

func (*Reader) GetObjCMethodNames

func (f *Reader) GetObjCMethodNames() (map[uint64]string, error)

GetObjCMethodNames returns a map of section data virtual memory addresses to their method names

func (*Reader) GetObjCMethods

func (f *Reader) GetObjCMethods(vmaddr uint64) ([]objc.Method, error)

func (*Reader) GetObjCNonLazyCategories

func (f *Reader) GetObjCNonLazyCategories() ([]objc.Category, error)

GetObjCNonLazyCategories returns an array of Objective-C classes that implement +load

func (*Reader) GetObjCNonLazyClasses

func (f *Reader) GetObjCNonLazyClasses() ([]objc.Class, error)

GetObjCNonLazyClasses returns an array of Objective-C classes that implement +load

func (*Reader) GetObjCProperties

func (f *Reader) GetObjCProperties(vmaddr uint64) ([]objc.Property, error)

GetObjCProperties returns the Objective-C properties

func (*Reader) GetObjCProtoReferences

func (f *Reader) GetObjCProtoReferences() (map[uint64]*objc.Protocol, error)

GetObjCProtoReferences maps each protocol-reference slot to its protocol. It returns an error if a referenced protocol is unavailable or truncated.

func (*Reader) GetObjCProtocols

func (f *Reader) GetObjCProtocols() ([]objc.Protocol, error)

GetObjCProtocols returns locally readable Objective-C protocol definitions. Unavailable external references are skipped; truncated records return an error.

func (*Reader) GetObjCSelectorReferences

func (f *Reader) GetObjCSelectorReferences() (map[uint64]*objc.Selector, error)

GetObjCSelectorReferences returns a map of selector names to their section data virtual memory address

func (*Reader) GetObjCStubs

func (f *Reader) GetObjCStubs(
	parse func(uint64, []byte) (map[uint64]*objc.Stub, error),
) (map[uint64]*objc.Stub, error)

GetObjCStubs returns the Objective-C stubs

func (*Reader) GetObjCSuperReferences

func (f *Reader) GetObjCSuperReferences() (map[uint64]*objc.Class, error)

GetObjCSuperReferences returns a map of super classes to their section data virtual memory address

func (*Reader) GetObjCToc

func (f *Reader) GetObjCToc() objc.Toc

GetObjCToc returns a table of contents of the ObjC objects in the MachO

func (*Reader) HasObjC

func (f *Reader) HasObjC() bool

HasObjC returns true if MachO contains Objective-C metadata.

func (*Reader) HasObjCMessageReferences

func (f *Reader) HasObjCMessageReferences() bool

HasObjCMessageReferences returns true if MachO contains a __objc_msgrefs section

func (*Reader) HasPlusLoadMethod

func (f *Reader) HasPlusLoadMethod() bool

HasPlusLoadMethod returns true if MachO contains a __objc_nlclslist or __objc_nlcatlist section

func (*Reader) ObjCSelectorBaseUnavailable

func (f *Reader) ObjCSelectorBaseUnavailable() bool

ObjCSelectorBaseUnavailable reports whether ObjC parsing encountered a relative method list whose selectors are offsets into the shared cache's global selector-string table. That table is absent when a dylib is parsed in isolation (e.g. extracted from a dyld_shared_cache), so such method names cannot be resolved without the full cache. See ErrObjCSelectorBaseUnavailable.

func (*Reader) PutObjC

func (f *Reader) PutObjC(addr uint64, obj any)

type Source

type Source interface {
	ByteOrder() binary.ByteOrder
	DataReader() types.MachoReader
	Sections() []*types.Section
	SegmentNames() []string
	Section(string, string) *types.Section
	PointerSize() uint64
	RelativeSelectorBase() uint64
	ConvertPointer(uint64) uint64
	GetOffset(uint64) (uint64, error)
	CheckFileData(uint64, uint64) error
	HasFileData(uint64, uint64) bool
	HasZeroFillData(uint64, uint64) bool
	AddressResolvable(uint64) bool
	GetCString(uint64) (string, error)
	GetUTF16String(uint64, uint64) (string, error)
	CStringUnavailable(error) bool
	GetPointerAtAddress(uint64) (uint64, error)
	GetSlidPointerAtAddress(uint64) (uint64, error)
	GetBindName(uint64) (string, error)
	BindInfoUnavailable(error) bool
	HasFixups() bool
	SwiftSymbolicName(uint64) (string, error)
	SwiftASCIITypeGuess(uint64) (string, bool)
	SwiftFieldTypesForClass(string) (map[string]string, error)
	SymbolicMangledNameStringRef(uint64) (string, error)
}

Source supplies the active Mach-O image and its address/Swift decoding services. Implementations must expose the live reader and layout rather than a stale snapshot.

Jump to

Keyboard shortcuts

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