?
本文檔使用 php中文網(wǎng)手冊 發(fā)布
import "debug/plan9obj"
概述
參數(shù)
Package plan9obj 實(shí)現(xiàn)對 Plan 9 a.out 目標(biāo)文件的訪問。
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 代表一個開放的 Plan 9 a.out 文件。
type File struct { FileHeader Sections []*Section // 包含已過濾或未導(dǎo)出的字段}
func NewFile(r io.ReaderAt) (*File, error)
NewFile 在底層的閱讀器中創(chuàng)建一個用于訪問 Plan 9 二進(jìn)制文件的新文件。Plan 9二進(jìn)制文件預(yù)計(jì)從 ReaderAt 的位置0開始。
func Open(name string) (*File, error)
打開使用 os.Open 打開命名文件,并將其準(zhǔn)備用作 Plan 9 a.out 二進(jìn)制文件。
func (f *File) Close() error
關(guān)閉文件。如果文件是直接使用 NewFile 而不是 Open 來創(chuàng)建的,則 Close 不起作用。
func (f *File) Section(name string) *Section
部分返回給定名稱的部分,如果不存在此部分,則返回 nil。
func (f *File) Symbols() ([]Sym, error)
符號返回f的符號表。
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 文件中的單個 Section。
type Section struct { SectionHeader // 為ReadAt方法嵌入ReaderAt。 // 不要直接嵌入SectionReader // 避免Read和Seek。 // 如果客戶想要閱讀和尋求它必須使用 // Open()以避免爭奪搜索偏移量 // 與其他客戶。 io.ReaderAt // 包含已過濾或未導(dǎo)出的字段}
func (s *Section) Data() ([]byte, error)
數(shù)據(jù)讀取并返回 Plan 9 a.out 部分的內(nèi)容。
func (s *Section) Open() io.ReadSeeker
打開返回閱讀 Plan 9 a.out 部分的新 ReadSeeker。
SectionHeader 表示單個 Plan 9 a.out 節(jié)標(biāo)題。該結(jié)構(gòu)不存在于磁盤上,但可以簡化通過目標(biāo)文件的導(dǎo)航。
type SectionHeader struct { Name string Size uint32 Offset uint32}
符號表示 Plan 9 a.out 符號表部分中的條目。
type Sym struct { Value uint64 Type rune Name string}