?
This document uses PHP Chinese website manual Release
import "debug/plan9obj"
概述
參數(shù)
Package plan9obj 實(shí)現(xiàn)對(duì) Plan 9 a.out 目標(biāo)文件的訪問(wèn)。
Constants
type File
func NewFile(r io.ReaderAt) (*File, error)
func Open(name string) (*File, error)
func (f *File) Close() error
func (f *File) Section(name string) *Section
func (f *File) Symbols() ([]Sym, error)
type FileHeader
type Section
func (s *Section) Data() ([]byte, error)
func (s *Section) Open() io.ReadSeeker
type SectionHeader
type Sym
file.go plan9obj.go
const ( Magic64 = 0x8000 // 64位擴(kuò)展標(biāo)頭 Magic386 = (4*11+0)*11 + 7 MagicAMD64 = (4*26+0)*26 + 7 + Magic64 MagicARM = (4*20+0)*20 + 7)
File 代表一個(gè)開(kāi)放的 Plan 9 a.out 文件。
type File struct { FileHeader Sections []*Section // 包含已過(guò)濾或未導(dǎo)出的字段}
func NewFile(r io.ReaderAt) (*File, error)
NewFile 在底層的閱讀器中創(chuàng)建一個(gè)用于訪問(wèn) Plan 9 二進(jìn)制文件的新文件。Plan 9二進(jìn)制文件預(yù)計(jì)從 ReaderAt 的位置0開(kāi)始。
func Open(name string) (*File, error)
打開(kāi)使用 os.Open 打開(kāi)命名文件,并將其準(zhǔn)備用作 Plan 9 a.out 二進(jìn)制文件。
func (f *File) Close() error
關(guān)閉文件。如果文件是直接使用 NewFile 而不是 Open 來(lái)創(chuàng)建的,則 Close 不起作用。
func (f *File) Section(name string) *Section
部分返回給定名稱(chēng)的部分,如果不存在此部分,則返回 nil。
func (f *File) Symbols() ([]Sym, error)
符號(hào)返回f的符號(hào)表。
FileHeader 代表 Plan 9 a.out 文件頭。
type FileHeader struct { Magic uint32 Bss uint32 Entry uint64 PtrSize int LoadAddress uint64 HdrSize uint64}
Section 代表 Plan 9 a.out 文件中的單個(gè) Section。
type Section struct { SectionHeader // 為ReadAt方法嵌入ReaderAt。 // 不要直接嵌入SectionReader // 避免Read和Seek。 // 如果客戶(hù)想要閱讀和尋求它必須使用 // Open()以避免爭(zhēng)奪搜索偏移量 // 與其他客戶(hù)。 io.ReaderAt // 包含已過(guò)濾或未導(dǎo)出的字段}
func (s *Section) Data() ([]byte, error)
數(shù)據(jù)讀取并返回 Plan 9 a.out 部分的內(nèi)容。
func (s *Section) Open() io.ReadSeeker
打開(kāi)返回閱讀 Plan 9 a.out 部分的新 ReadSeeker。
SectionHeader 表示單個(gè) Plan 9 a.out 節(jié)標(biāo)題。該結(jié)構(gòu)不存在于磁盤(pán)上,但可以簡(jiǎn)化通過(guò)目標(biāo)文件的導(dǎo)航。
type SectionHeader struct { Name string Size uint32 Offset uint32}
符號(hào)表示 Plan 9 a.out 符號(hào)表部分中的條目。
type Sym struct { Value uint64 Type rune Name string}