const ( Magic64 = 0x8000 // 64 ビット拡張ヘッダ 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 // エクスポートされていないフィールドがあります }
func NewFile(r io.ReaderAt) (*File, error)
NewFile は,内部のリーダーで Plan 9 バイナリにアクセスするための新しい File を作成します。 Plan 9 バイナリは, ReaderAt の位置 0 から始まると予想されます。
func Open(name string) (*File, error)
Open は, os.Open を使用して名前付きファイルを開き,それを Plan 9 a.out バイナリとして使用するための準備をします。
func (f *File) Close() error
Close はファイルを閉じます。 ファイルが Open ではなく NewFile を使用して直接作成された場合, Close は効果がありません。
func (f *File) Section(name string) *Section
Section は与えられた名前のセクションを返します。 そのようなセクションが存在しない場合は nil を返します。
func (f *File) Symbols() ([]Sym, error)
Symbols は f のシンボルテーブルを返します。
FileHeader は, Plan 9 の a.out ファイルヘッダーを表します。
type FileHeader struct { Magic uint32 Bss uint32 Entry uint64 PtrSize int LoadAddress uint64 // Go 1.4 HdrSize uint64 // Go 1.4 }
Section は, Plan 9 の a.out ファイル内の 1 つのセクションを表します。
type Section struct { SectionHeader // ReadAt メソッドに ReaderAt を埋め込みます。 // Read や Seek を避けるために, SectionReader を直接埋め込んではいけません。 // クライアントが Read and Seek を望んでいる場合は,他のクライアントとのシークオフセットの競合を避けるために Open() を使用する必要があります。 io.ReaderAt // エクスポートされていないフィールドがあります }
func (s *Section) Data() ([]byte, error)
Data は, Plan 9 a.out セクションの内容を読み取って返します。
func (s *Section) Open() io.ReadSeeker
Open は, Plan 9 a.out セクションを読んでいる新しい ReadSeeker を返します。
SectionHeader は, 1 つの Plan 9 a.out セクションヘッダーを表します。 この構造はディスク上には存在しませんが,オブジェクトファイル内のナビゲーションを容易にします。
type SectionHeader struct { Name string Size uint32 Offset uint32 }
Symbol は,プラン 9 のシンボルテーブルセクションのエントリを表します。
type Sym struct { Value uint64 Type rune Name string }