xcoff

Imports

Imports #

"debug/dwarf"
"encoding/binary"
"errors"
"fmt"
"internal/saferio"
"io"
"os"
"strings"
"encoding/binary"
"fmt"
"io"
"os"
"strconv"
"strings"

Constants & Variables

AIAFMAG const #

const AIAFMAG = "`\n"

AIAMAG const #

const AIAMAG = "\n"

AIAMAGBIG const #

const AIAMAGBIG = "\n"

AR_HSZ_BIG const #

const AR_HSZ_BIG = 0x70

C_BCOMM const #

Storage Class.

const C_BCOMM = 135

C_BINCL const #

Storage Class.

const C_BINCL = 108

C_BLOCK const #

Storage Class.

const C_BLOCK = 100

C_BSTAT const #

Storage Class.

const C_BSTAT = 143

C_DECL const #

Storage Class.

const C_DECL = 140

C_DWARF const #

Storage Class.

const C_DWARF = 112

C_ECOML const #

Storage Class.

const C_ECOML = 136

C_ECOMM const #

Storage Class.

const C_ECOMM = 137

C_EINCL const #

Storage Class.

const C_EINCL = 109

C_ENTRY const #

Storage Class.

const C_ENTRY = 141

C_ESTAT const #

Storage Class.

const C_ESTAT = 144

C_EXT const #

Storage Class.

const C_EXT = 2

C_FCN const #

Storage Class.

const C_FCN = 101

C_FILE const #

Storage Class.

const C_FILE = 103

C_FUN const #

Storage Class.

const C_FUN = 142

C_GSYM const #

Storage Class.

const C_GSYM = 128

C_GTLS const #

Storage Class.

const C_GTLS = 145

C_HIDEXT const #

Storage Class.

const C_HIDEXT = 107

C_LSYM const #

Storage Class.

const C_LSYM = 129

C_NULL const #

Storage Class.

const C_NULL = 0

C_PSYM const #

Storage Class.

const C_PSYM = 130

C_RPSYM const #

Storage Class.

const C_RPSYM = 132

C_RSYM const #

Storage Class.

const C_RSYM = 131

C_STAT const #

Storage Class.

const C_STAT = 3

C_STSYM const #

Storage Class.

const C_STSYM = 133

C_STTLS const #

Storage Class.

const C_STTLS = 146

C_WEAKEXT const #

Storage Class.

const C_WEAKEXT = 111

FILHSZ_32 const #

const FILHSZ_32 = 20

FILHSZ_64 const #

const FILHSZ_64 = 24

FL_HSZ_BIG const #

Sizeof

const FL_HSZ_BIG = 0x80

F_DSA const #

Flags that describe the type of the object file.

const F_DSA = 0x0040

F_DYNLOAD const #

Flags that describe the type of the object file.

const F_DYNLOAD = 0x1000

F_EXEC const #

Flags that describe the type of the object file.

const F_EXEC = 0x0002

F_FDPR_OPTI const #

Flags that describe the type of the object file.

const F_FDPR_OPTI = 0x0020

F_FDPR_PROF const #

Flags that describe the type of the object file.

const F_FDPR_PROF = 0x0010

F_LNNO const #

Flags that describe the type of the object file.

const F_LNNO = 0x0004

F_LOADONLY const #

Flags that describe the type of the object file.

const F_LOADONLY = 0x4000

F_RELFLG const #

Flags that describe the type of the object file.

const F_RELFLG = 0x0001

F_SHROBJ const #

Flags that describe the type of the object file.

const F_SHROBJ = 0x2000

F_VARPG const #

Flags that describe the type of the object file.

const F_VARPG = 0x0100

LDHDRSZ_32 const #

const LDHDRSZ_32 = 32

LDHDRSZ_64 const #

const LDHDRSZ_64 = 56

N_ABS const #

const N_ABS = *ast.UnaryExpr

N_DEBUG const #

Nscnum

const N_DEBUG = *ast.UnaryExpr

N_UNDEF const #

const N_UNDEF = 0

R_BA const #

const R_BA = 0x08

R_BR const #

const R_BR = 0x0A

R_GL const #

const R_GL = 0x05

R_NEG const #

const R_NEG = 0x01

R_POS const #

const R_POS = 0x00

R_RBA const #

const R_RBA = 0x18

R_RBR const #

const R_RBR = 0x1A

R_REF const #

const R_REF = 0x0F

R_REL const #

const R_REL = 0x02

R_RL const #

const R_RL = 0x0C

R_RLA const #

const R_RLA = 0x0D

R_TCL const #

const R_TCL = 0x06

R_TLS const #

const R_TLS = 0x20

R_TLSM const #

const R_TLSM = 0x24

R_TLSML const #

const R_TLSML = 0x25

R_TLS_IE const #

const R_TLS_IE = 0x21

R_TLS_LD const #

const R_TLS_LD = 0x22

R_TLS_LE const #

const R_TLS_LE = 0x23

R_TOC const #

const R_TOC = 0x03

R_TOCL const #

const R_TOCL = 0x31

R_TOCU const #

const R_TOCU = 0x30

R_TRL const #

const R_TRL = 0x12

R_TRLA const #

const R_TRLA = 0x13

SAIAMAG const #

const SAIAMAG = 0x8

SSUBTYP_DWABREV const #

const SSUBTYP_DWABREV = 0x60000

SSUBTYP_DWARNGE const #

const SSUBTYP_DWARNGE = 0x50000

SSUBTYP_DWFRAME const #

const SSUBTYP_DWFRAME = 0xA0000

SSUBTYP_DWINFO const #

const SSUBTYP_DWINFO = 0x10000

SSUBTYP_DWLINE const #

const SSUBTYP_DWLINE = 0x20000

SSUBTYP_DWLOC const #

const SSUBTYP_DWLOC = 0x90000

SSUBTYP_DWMAC const #

const SSUBTYP_DWMAC = 0xB0000

SSUBTYP_DWPBNMS const #

const SSUBTYP_DWPBNMS = 0x30000

SSUBTYP_DWPBTYP const #

const SSUBTYP_DWPBTYP = 0x40000

SSUBTYP_DWRNGES const #

const SSUBTYP_DWRNGES = 0x80000

SSUBTYP_DWSTR const #

const SSUBTYP_DWSTR = 0x70000

STYP_BSS const #

Flags defining the section type.

const STYP_BSS = 0x0080

STYP_DATA const #

Flags defining the section type.

const STYP_DATA = 0x0040

STYP_DEBUG const #

Flags defining the section type.

const STYP_DEBUG = 0x2000

STYP_DWARF const #

Flags defining the section type.

const STYP_DWARF = 0x0010

STYP_EXCEPT const #

Flags defining the section type.

const STYP_EXCEPT = 0x0100

STYP_INFO const #

Flags defining the section type.

const STYP_INFO = 0x0200

STYP_LOADER const #

Flags defining the section type.

const STYP_LOADER = 0x1000

STYP_OVRFLO const #

Flags defining the section type.

const STYP_OVRFLO = 0x8000

STYP_TBSS const #

Flags defining the section type.

const STYP_TBSS = 0x0800

STYP_TDATA const #

Flags defining the section type.

const STYP_TDATA = 0x0400

STYP_TEXT const #

Flags defining the section type.

const STYP_TEXT = 0x0020

STYP_TYPCHK const #

Flags defining the section type.

const STYP_TYPCHK = 0x4000

SYMESZ const #

const SYMESZ = 18

SYM_TYPE_FUNC const #

const SYM_TYPE_FUNC = 0x0020

SYM_V_EXPORTED const #

const SYM_V_EXPORTED = 0x4000

SYM_V_HIDDEN const #

const SYM_V_HIDDEN = 0x2000

SYM_V_INTERNAL const #

Ntype

const SYM_V_INTERNAL = 0x1000

SYM_V_PROTECTED const #

const SYM_V_PROTECTED = 0x3000

U64_TOCMAGIC const #

const U64_TOCMAGIC = 0767

U802TOCMAGIC const #

const U802TOCMAGIC = 0737

XFT_CD const #

Defines for File auxiliary definitions: x_ftype field of x_file

const XFT_CD = 128

XFT_CT const #

Defines for File auxiliary definitions: x_ftype field of x_file

const XFT_CT = 1

XFT_CV const #

Defines for File auxiliary definitions: x_ftype field of x_file

const XFT_CV = 2

XFT_FN const #

Defines for File auxiliary definitions: x_ftype field of x_file

const XFT_FN = 0

XMC_BS const #

Storage-mapping class.

const XMC_BS = 9

XMC_DB const #

Storage-mapping class.

const XMC_DB = 2

XMC_DS const #

Storage-mapping class.

const XMC_DS = 10

XMC_GL const #

Storage-mapping class.

const XMC_GL = 6

XMC_PR const #

Storage-mapping class.

const XMC_PR = 0

XMC_RO const #

Storage-mapping class.

const XMC_RO = 1

XMC_RW const #

Storage-mapping class.

const XMC_RW = 5

XMC_SV const #

Storage-mapping class.

const XMC_SV = 8

XMC_SV3264 const #

Storage-mapping class.

const XMC_SV3264 = 18

XMC_SV64 const #

Storage-mapping class.

const XMC_SV64 = 17

XMC_TC const #

Storage-mapping class.

const XMC_TC = 3

XMC_TC0 const #

Storage-mapping class.

const XMC_TC0 = 15

XMC_TD const #

Storage-mapping class.

const XMC_TD = 16

XMC_TE const #

Storage-mapping class.

const XMC_TE = 22

XMC_TL const #

Storage-mapping class.

const XMC_TL = 20

XMC_UA const #

Storage-mapping class.

const XMC_UA = 4

XMC_UC const #

Storage-mapping class.

const XMC_UC = 11

XMC_UL const #

Storage-mapping class.

const XMC_UL = 21

XMC_XO const #

Storage-mapping class.

const XMC_XO = 7

XTY_CM const #

Symbol type field.

const XTY_CM = 3

XTY_ER const #

Symbol type field.

const XTY_ER = 0

XTY_LD const #

Symbol type field.

const XTY_LD = 2

XTY_SD const #

Symbol type field.

const XTY_SD = 1

_AUX_CSECT const #

Auxiliary type

const _AUX_CSECT = 251

_AUX_EXCEPT const #

Auxiliary type

const _AUX_EXCEPT = 255

_AUX_FCN const #

Auxiliary type

const _AUX_FCN = 254

_AUX_FILE const #

Auxiliary type

const _AUX_FILE = 252

_AUX_SECT const #

Auxiliary type

const _AUX_SECT = 250

_AUX_SYM const #

Auxiliary type

const _AUX_SYM = 253

Structs

Archive struct #

Archive represents an open AIX big archive.

type Archive struct {
ArchiveHeader
Members []*Member
closer io.Closer
}

ArchiveHeader struct #

ArchiveHeader holds information about a big archive file header

type ArchiveHeader struct {
magic string
}

AuxCSect32 struct #

csect Auxiliary Entry.

type AuxCSect32 struct {
Xscnlen uint32
Xparmhash uint32
Xsnhash uint16
Xsmtyp uint8
Xsmclas uint8
Xstab uint32
Xsnstab uint16
}

AuxCSect64 struct #

type AuxCSect64 struct {
Xscnlenlo uint32
Xparmhash uint32
Xsnhash uint16
Xsmtyp uint8
Xsmclas uint8
Xscnlenhi uint32
Xpad uint8
Xauxtype uint8
}

AuxFcn32 struct #

Function Auxiliary Entry

type AuxFcn32 struct {
Xexptr uint32
Xfsize uint32
Xlnnoptr uint32
Xendndx uint32
Xpad uint16
}

AuxFcn64 struct #

type AuxFcn64 struct {
Xlnnoptr uint64
Xfsize uint32
Xendndx uint32
Xpad uint8
Xauxtype uint8
}

AuxFile64 struct #

File Auxiliary Entry

type AuxFile64 struct {
Xfname [8]byte
Xftype uint8
Xauxtype uint8
}

AuxSect64 struct #

type AuxSect64 struct {
Xscnlen uint64
Xnreloc uint64
pad uint8
Xauxtype uint8
}

AuxiliaryCSect struct #

AuxiliaryCSect holds information about an XCOFF symbol in an AUX_CSECT entry.

type AuxiliaryCSect struct {
Length int64
StorageMappingClass int
SymbolType int
}

AuxiliaryFcn struct #

AuxiliaryFcn holds information about an XCOFF symbol in an AUX_FCN entry.

type AuxiliaryFcn struct {
Size int64
}

File struct #

A File represents an open XCOFF file.

type File struct {
FileHeader
Sections []*Section
Symbols []*Symbol
StringTable []byte
LibraryPaths []string
closer io.Closer
}

FileHeader struct #

FileHeader holds information about an XCOFF file header.

type FileHeader struct {
TargetMachine uint16
}

FileHeader32 struct #

File Header.

type FileHeader32 struct {
Fmagic uint16
Fnscns uint16
Ftimedat uint32
Fsymptr uint32
Fnsyms uint32
Fopthdr uint16
Fflags uint16
}

FileHeader64 struct #

type FileHeader64 struct {
Fmagic uint16
Fnscns uint16
Ftimedat uint32
Fsymptr uint64
Fopthdr uint16
Fflags uint16
Fnsyms uint32
}

ImportedSymbol struct #

ImportedSymbol holds information about an imported XCOFF symbol.

type ImportedSymbol struct {
Name string
Library string
}

LoaderHeader32 struct #

Loader Header.

type LoaderHeader32 struct {
Lversion uint32
Lnsyms uint32
Lnreloc uint32
Listlen uint32
Lnimpid uint32
Limpoff uint32
Lstlen uint32
Lstoff uint32
}

LoaderHeader64 struct #

type LoaderHeader64 struct {
Lversion uint32
Lnsyms uint32
Lnreloc uint32
Listlen uint32
Lnimpid uint32
Lstlen uint32
Limpoff uint64
Lstoff uint64
Lsymoff uint64
Lrldoff uint64
}

LoaderSymbol32 struct #

Loader Symbol.

type LoaderSymbol32 struct {
Lname [8]byte
Lvalue uint32
Lscnum uint16
Lsmtype uint8
Lsmclas uint8
Lifile uint32
Lparm uint32
}

LoaderSymbol64 struct #

type LoaderSymbol64 struct {
Lvalue uint64
Loffset uint32
Lscnum uint16
Lsmtype uint8
Lsmclas uint8
Lifile uint32
Lparm uint32
}

Member struct #

Member represents a member of an AIX big archive.

type Member struct {
MemberHeader
sr *io.SectionReader
}

MemberHeader struct #

MemberHeader holds information about a big archive member

type MemberHeader struct {
Name string
Size uint64
}

Reloc struct #

type Reloc struct {
VirtualAddress uint64
Symbol *Symbol
Signed bool
InstructionFixed bool
Length uint8
Type uint8
}

Reloc32 struct #

type Reloc32 struct {
Rvaddr uint32
Rsymndx uint32
Rsize uint8
Rtype uint8
}

Reloc64 struct #

type Reloc64 struct {
Rvaddr uint64
Rsymndx uint32
Rsize uint8
Rtype uint8
}

Section struct #

type Section struct {
SectionHeader
Relocs []Reloc
io.ReaderAt
sr *io.SectionReader
}

SectionHeader struct #

SectionHeader holds information about an XCOFF section header.

type SectionHeader struct {
Name string
VirtualAddress uint64
Size uint64
Type uint32
Relptr uint64
Nreloc uint32
}

SectionHeader32 struct #

Section Header.

type SectionHeader32 struct {
Sname [8]byte
Spaddr uint32
Svaddr uint32
Ssize uint32
Sscnptr uint32
Srelptr uint32
Slnnoptr uint32
Snreloc uint16
Snlnno uint16
Sflags uint32
}

SectionHeader64 struct #

type SectionHeader64 struct {
Sname [8]byte
Spaddr uint64
Svaddr uint64
Ssize uint64
Sscnptr uint64
Srelptr uint64
Slnnoptr uint64
Snreloc uint32
Snlnno uint32
Sflags uint32
Spad uint32
}

SymEnt32 struct #

Symbol Table Entry.

type SymEnt32 struct {
Nname [8]byte
Nvalue uint32
Nscnum uint16
Ntype uint16
Nsclass uint8
Nnumaux uint8
}

SymEnt64 struct #

type SymEnt64 struct {
Nvalue uint64
Noffset uint32
Nscnum uint16
Ntype uint16
Nsclass uint8
Nnumaux uint8
}

Symbol struct #

type Symbol struct {
Name string
Value uint64
SectionNumber int
StorageClass int
AuxFcn AuxiliaryFcn
AuxCSect AuxiliaryCSect
}

bigarFileHeader struct #

type bigarFileHeader struct {
Flmagic [SAIAMAG]byte
Flmemoff [20]byte
Flgstoff [20]byte
Flgst64off [20]byte
Flfstmoff [20]byte
Fllstmoff [20]byte
Flfreeoff [20]byte
}

bigarMemberHeader struct #

type bigarMemberHeader struct {
Arsize [20]byte
Arnxtmem [20]byte
Arprvmem [20]byte
Ardate [12]byte
Aruid [12]byte
Argid [12]byte
Armode [12]byte
Arnamlen [4]byte
}

nobitsSectionReader struct #

type nobitsSectionReader struct {

}

Functions

CSect method #

CSect reads and returns the contents of a csect.

func (f *File) CSect(name string) []byte

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

Close method #

Close closes the Archive. If the Archive was created using NewArchive directly instead of OpenArchive, Close has no effect.

func (a *Archive) Close() error

DWARF method #

func (f *File) DWARF() (*dwarf.Data, error)

Data method #

Data reads and returns the contents of the XCOFF section s.

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

GetFile method #

GetFile returns the XCOFF file defined by member name. FIXME: This doesn't work if an archive has two members with the same name which can occur if an archive has both 32-bits and 64-bits files.

func (arch *Archive) GetFile(name string) (*File, error)

ImportedLibraries method #

ImportedLibraries returns the names of all libraries referred to by the binary f that are expected to be linked with the binary at dynamic link time.

func (f *File) ImportedLibraries() ([]string, error)

ImportedSymbols method #

ImportedSymbols returns the names of all symbols referred to by the binary f that are expected to be satisfied by other libraries at dynamic load time. It does not return weak symbols.

func (f *File) ImportedSymbols() ([]ImportedSymbol, error)

NewArchive function #

NewArchive creates a new Archive for accessing an AIX big archive in an underlying reader.

func NewArchive(r io.ReaderAt) (*Archive, error)

NewFile function #

NewFile creates a new File for accessing an XCOFF binary in an underlying reader.

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

Open function #

Open opens the named file using os.Open and prepares it for use as an XCOFF binary.

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

OpenArchive function #

OpenArchive opens the named archive using os.Open and prepares it for use as an AIX big archive.

func OpenArchive(name string) (*Archive, error)

ReadAt method #

func (*nobitsSectionReader) ReadAt(p []byte, off int64) (n int, err error)

Section method #

Section returns the first section with the given name, or nil if no such section exists. Xcoff have section's name limited to 8 bytes. Some sections like .gosymtab can be trunked but this method will still find them.

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

SectionByType method #

SectionByType returns the first section in f with the given type, or nil if there is no such section.

func (f *File) SectionByType(typ uint32) *Section

cstring function #

cstring converts ASCII byte sequence b to string. It stops once it finds 0 or reaches end of b.

func cstring(b []byte) string

getString function #

getString extracts a string from an XCOFF string table.

func getString(st []byte, offset uint32) (string, bool)

readImportIDs method #

readImportID returns the import file IDs stored inside the .loader section. Library name pattern is either path/base/member or base/member

func (f *File) readImportIDs(s *Section) ([]string, error)

Generated with Arrow