plan9obj

Imports

Imports #

"encoding/binary"
"errors"
"fmt"
"internal/saferio"
"io"
"os"

Constants & Variables

ErrNoSymbols var #

ErrNoSymbols is returned by [File.Symbols] if there is no such section in the File.

var ErrNoSymbols = *ast.CallExpr

Magic386 const #

const Magic386 = *ast.BinaryExpr

Magic64 const #

const Magic64 = 0x8000

MagicAMD64 const #

const MagicAMD64 = *ast.BinaryExpr

MagicARM const #

const MagicARM = *ast.BinaryExpr

Structs

File struct #

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

type File struct {
FileHeader
Sections []*Section
closer io.Closer
}

FileHeader struct #

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

type FileHeader struct {
Magic uint32
Bss uint32
Entry uint64
PtrSize int
LoadAddress uint64
HdrSize uint64
}

Section struct #

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

type Section struct {
SectionHeader
io.ReaderAt
sr *io.SectionReader
}

SectionHeader struct #

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 SectionHeader struct {
Name string
Size uint32
Offset uint32
}

Sym struct #

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

type Sym struct {
Value uint64
Type rune
Name string
}

formatError struct #

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

type formatError struct {
off int
msg string
val any
}

prog struct #

Plan 9 Program header.

type prog struct {
Magic uint32
Text uint32
Data uint32
Bss uint32
Syms uint32
Entry uint32
Spsz uint32
Pcsz uint32
}

sym struct #

Plan 9 symbol table entries.

type sym struct {
value uint64
typ byte
name []byte
}

Functions

Close method #

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

func (f *File) Close() error

Data method #

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

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

Error method #

func (e *formatError) Error() string

NewFile function #

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 NewFile(r io.ReaderAt) (*File, error)

Open method #

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

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

Open function #

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

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

Section method #

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

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

Symbols method #

Symbols returns the symbol table for f.

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

newTable function #

newTable decodes the Go symbol table in data, returning an in-memory representation.

func newTable(symtab []byte, ptrsz int) ([]Sym, error)

parseMagic function #

func parseMagic(magic []byte) (uint32, error)

walksymtab function #

func walksymtab(data []byte, ptrsz int, fn func(sym) error) error

Generated with Arrow