version: 1.10

package plan9obj

import "debug/plan9obj"

Overview

Package plan9obj implements access to Plan 9 a.out object files.

Index

Package files

file.go plan9obj.go

Constants

  1. const (
  2. Magic64 = 0x8000 // 64-bit expanded header
  3.  
  4. Magic386 = (4*11+0)*11 + 7
  5. MagicAMD64 = (4*26+0)*26 + 7 + Magic64
  6. MagicARM = (4*20+0)*20 + 7
  7. )

type File

  1. type File struct {
  2. FileHeader
  3. Sections []*Section
  4. // contains filtered or unexported fields
  5. }

A File represents an open Plan 9 a.out file.

func NewFile

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

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

func Open

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

Open opens the named file using os.Open and prepares it for use as a Plan 9
a.out binary.

func (*File) Close

  1. 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) Section

  1. func (f *File) Section(name string) *Section

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

func (*File) Symbols

  1. func (f *File) Symbols() ([]Sym, error)

Symbols returns the symbol table for f.

type FileHeader

  1. type FileHeader struct {
  2. Magic uint32
  3. Bss uint32
  4. Entry uint64
  5. PtrSize int
  6. LoadAddress uint64
  7. HdrSize uint64
  8. }

A FileHeader represents a Plan 9 a.out file header.

type Section

  1. type Section struct {
  2. SectionHeader
  3.  
  4. // Embed ReaderAt for ReadAt method.
  5. // Do not embed SectionReader directly
  6. // to avoid having Read and Seek.
  7. // If a client wants Read and Seek it must use
  8. // Open() to avoid fighting over the seek offset
  9. // with other clients.
  10. io.ReaderAt
  11. // contains filtered or unexported fields
  12. }

A Section represents a single section in a Plan 9 a.out file.

func (*Section) Data

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

Data reads and returns the contents of the Plan 9 a.out section.

func (*Section) Open

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

Open returns a new ReadSeeker reading the Plan 9 a.out section.

type SectionHeader

  1. type SectionHeader struct {
  2. Name string
  3. Size uint32
  4. Offset uint32
  5. }

A SectionHeader represents a single Plan 9 a.out section header. This structure
doesn’t exist on-disk, but eases navigation through the object file.

type Sym

  1. type Sym struct {
  2. Value uint64
  3. Type rune
  4. Name string
  5. }

A Symbol represents an entry in a Plan 9 a.out symbol table section.