plan9obj package - debug/plan9obj - Go Packages

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

Security ΒΆ

This package is not designed to be hardened against adversarial inputs, and is outside the scope of https://go.dev/security/policy. In particular, only basic validation is done when parsing object files. As such, care should be taken when parsing untrusted inputs, as parsing malformed files may consume significant resources, or cause panics.

View Source

const (
	Magic64 = 0x8000 

	Magic386   = (4*11+0)*11 + 7
	MagicAMD64 = (4*26+0)*26 + 7 + Magic64
	MagicARM   = (4*20+0)*20 + 7
)

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

This section is empty.

type File struct {
	Sections []*Section
	
}

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

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.

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

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

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

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

Symbols returns the symbol table for f.

type FileHeader struct {
}

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

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

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

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

type 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.

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