macho

package module
v0.0.0-...-b52216c Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: MIT Imports: 25 Imported by: 0

README ¶

go-macho [WIP] 🚧

Go Go Reference License

Package macho implements access to and creation of Mach-O object files.


Why 🤔

This package goes beyond the Go's debug/macho to:

  • Cover ALL load commands and architectures
  • Provide nice summary string output
  • Allow for creating custom macho

Install

$ go get github.com/appsworld/go-macho-fix

Getting Started

package main

import "github.com/appsworld/go-macho-fix"

func main() {
    f, err := os.Open("/path/to/macho")
    if err != nil {
        panic(err)
    }

    m, err := macho.NewFile(f)
    if err != nil {
        panic(err)
    }

    fmt.Println(m.FileTOC.String())
}

License

MIT Copyright (c) 2021 blacktop

Documentation ¶

Overview ¶

Package macho implements access to and creation of Mach-O object files.

Index ¶

Constants ¶

This section is empty.

Variables ¶

View Source
var ErrMachOSectionNotFound = errors.New("MachO missing required section")
View Source
var ErrNotFat = &FormatError{0, "not a fat Mach-O file", nil}

ErrNotFat is returned from NewFatFile or OpenFat when the file is not a universal binary but may be a thin binary, based on its magic number.

View Source
var ErrObjcSectionNotFound = errors.New("missing required ObjC section")

Functions ¶

This section is empty.

Types ¶

type BuildVersion ¶

type BuildVersion struct {
	LoadBytes
	types.BuildVersionCmd
	Platform    string /* platform */
	Minos       string /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
	Sdk         string /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
	NumTools    uint32 /* number of tool entries following this */
	Tool        string
	ToolVersion string
}

A BuildVersion represents a Mach-O build for platform min OS version.

func (*BuildVersion) String ¶

func (b *BuildVersion) String() string

type CodeSignature ¶

type CodeSignature struct {
	LoadBytes
	types.CodeSignatureCmd
	Offset uint32
	Size   uint32
	ctypes.CodeSignature
}

A CodeSignature represents a Mach-O LC_CODE_SIGNATURE command.

func (*CodeSignature) String ¶

func (c *CodeSignature) String() string

func (*CodeSignature) Write ¶

func (c *CodeSignature) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type DataInCode ¶

type DataInCode struct {
	LoadBytes
	types.DataInCodeCmd
	Offset  uint32
	Size    uint32
	Entries []types.DataInCodeEntry
}

A DataInCode represents a Mach-O LC_DATA_IN_CODE command.

func (*DataInCode) String ¶

func (d *DataInCode) String() string

func (*DataInCode) Write ¶

func (l *DataInCode) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type DyldChainedFixups ¶

type DyldChainedFixups struct {
	LoadBytes
	types.DyldChainedFixupsCmd
	Offset uint32
	Size   uint32
}

A DyldChainedFixups used with linkedit_data_command

func (*DyldChainedFixups) String ¶

func (cf *DyldChainedFixups) String() string

func (*DyldChainedFixups) Write ¶

func (s *DyldChainedFixups) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type DyldEnvironment ¶

type DyldEnvironment struct {
	LoadBytes
	types.DyldEnvironmentCmd
	Name string
}

A DyldEnvironment is a string for dyld to treat like environment variable

func (*DyldEnvironment) String ¶

func (d *DyldEnvironment) String() string

type DyldExportsTrie ¶

type DyldExportsTrie struct {
	LoadBytes
	types.DyldExportsTrieCmd
	Offset uint32
	Size   uint32
}

A DyldExportsTrie used with linkedit_data_command, payload is trie

func (*DyldExportsTrie) String ¶

func (t *DyldExportsTrie) String() string

func (*DyldExportsTrie) Write ¶

func (t *DyldExportsTrie) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type DyldInfo ¶

type DyldInfo struct {
	LoadBytes
	types.DyldInfoCmd
	RebaseOff    uint32 // file offset to rebase info
	RebaseSize   uint32 //  size of rebase info
	BindOff      uint32 // file offset to binding info
	BindSize     uint32 // size of binding info
	WeakBindOff  uint32 // file offset to weak binding info
	WeakBindSize uint32 //  size of weak binding info
	LazyBindOff  uint32 // file offset to lazy binding info
	LazyBindSize uint32 //  size of lazy binding info
	ExportOff    uint32 // file offset to export info
	ExportSize   uint32 //  size of export info
}

A DyldInfo represents a Mach-O LC_DYLD_INFO command.

func (*DyldInfo) Copy ¶

func (d *DyldInfo) Copy() *DyldInfo

func (*DyldInfo) LoadSize ¶

func (d *DyldInfo) LoadSize(t *FileTOC) uint32

func (*DyldInfo) Put ¶

func (d *DyldInfo) Put(b []byte, o binary.ByteOrder) int

func (*DyldInfo) String ¶

func (d *DyldInfo) String() string

func (*DyldInfo) Write ¶

func (l *DyldInfo) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type DyldInfoOnly ¶

type DyldInfoOnly struct {
	LoadBytes
	types.DyldInfoOnlyCmd
	RebaseOff    uint32 // file offset to rebase info
	RebaseSize   uint32 //  size of rebase info
	BindOff      uint32 // file offset to binding info
	BindSize     uint32 // size of binding info
	WeakBindOff  uint32 // file offset to weak binding info
	WeakBindSize uint32 //  size of weak binding info
	LazyBindOff  uint32 // file offset to lazy binding info
	LazyBindSize uint32 //  size of lazy binding info
	ExportOff    uint32 // file offset to export info
	ExportSize   uint32 //  size of export info
}

DyldInfoOnly is compressed dyld information only

func (*DyldInfoOnly) Copy ¶

func (d *DyldInfoOnly) Copy() *DyldInfoOnly

func (*DyldInfoOnly) LoadSize ¶

func (d *DyldInfoOnly) LoadSize(t *FileTOC) uint32

func (*DyldInfoOnly) Put ¶

func (d *DyldInfoOnly) Put(b []byte, o binary.ByteOrder) int

func (*DyldInfoOnly) String ¶

func (d *DyldInfoOnly) String() string

func (*DyldInfoOnly) Write ¶

func (l *DyldInfoOnly) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type Dylib ¶

type Dylib struct {
	LoadBytes
	types.DylibCmd
	Name           string
	Time           uint32
	CurrentVersion string
	CompatVersion  string
}

A Dylib represents a Mach-O load dynamic library command.

func (*Dylib) String ¶

func (d *Dylib) String() string

type DylibCodeSignDrs ¶

type DylibCodeSignDrs struct {
	LoadBytes
	types.DylibCodeSignDrsCmd
	Offset uint32
	Size   uint32
}

func (*DylibCodeSignDrs) String ¶

func (d *DylibCodeSignDrs) String() string

func (*DylibCodeSignDrs) Write ¶

func (l *DylibCodeSignDrs) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type DylibID ¶

type DylibID Dylib

A DylibID represents a Mach-O LC_ID_DYLIB command.

func (*DylibID) String ¶

func (d *DylibID) String() string

type DylinkerID ¶

type DylinkerID struct {
	LoadBytes
	types.DylinkerIDCmd
	Name string
}

DylinkerID represents a Mach-O LC_ID_DYLINKER command.

func (*DylinkerID) String ¶

func (d *DylinkerID) String() string

type Dysymtab ¶

type Dysymtab struct {
	LoadBytes
	types.DysymtabCmd
	IndirectSyms []uint32 // indices into Symtab.Syms
}

A Dysymtab represents a Mach-O LC_DYSYMTAB command.

func (*Dysymtab) String ¶

func (d *Dysymtab) String() string

func (*Dysymtab) Write ¶

func (d *Dysymtab) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type EncryptionInfo ¶

type EncryptionInfo struct {
	LoadBytes
	types.EncryptionInfoCmd
	Offset  uint32                 // file offset of encrypted range
	Size    uint32                 // file size of encrypted range
	CryptID types.EncryptionSystem // which enryption system, 0 means not-encrypted yet
}

A EncryptionInfo represents a Mach-O 32-bit encrypted segment information

func (*EncryptionInfo) Copy ¶

func (e *EncryptionInfo) Copy() *EncryptionInfo

func (*EncryptionInfo) LoadSize ¶

func (e *EncryptionInfo) LoadSize(t *FileTOC) uint32

func (*EncryptionInfo) Put ¶

func (e *EncryptionInfo) Put(b []byte, o binary.ByteOrder) int

func (*EncryptionInfo) String ¶

func (e *EncryptionInfo) String() string

func (*EncryptionInfo) Write ¶

func (l *EncryptionInfo) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type EncryptionInfo64 ¶

type EncryptionInfo64 struct {
	LoadBytes
	types.EncryptionInfo64Cmd
	Offset  uint32                 // file offset of encrypted range
	Size    uint32                 // file size of encrypted range
	CryptID types.EncryptionSystem // which enryption system, 0 means not-encrypted yet
}

A EncryptionInfo64 represents a Mach-O 64-bit encrypted segment information

func (*EncryptionInfo64) Copy ¶

func (*EncryptionInfo64) LoadSize ¶

func (e *EncryptionInfo64) LoadSize(t *FileTOC) uint32

func (*EncryptionInfo64) Put ¶

func (e *EncryptionInfo64) Put(b []byte, o binary.ByteOrder) int

func (*EncryptionInfo64) String ¶

func (e *EncryptionInfo64) String() string

func (*EncryptionInfo64) Write ¶

func (e *EncryptionInfo64) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type EntryPoint ¶

type EntryPoint struct {
	LoadBytes
	types.EntryPointCmd
	EntryOffset uint64
	StackSize   uint64
}

EntryPoint represents a Mach-O LC_MAIN command.

func (*EntryPoint) Copy ¶

func (e *EntryPoint) Copy() *EntryPoint

func (*EntryPoint) LoadSize ¶

func (e *EntryPoint) LoadSize(t *FileTOC) uint32

func (*EntryPoint) Put ¶

func (e *EntryPoint) Put(b []byte, o binary.ByteOrder) int

func (*EntryPoint) String ¶

func (e *EntryPoint) String() string

func (*EntryPoint) Write ¶

func (e *EntryPoint) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type FatArch ¶

type FatArch struct {
	FatArchHeader
	*File
}

A FatArch is a Mach-O File inside a FatFile.

type FatArchHeader ¶

type FatArchHeader struct {
	CPU    types.CPU
	SubCPU types.CPUSubtype
	Offset uint32
	Size   uint32
	Align  uint32
}

A FatArchHeader represents a fat header for a specific image architecture.

type FatFile ¶

type FatFile struct {
	Magic  types.Magic
	Arches []FatArch
	// contains filtered or unexported fields
}

A FatFile is a Mach-O universal binary that contains at least one architecture.

func NewFatFile ¶

func NewFatFile(r io.ReaderAt) (*FatFile, error)

NewFatFile creates a new FatFile for accessing all the Mach-O images in a universal binary. The Mach-O binary is expected to start at position 0 in the ReaderAt.

func OpenFat ¶

func OpenFat(name string) (*FatFile, error)

OpenFat opens the named file using os.Open and prepares it for use as a Mach-O universal binary.

func (*FatFile) Close ¶

func (ff *FatFile) Close() error

Close with close the Mach-O Fat file.

type File ¶

type File struct {
	FileTOC

	Symtab   *Symtab
	Dysymtab *Dysymtab
	// contains filtered or unexported fields
}

A File represents an open Mach-O file.

func NewFile ¶

func NewFile(r io.ReaderAt, config ...FileConfig) (*File, error)

NewFile creates a new File for accessing a Mach-O binary in an underlying reader. The Mach-O binary is expected to start at position 0 in the ReaderAt.

func Open ¶

func Open(name string) (*File, error)

Open opens the named file using os.Open and prepares it for use as a Mach-O binary.

func (*File) BuildVersion ¶

func (f *File) BuildVersion() *BuildVersion

BuildVersion returns the build version load command, or nil if no build version exists.

func (*File) Close ¶

func (f *File) Close() error

Close closes the File. If the File was created using NewFile directly instead of Open, Close has no effect.

func (*File) CodeSignature ¶

func (f *File) CodeSignature() *CodeSignature

CodeSignature returns the code signature, or nil if none exists.

func (*File) DWARF ¶

func (f *File) DWARF() (*dwarf.Data, error)

DWARF returns the DWARF debug information for the Mach-O file.

func (*File) DataInCode ¶

func (f *File) DataInCode() *DataInCode

DataInCode returns the LC_DATA_IN_CODE, or nil if none exists.

func (*File) DyldChainedFixups ¶

func (f *File) DyldChainedFixups() (*fixupchains.DyldChainedFixups, error)

DyldChainedFixups returns the dyld chained fixups.

func (*File) DyldExports ¶

func (f *File) DyldExports() ([]trie.TrieExport, error)

DyldExports returns the dyld export trie symbols

func (*File) DyldExportsTrie ¶

func (f *File) DyldExportsTrie() *DyldExportsTrie

DyldExportsTrie returns the dyld export trie load command, or nil if no dyld info exists.

func (*File) DyldInfo ¶

func (f *File) DyldInfo() *DyldInfo

DyldInfo returns the dyld info load command, or nil if no dyld info exists.

func (*File) DyldInfoOnly ¶

func (f *File) DyldInfoOnly() *DyldInfoOnly

DyldInfoOnly returns the dyld info only load command, or nil if no dyld info only exists.

func (*File) DylibID ¶

func (f *File) DylibID() *DylibID

DylibID returns the dylib ID load command, or nil if no dylib ID exists.

func (*File) Export ¶

func (f *File) Export(path string, dcf *fixupchains.DyldChainedFixups, baseAddress uint64, locals []Symbol) (err error)

Export exports an in-memory or cached dylib|kext MachO to a file

func (*File) FileSets ¶

func (f *File) FileSets() []*FilesetEntry

FileSets returns an array of Fileset entries.

func (*File) FindAddressSymbols ¶

func (f *File) FindAddressSymbols(addr uint64) ([]Symbol, error)

func (*File) FindSectionForVMAddr ¶

func (f *File) FindSectionForVMAddr(vmAddr uint64) *Section

FindSectionForVMAddr returns the section containing a given virtual memory ddress.

func (*File) FindSegmentForVMAddr ¶

func (f *File) FindSegmentForVMAddr(vmAddr uint64) *Segment

FindSegmentForVMAddr returns the segment containing a given virtual memory ddress.

func (*File) FindSymbolAddress ¶

func (f *File) FindSymbolAddress(symbol string) (uint64, error)

func (*File) FunctionStarts ¶

func (f *File) FunctionStarts() *FunctionStarts

FunctionStarts returns the function starts array, or nil if none exists.

func (*File) GetBaseAddress ¶

func (f *File) GetBaseAddress() uint64

GetBaseAddress returns the MachO's preferred load address

func (*File) GetBindInfo ¶

func (f *File) GetBindInfo() (types.Binds, error)

func (*File) GetBindName ¶

func (f *File) GetBindName(pointer uint64) (string, error)

GetBindName returns the import name for a given dyld chained pointer

func (*File) GetCFStrings ¶

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

GetCFStrings returns the Objective-C CFStrings

func (*File) GetCString ¶

func (f *File) GetCString(strVMAdr uint64) (string, error)

GetCString returns a c-string at a given virtual address in the MachO

func (*File) GetCStringAtOffset ¶

func (f *File) GetCStringAtOffset(strOffset int64) (string, error)

GetCStringAtOffset returns a c-string at a given offset into the MachO

func (*File) GetDyldExport ¶

func (f *File) GetDyldExport(symbol string) (*trie.TrieExport, error)

DyldExports returns the dyld export trie symbols

func (*File) GetExports ¶

func (f *File) GetExports() ([]trie.TrieExport, error)

func (*File) GetFileSetFileByName ¶

func (f *File) GetFileSetFileByName(name string) (*File, error)

GetFileSetFileByName returns the Fileset MachO for a given name.

func (*File) GetFunctionData ¶

func (f *File) GetFunctionData(fn types.Function) ([]byte, error)

func (*File) GetFunctionForVMAddr ¶

func (f *File) GetFunctionForVMAddr(addr uint64) (types.Function, error)

GetFunctionForVMAddr returns the function containing a given virual address

func (*File) GetFunctions ¶

func (f *File) GetFunctions(data ...byte) []types.Function

GetFunctions returns the function array, or nil if none exists.

func (*File) GetMangledTypeAtOffset ¶

func (f *File) GetMangledTypeAtOffset(offset int64) (string, *stypes.TypeDescriptor, error)

GetMangledTypeAtOffset reads a mangled type at a given offset in the MachO

func (*File) GetObjCCategories ¶

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

GetObjCCategories returns an array of Objective-C categories

func (*File) GetObjCClass ¶

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

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

func (*File) GetObjCClassInfo ¶

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

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

func (*File) GetObjCClassNames ¶

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

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

func (*File) GetObjCClassReferences ¶

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

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

func (*File) GetObjCClasses ¶

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

GetObjCClasses returns an array of Objective-C classes

func (*File) GetObjCImageInfo ¶

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

GetObjCImageInfo returns the parsed __objc_imageinfo data

func (*File) GetObjCIvars ¶

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

GetObjCIvars returns the Objective-C instance variables

func (*File) GetObjCMethodList ¶

func (f *File) GetObjCMethodList() ([]objc.Method, error)

GetObjCMethodList returns the Objective-C method list

func (*File) GetObjCMethodNames ¶

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

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

func (*File) GetObjCMethods ¶

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

GetObjCMethods returns the Objective-C methods

func (*File) GetObjCNonLazyClasses ¶

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

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

func (*File) GetObjCProperties ¶

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

GetObjCProperties returns the Objective-C properties

func (*File) GetObjCProtoReferences ¶

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

GetObjCProtoReferences returns a map of protocol names to their section data virtual memory address

func (*File) GetObjCProtocols ¶

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

GetObjCProtocols returns the Objective-C protocols

func (*File) GetObjCSelectorReferences ¶

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

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

func (*File) GetObjCSuperReferences ¶

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

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

func (*File) GetObjCToc ¶

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

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

func (*File) GetOffset ¶

func (f *File) GetOffset(address uint64) (uint64, error)

GetOffset returns the file offset for a given virtual address

func (*File) GetPointer ¶

func (f *File) GetPointer(offset uint64) (uint64, error)

GetPointer returns pointer at a given offset

func (*File) GetPointerAtAddress ¶

func (f *File) GetPointerAtAddress(address uint64) (uint64, error)

GetPointerAtAddress returns pointer at a given virtual address

func (*File) GetRebaseInfo ¶

func (f *File) GetRebaseInfo() ([]types.Rebase, error)

func (*File) GetSectionsForSegment ¶

func (f *File) GetSectionsForSegment(name string) []*Section

GetSectionsForSegment returns all the segment's sections or nil if it doesn't have any

func (*File) GetSwiftAssociatedTypes ¶

func (f *File) GetSwiftAssociatedTypes() (*[]swift.AssociatedTypeDescriptor, error)

GetSwiftAssociatedTypes parses all the associated types in the __TEXT.__swift5_assocty section

func (*File) GetSwiftBuiltinTypes ¶

func (f *File) GetSwiftBuiltinTypes() (*[]swift.BuiltinType, error)

GetSwiftBuiltinTypes parses all the built-in types in the __TEXT.__swift5_builtin section

func (*File) GetSwiftClosures ¶

func (f *File) GetSwiftClosures() (*[]swift.CaptureDescriptor, error)

GetSwiftClosures parses all the closure context objects in the __TEXT.__swift5_capture section

func (*File) GetSwiftFields ¶

func (f *File) GetSwiftFields() (*[]fieldmd.Field, error)

GetSwiftFields parses all the fields in the __TEXT.__swift5_fieldmd section

func (*File) GetSwiftProtocolConformances ¶

func (f *File) GetSwiftProtocolConformances() (*[]protocols.ConformanceDescriptor, error)

GetSwiftProtocolConformances parses all the protocol conformances in the __TEXT.__swift5_proto section

func (*File) GetSwiftProtocols ¶

func (f *File) GetSwiftProtocols() (*[]protocols.Protocol, error)

GetSwiftProtocols parses all the protocols in the __TEXT.__swift5_protos section

func (*File) GetSwiftTypes ¶

func (f *File) GetSwiftTypes() (*[]stypes.TypeDescriptor, error)

GetSwiftTypes parses all the types in the __TEXT.__swift5_types section

func (*File) GetVMAddress ¶

func (f *File) GetVMAddress(offset uint64) (uint64, error)

GetVMAddress returns the virtal address for a given file offset

func (*File) HasFixups ¶

func (f *File) HasFixups() bool

HasFixups does macho contain a LC_DYLD_CHAINED_FIXUPS load command

func (*File) HasObjC ¶

func (f *File) HasObjC() bool

HasObjC returns true if MachO contains a __objc_imageinfo section

func (*File) HasObjCMessageReferences ¶

func (f *File) HasObjCMessageReferences() bool

HasObjCMessageReferences returns true if MachO contains a __objc_msgrefs section

func (*File) HasPlusLoadMethod ¶

func (f *File) HasPlusLoadMethod() bool

HasPlusLoadMethod returns true if MachO contains a __objc_nlclslist or __objc_nlcatlist section

func (*File) ImportedLibraries ¶

func (f *File) ImportedLibraries() []string

ImportedLibraries returns the paths of all libraries referred to by the binary f that are expected to be linked with the binary at dynamic link time.

func (*File) ImportedSymbolNames ¶

func (f *File) ImportedSymbolNames() ([]string, error)

ImportedSymbolNames returns the names of all symbols referred to by the binary f that are expected to be satisfied by other libraries at dynamic load time.

func (*File) ImportedSymbols ¶

func (f *File) ImportedSymbols() ([]Symbol, error)

ImportedSymbols returns the names of all symbols referred to by the binary f that are expected to be satisfied by other libraries at dynamic load time.

func (*File) IsCString ¶

func (f *File) IsCString(addr uint64) (string, bool)

IsCString returns cstring at given virtual address if is in a CstringLiterals section

func (*File) LibraryOrdinalName ¶

func (f *File) LibraryOrdinalName(libraryOrdinal int) string

LibraryOrdinalName returns the depancy library oridinal's name

func (*File) ReadAt ¶

func (f *File) ReadAt(p []byte, off int64) (n int, err error)

ReadAt reads data at offset within MachO

func (*File) Section ¶

func (f *File) Section(segment, section string) *Section

Section returns the section with the given name in the given segment, or nil if no such section exists.

func (*File) Segment ¶

func (f *File) Segment(name string) *Segment

Segment returns the first Segment with the given name, or nil if no such segment exists.

func (*File) Segments ¶

func (f *File) Segments() Segments

Segments returns all Segments.

func (*File) SlidePointer ¶

func (f *File) SlidePointer(ptr uint64) uint64

SlidePointer returns slid or un-chained pointer

func (*File) SourceVersion ¶

func (f *File) SourceVersion() *SourceVersion

SourceVersion returns the source version load command, or nil if no source version exists.

func (*File) UUID ¶

func (f *File) UUID() *UUID

UUID returns the UUID load command, or nil if no UUID exists.

type FileConfig ¶

type FileConfig struct {
	Offset               int64
	LoadFilter           []types.LoadCmd
	VMAddrConverter      types.VMAddrConverter
	SectionReader        types.MachoReader
	CacheReader          types.MachoReader
	RelativeSelectorBase uint64
}

FileConfig is a MachO file config object

type FileTOC ¶

type FileTOC struct {
	types.FileHeader
	ByteOrder binary.ByteOrder
	Loads     []Load
	Sections  sections
	// contains filtered or unexported fields
}

func (*FileTOC) AddLoad ¶

func (t *FileTOC) AddLoad(l Load)

func (*FileTOC) AddSection ¶

func (t *FileTOC) AddSection(s *Section)

AddSection adds section to the most recently added Segment

func (*FileTOC) AddSegment ¶

func (t *FileTOC) AddSegment(s *Segment)

AddSegment adds segment s to the file table of contents, and also zeroes out the segment information with the expectation that this will be added next.

func (*FileTOC) DerivedCopy ¶

func (t *FileTOC) DerivedCopy(Type types.HeaderFileType, Flags types.HeaderFlag) *FileTOC

DerivedCopy returns a modified copy of the TOC, with empty loads and sections, and with the specified header type and flags.

func (*FileTOC) FileSize ¶

func (t *FileTOC) FileSize() uint64

FileSize returns the size in bytes of the header, load commands, and the in-file contents of all the segments and sections included in those load commands, accounting for their offsets within the file.

func (*FileTOC) HdrSize ¶

func (t *FileTOC) HdrSize() uint32

HdrSize returns the size in bytes of the Macho header for a given magic number (where the magic number has been appropriately byte-swapped).

func (*FileTOC) LoadAlign ¶

func (t *FileTOC) LoadAlign() uint64

LoadAlign returns the required alignment of Load commands in a binary. This is used to add padding for necessary alignment.

func (*FileTOC) LoadSize ¶

func (t *FileTOC) LoadSize() uint32

LoadSize returns the size of all the load commands in a file's table-of contents (but not their associated data, e.g., sections and symbol tables)

func (*FileTOC) LoadsString ¶

func (t *FileTOC) LoadsString() string

LoadsString returns a string representation of all the MachO's load commands

func (*FileTOC) Put ¶

func (t *FileTOC) Put(buffer []byte) int

Put writes the header and all load commands to buffer, using the byte ordering specified in FileTOC t. For sections, this writes the headers that come in-line with the segment Load commands, but does not write the reference data for those sections.

func (*FileTOC) String ¶

func (t *FileTOC) String() string

func (*FileTOC) SymbolSize ¶

func (t *FileTOC) SymbolSize() uint32

SymbolSize returns the size in bytes of a Symbol (Nlist32 or Nlist64)

func (*FileTOC) TOCSize ¶

func (t *FileTOC) TOCSize() uint32

TOCSize returns the size in bytes of the object file representation of the header and Load Commands (including Segments and Sections, but not their contents) at the beginning of a Mach-O file. This typically overlaps the text segment in the object file.

type FilesetEntry ¶

type FilesetEntry struct {
	LoadBytes
	types.FilesetEntryCmd
	Addr    uint64 // memory address of the entry
	Offset  uint64 // file offset of the entry
	EntryID string // contained entry id
}

FilesetEntry used with fileset_entry_command

func (*FilesetEntry) String ¶

func (f *FilesetEntry) String() string

func (*FilesetEntry) Write ¶

func (l *FilesetEntry) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type FormatError ¶

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

FormatError is returned by some operations if the data does not have the correct format for an object file.

func (*FormatError) Error ¶

func (e *FormatError) Error() string

type FunctionStarts ¶

type FunctionStarts struct {
	LoadBytes
	types.FunctionStartsCmd
	Offset          uint32
	Size            uint32
	StartOffset     uint64
	NextFuncOffsets []uint64
	VMAddrs         []uint64
}

A FunctionStarts represents a Mach-O function starts command.

func (*FunctionStarts) String ¶

func (f *FunctionStarts) String() string

func (*FunctionStarts) Write ¶

func (l *FunctionStarts) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type FvmFile ¶

type FvmFile struct {
	LoadBytes
	types.FvmFileCmd
	Name          string
	HeaderAddress uint32
}

A FvmFile represents a Mach-O LC_FVMFILE command.

func (*FvmFile) String ¶

func (l *FvmFile) String() string

type IDFvmlib ¶

type IDFvmlib struct {
	LoadBytes
	types.IDFvmLibCmd
	Name          string
	MinorVersion  types.Version
	HeaderAddress uint32
}

A IDFvmlib represents a Mach-O LC_IDFVMLIB command.

func (*IDFvmlib) String ¶

func (l *IDFvmlib) String() string

type Ident ¶

type Ident struct {
	LoadBytes
	types.IdentCmd
	Length uint32
}

A Ident represents a Mach-O LC_IDENT command.

func (*Ident) String ¶

func (i *Ident) String() string

type LazyLoadDylib ¶

type LazyLoadDylib Dylib

A LazyLoadDylib represents a Mach-O LC_LAZY_LOAD_DYLIB command.

func (*LazyLoadDylib) String ¶

func (d *LazyLoadDylib) String() string

type LinkEditData ¶

type LinkEditData struct {
	LoadBytes
	types.LinkEditDataCmd
	Offset uint32
	Size   uint32
}

A LinkEditData represents a Mach-O linkedit data command.

func (*LinkEditData) Write ¶

func (l *LinkEditData) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type LinkerOptimizationHint ¶

type LinkerOptimizationHint struct {
	LoadBytes
	types.LinkerOptimizationHintCmd
	Offset uint32
	Size   uint32
}

func (*LinkerOptimizationHint) String ¶

func (l *LinkerOptimizationHint) String() string

func (*LinkerOptimizationHint) Write ¶

type LinkerOption ¶

type LinkerOption struct {
	LoadBytes
	types.LinkerOptionCmd
	Options []string
}

A LinkerOption represents a Mach-O LC_LINKER_OPTION command.

func (*LinkerOption) String ¶

func (o *LinkerOption) String() string

type Load ¶

type Load interface {
	Raw() []byte
	String() string
	Command() types.LoadCmd
	LoadSize(*FileTOC) uint32 // Need the TOC for alignment, sigh.
	Put([]byte, binary.ByteOrder) int
	Write(buf *bytes.Buffer, o binary.ByteOrder) error
}

A Load represents any Mach-O load command.

type LoadBytes ¶

type LoadBytes []byte

A LoadBytes is the uninterpreted bytes of a Mach-O load command.

func (LoadBytes) Copy ¶

func (b LoadBytes) Copy() LoadBytes

func (LoadBytes) LoadSize ¶

func (b LoadBytes) LoadSize(t *FileTOC) uint32

func (LoadBytes) Raw ¶

func (b LoadBytes) Raw() []byte

func (LoadBytes) String ¶

func (b LoadBytes) String() string

func (LoadBytes) Write ¶

func (b LoadBytes) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type LoadCmdBytes ¶

type LoadCmdBytes struct {
	types.LoadCmd
	LoadBytes
}

LoadCmdBytes is a command-tagged sequence of bytes. This is used for Load Commands that are not (yet) interesting to us, and to common up this behavior for all those that are.

func (LoadCmdBytes) Copy ¶

func (s LoadCmdBytes) Copy() LoadCmdBytes

func (LoadCmdBytes) String ¶

func (s LoadCmdBytes) String() string

type LoadDylinker ¶

type LoadDylinker struct {
	LoadBytes
	types.DylinkerCmd
	Name string
}

A LoadDylinker represents a Mach-O LC_LOAD_DYLINKER command.

func (*LoadDylinker) String ¶

func (d *LoadDylinker) String() string

type LoadFvmlib ¶

type LoadFvmlib struct {
	LoadBytes
	types.LoadFvmLibCmd
	Name          string
	MinorVersion  types.Version
	HeaderAddress uint32
}

A LoadFvmlib represents a Mach-O LC_LOADFVMLIB command.

func (*LoadFvmlib) String ¶

func (l *LoadFvmlib) String() string

type Note ¶

type Note struct {
	LoadBytes
	types.NoteCmd
	DataOwner string
	Offset    uint64
	Size      uint64
}

A Note represents a Mach-O LC_NOTE command.

func (*Note) String ¶

func (n *Note) String() string

type PrebindCksum ¶

type PrebindCksum struct {
	LoadBytes
	types.PrebindCksumCmd
	CheckSum uint32
}

A PrebindCksum is a Mach-O LC_PREBIND_CKSUM command.

func (*PrebindCksum) String ¶

func (p *PrebindCksum) String() string

type PreboundDylib ¶

type PreboundDylib struct {
	LoadBytes
	types.PreboundDylibCmd
	Name          string
	NumModules    uint32
	LinkedModules string
}

PreboundDylib represents a Mach-O LC_PREBOUND_DYLIB command.

func (*PreboundDylib) String ¶

func (d *PreboundDylib) String() string

type Prepage ¶

type Prepage struct {
	LoadBytes
	types.PrePageCmd
}

A Prepage represents a Mach-O LC_PREPAGE command.

type ReExportDylib ¶

type ReExportDylib Dylib

A ReExportDylib represents a Mach-O LC_REEXPORT_DYLIB command.

func (*ReExportDylib) String ¶

func (d *ReExportDylib) String() string

type Regs386 ¶

type Regs386 struct {
	AX    uint32
	BX    uint32
	CX    uint32
	DX    uint32
	DI    uint32
	SI    uint32
	BP    uint32
	SP    uint32
	SS    uint32
	FLAGS uint32
	IP    uint32
	CS    uint32
	DS    uint32
	ES    uint32
	FS    uint32
	GS    uint32
}

Regs386 is the Mach-O 386 register structure.

type RegsAMD64 ¶

type RegsAMD64 struct {
	AX    uint64
	BX    uint64
	CX    uint64
	DX    uint64
	DI    uint64
	SI    uint64
	BP    uint64
	SP    uint64
	R8    uint64
	R9    uint64
	R10   uint64
	R11   uint64
	R12   uint64
	R13   uint64
	R14   uint64
	R15   uint64
	IP    uint64
	FLAGS uint64
	CS    uint64
	FS    uint64
	GS    uint64
}

RegsAMD64 is the Mach-O AMD64 register structure.

type RegsARM ¶

type RegsARM struct {
	R0   uint32
	R1   uint32
	R2   uint32
	R3   uint32
	R4   uint32
	R5   uint32
	R6   uint32
	R7   uint32
	R8   uint32
	R9   uint32
	R10  uint32
	R11  uint32
	R12  uint32
	SP   uint32
	LR   uint32
	PC   uint32
	CPSR uint32
}

RegsARM is the Mach-O ARM register structure.

type RegsARM64 ¶

type RegsARM64 struct {
	X0   uint64
	X1   uint64
	X2   uint64
	X3   uint64
	X4   uint64
	X5   uint64
	X6   uint64
	X7   uint64
	X8   uint64
	X9   uint64
	X10  uint64
	X11  uint64
	X12  uint64
	X13  uint64
	X14  uint64
	X15  uint64
	X16  uint64
	X17  uint64
	X18  uint64
	X19  uint64
	X20  uint64
	X21  uint64
	X22  uint64
	X23  uint64
	X24  uint64
	X25  uint64
	X26  uint64
	X27  uint64
	X28  uint64
	FP   uint64
	LR   uint64
	SP   uint64
	PC   uint64
	CPSR uint32
	PAD  uint32
}

RegsARM64 is the Mach-O ARM 64 register structure.

type Reloc ¶

type Reloc struct {
	Addr  uint32
	Value uint32
	// when Scattered == false && Extern == true, Value is the symbol number.
	// when Scattered == false && Extern == false, Value is the section number.
	// when Scattered == true, Value is the value that this reloc refers to.
	Type      uint8
	Len       uint8 // 0=byte, 1=word, 2=long, 3=quad
	Pcrel     bool
	Extern    bool // valid if Scattered == false
	Scattered bool
}

A Reloc represents a Mach-O relocation.

type Routines ¶

type Routines struct {
	LoadBytes
	types.Routines64Cmd
	InitAddress uint32
	InitModule  uint32
}

A Routines is a Mach-O LC_ROUTINES command.

func (*Routines) String ¶

func (r *Routines) String() string

type Routines64 ¶

type Routines64 struct {
	LoadBytes
	types.Routines64Cmd
	InitAddress uint64
	InitModule  uint64
}

A Routines64 is a Mach-O LC_ROUTINES_64 command.

func (*Routines64) String ¶

func (r *Routines64) String() string

type Rpath ¶

type Rpath struct {
	LoadBytes
	types.RpathCmd
	Path string
}

A Rpath represents a Mach-O LC_RPATH command.

func (*Rpath) String ¶

func (r *Rpath) String() string

type Section ¶

type Section struct {
	SectionHeader
	Relocs []Reloc

	// Embed ReaderAt for ReadAt method.
	// Do not embed SectionReader directly
	// to avoid having Read and Seek.
	// If a client wants Read and Seek it must use
	// Open() to avoid fighting over the seek offset
	// with other clients.
	io.ReaderAt
	// contains filtered or unexported fields
}

func (*Section) Copy ¶

func (s *Section) Copy() *Section

func (*Section) Data ¶

func (s *Section) Data() ([]byte, error)

Data reads and returns the contents of the Mach-O section.

func (*Section) Open ¶

func (s *Section) Open() io.ReadSeeker

Open returns a new ReadSeeker reading the Mach-O section.

func (*Section) Put32 ¶

func (s *Section) Put32(b []byte, o binary.ByteOrder) int

func (*Section) Put64 ¶

func (s *Section) Put64(b []byte, o binary.ByteOrder) int

func (*Section) PutData ¶

func (s *Section) PutData(b []byte)

func (*Section) PutRelocs ¶

func (s *Section) PutRelocs(b []byte, o binary.ByteOrder) int

func (*Section) PutUncompressedData ¶

func (s *Section) PutUncompressedData(b []byte)

func (*Section) UncompressedSize ¶

func (s *Section) UncompressedSize() uint64

func (*Section) Write ¶

func (s *Section) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type SectionHeader ¶

type SectionHeader struct {
	Name      string
	Seg       string
	Addr      uint64
	Size      uint64
	Offset    uint32
	Align     uint32
	Reloff    uint32
	Nreloc    uint32
	Flags     types.SectionFlag
	Reserved1 uint32
	Reserved2 uint32
	Reserved3 uint32 // only present if original was 64-bit
	Type      uint8
}

type Segment ¶

type Segment struct {
	SegmentHeader
	LoadBytes
	// Embed ReaderAt for ReadAt method.
	// Do not embed SectionReader directly
	// to avoid having Read and Seek.
	// If a client wants Read and Seek it must use
	// Open() to avoid fighting over the seek offset
	// with other clients.
	io.ReaderAt
	// contains filtered or unexported fields
}

A Segment represents a Mach-O 32-bit or 64-bit load segment command.

func (*Segment) Copy ¶

func (s *Segment) Copy() *Segment

func (*Segment) CopyZeroed ¶

func (s *Segment) CopyZeroed() *Segment

func (*Segment) Data ¶

func (s *Segment) Data() ([]byte, error)

Data reads and returns the contents of the segment.

func (*Segment) LessThan ¶

func (s *Segment) LessThan(o *Segment) bool

func (*Segment) LoadSize ¶

func (s *Segment) LoadSize(t *FileTOC) uint32

func (*Segment) Open ¶

func (s *Segment) Open() io.ReadSeeker

Open returns a new ReadSeeker reading the segment.

func (*Segment) Put32 ¶

func (s *Segment) Put32(b []byte, o binary.ByteOrder) int

func (*Segment) Put64 ¶

func (s *Segment) Put64(b []byte, o binary.ByteOrder) int

func (*Segment) String ¶

func (s *Segment) String() string

func (*Segment) UncompressedSize ¶

func (s *Segment) UncompressedSize(t *FileTOC, align uint64) uint64

UncompressedSize returns the size of the segment with its sections uncompressed, ignoring its offset within the file. The returned size is rounded up to the power of two in align.

func (*Segment) Write ¶

func (s *Segment) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type SegmentHeader ¶

type SegmentHeader struct {
	types.LoadCmd
	Len       uint32
	Name      string
	Addr      uint64
	Memsz     uint64
	Offset    uint64
	Filesz    uint64
	Maxprot   types.VmProtection
	Prot      types.VmProtection
	Nsect     uint32
	Flag      types.SegFlag
	Firstsect uint32
}

A SegmentHeader is the header for a Mach-O 32-bit or 64-bit load segment command.

func (*SegmentHeader) String ¶

func (s *SegmentHeader) String() string

type Segments ¶

type Segments []*Segment

func (Segments) Len ¶

func (v Segments) Len() int

func (Segments) Less ¶

func (v Segments) Less(i, j int) bool

func (Segments) Swap ¶

func (v Segments) Swap(i, j int)

type SourceVersion ¶

type SourceVersion struct {
	LoadBytes
	types.SourceVersionCmd
	Version string
}

A SourceVersion represents a Mach-O LC_SOURCE_VERSION command.

func (*SourceVersion) String ¶

func (s *SourceVersion) String() string

type SplitInfo ¶

type SplitInfo struct {
	LoadBytes
	types.SegmentSplitInfoCmd
	Offset  uint32
	Size    uint32
	Version uint8
	Offsets []uint64
}

A SplitInfo represents a Mach-O LC_SEGMENT_SPLIT_INFO command.

func (*SplitInfo) String ¶

func (s *SplitInfo) String() string

func (*SplitInfo) Write ¶

func (s *SplitInfo) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type SubClient ¶

type SubClient struct {
	LoadBytes
	types.SubClientCmd
	Name string
}

A SubClient is a Mach-O LC_SUB_CLIENT command.

func (*SubClient) String ¶

func (d *SubClient) String() string

type SubFramework ¶

type SubFramework struct {
	LoadBytes
	types.SubFrameworkCmd
	Framework string
}

A SubFramework is a Mach-O LC_SUB_FRAMEWORK command.

func (*SubFramework) String ¶

func (s *SubFramework) String() string

type SubLibrary ¶

type SubLibrary struct {
	LoadBytes
	types.SubFrameworkCmd
	Library string
}

A SubLibrary is a Mach-O LC_SUB_LIBRARY command.

func (*SubLibrary) String ¶

func (s *SubLibrary) String() string

type SubUmbrella ¶

type SubUmbrella struct {
	LoadBytes
	types.SubFrameworkCmd
	Umbrella string
}

A SubUmbrella is a Mach-O LC_SUB_UMBRELLA command.

func (*SubUmbrella) String ¶

func (s *SubUmbrella) String() string

type SymSeg ¶

type SymSeg struct {
	LoadBytes
	types.SymsegCommand
	Offset uint32
	Size   uint32
}

A SymSeg represents a Mach-O LC_SYMSEG command.

func (*SymSeg) String ¶

func (s *SymSeg) String() string

type Symbol ¶

type Symbol struct {
	Name  string
	Type  types.NType
	Sect  uint8
	Desc  types.NDescType
	Value uint64
}

A Symbol is a Mach-O 32-bit or 64-bit symbol table entry.

func (Symbol) String ¶

func (s Symbol) String(m *File) string

type Symtab ¶

type Symtab struct {
	LoadBytes
	types.SymtabCmd
	Syms []Symbol
}

A Symtab represents a Mach-O LC_SYMTAB command.

func (*Symtab) Copy ¶

func (s *Symtab) Copy() *Symtab

func (*Symtab) LoadSize ¶

func (s *Symtab) LoadSize(t *FileTOC) uint32

func (*Symtab) Put ¶

func (s *Symtab) Put(b []byte, o binary.ByteOrder) int

func (*Symtab) Search ¶

func (s *Symtab) Search(name string) (*Symbol, error)

func (*Symtab) String ¶

func (s *Symtab) String() string

func (*Symtab) Write ¶

func (s *Symtab) Write(buf *bytes.Buffer, o binary.ByteOrder) error

type Thread ¶

type Thread struct {
	LoadBytes
	types.Thread
	Type uint32
	Data []uint32
}

A Thread represents a Mach-O LC_THREAD command.

func (*Thread) String ¶

func (t *Thread) String() string

type TwolevelHints ¶

type TwolevelHints struct {
	LoadBytes
	types.TwolevelHintsCmd
	Offset uint32
	Hints  []types.TwolevelHint
}

A TwolevelHints is a Mach-O LC_TWOLEVEL_HINTS command.

func (*TwolevelHints) String ¶

func (s *TwolevelHints) String() string

type UUID ¶

type UUID struct {
	LoadBytes
	types.UUIDCmd
	ID string
}

UUID represents a Mach-O LC_UUID command.

func (*UUID) Copy ¶

func (s *UUID) Copy() *UUID

func (*UUID) LoadSize ¶

func (s *UUID) LoadSize(t *FileTOC) uint32

func (*UUID) Put ¶

func (s *UUID) Put(b []byte, o binary.ByteOrder) int

func (*UUID) String ¶

func (s *UUID) String() string

type UnixThread ¶

type UnixThread struct {
	LoadBytes
	types.UnixThreadCmd
	EntryPoint uint64
}

A UnixThread represents a Mach-O LC_UNIXTHREAD command.

func (*UnixThread) String ¶

func (u *UnixThread) String() string

type UpwardDylib ¶

type UpwardDylib Dylib

A UpwardDylib represents a Mach-O load upward dylib command.

func (*UpwardDylib) String ¶

func (d *UpwardDylib) String() string

type VersionMinMacOSX ¶

type VersionMinMacOSX struct {
	LoadBytes
	types.VersionMinMacOSCmd
	Version string
	Sdk     string
}

VersionMinMacOSX build for MacOSX min OS version

func (*VersionMinMacOSX) String ¶

func (v *VersionMinMacOSX) String() string

type VersionMinTvOS ¶

type VersionMinTvOS struct {
	LoadBytes
	types.VersionMinIPhoneOSCmd
	Version string
	Sdk     string
}

VersionMinTvOS build for AppleTV min OS version

func (*VersionMinTvOS) String ¶

func (v *VersionMinTvOS) String() string

type VersionMinWatchOS ¶

type VersionMinWatchOS struct {
	LoadBytes
	types.VersionMinIPhoneOSCmd
	Version string
	Sdk     string
}

VersionMinWatchOS build for Watch min OS version

func (*VersionMinWatchOS) String ¶

func (v *VersionMinWatchOS) String() string

type VersionMiniPhoneOS ¶

type VersionMiniPhoneOS struct {
	LoadBytes
	types.VersionMinIPhoneOSCmd
	Version string
	Sdk     string
}

VersionMiniPhoneOS build for iPhoneOS min OS version

func (*VersionMiniPhoneOS) String ¶

func (v *VersionMiniPhoneOS) String() string

type WeakDylib ¶

type WeakDylib Dylib

A WeakDylib represents a Mach-O LC_LOAD_WEAK_DYLIB command.

func (*WeakDylib) String ¶

func (d *WeakDylib) String() string

Directories ¶

Path Synopsis
internal
obscuretestdata
Package obscuretestdata contains functionality used by tests to more easily work with testdata that must be obscured primarily due to golang.org/issue/34986.
Package obscuretestdata contains functionality used by tests to more easily work with testdata that must be obscured primarily due to golang.org/issue/34986.
pkg

Jump to

Keyboard shortcuts

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