Imports #
"debug/dwarf"
"encoding/binary"
"errors"
"fmt"
"internal/saferio"
"io"
"os"
"strings"
"encoding/binary"
"fmt"
"io"
"os"
"strconv"
"strings"
"debug/dwarf"
"encoding/binary"
"errors"
"fmt"
"internal/saferio"
"io"
"os"
"strings"
"encoding/binary"
"fmt"
"io"
"os"
"strconv"
"strings"
const AIAFMAG = "`\n"const AIAMAG = "\n" const AIAMAGBIG = "\n" const AR_HSZ_BIG = 0x70Storage Class.
const C_BCOMM = 135Storage Class.
const C_BINCL = 108Storage Class.
const C_BLOCK = 100Storage Class.
const C_BSTAT = 143Storage Class.
const C_DECL = 140Storage Class.
const C_DWARF = 112Storage Class.
const C_ECOML = 136Storage Class.
const C_ECOMM = 137Storage Class.
const C_EINCL = 109Storage Class.
const C_ENTRY = 141Storage Class.
const C_ESTAT = 144Storage Class.
const C_EXT = 2Storage Class.
const C_FCN = 101Storage Class.
const C_FILE = 103Storage Class.
const C_FUN = 142Storage Class.
const C_GSYM = 128Storage Class.
const C_GTLS = 145Storage Class.
const C_HIDEXT = 107Storage Class.
const C_LSYM = 129Storage Class.
const C_NULL = 0Storage Class.
const C_PSYM = 130Storage Class.
const C_RPSYM = 132Storage Class.
const C_RSYM = 131Storage Class.
const C_STAT = 3Storage Class.
const C_STSYM = 133Storage Class.
const C_STTLS = 146Storage Class.
const C_WEAKEXT = 111const FILHSZ_32 = 20const FILHSZ_64 = 24Sizeof
const FL_HSZ_BIG = 0x80Flags that describe the type of the object file.
const F_DSA = 0x0040Flags that describe the type of the object file.
const F_DYNLOAD = 0x1000Flags that describe the type of the object file.
const F_EXEC = 0x0002Flags that describe the type of the object file.
const F_FDPR_OPTI = 0x0020Flags that describe the type of the object file.
const F_FDPR_PROF = 0x0010Flags that describe the type of the object file.
const F_LNNO = 0x0004Flags that describe the type of the object file.
const F_LOADONLY = 0x4000Flags that describe the type of the object file.
const F_RELFLG = 0x0001Flags that describe the type of the object file.
const F_SHROBJ = 0x2000Flags that describe the type of the object file.
const F_VARPG = 0x0100const LDHDRSZ_32 = 32const LDHDRSZ_64 = 56const N_ABS = *ast.UnaryExprNscnum
const N_DEBUG = *ast.UnaryExprconst N_UNDEF = 0const R_BA = 0x08const R_BR = 0x0Aconst R_GL = 0x05const R_NEG = 0x01const R_POS = 0x00const R_RBA = 0x18const R_RBR = 0x1Aconst R_REF = 0x0Fconst R_REL = 0x02const R_RL = 0x0Cconst R_RLA = 0x0Dconst R_TCL = 0x06const R_TLS = 0x20const R_TLSM = 0x24const R_TLSML = 0x25const R_TLS_IE = 0x21const R_TLS_LD = 0x22const R_TLS_LE = 0x23const R_TOC = 0x03const R_TOCL = 0x31const R_TOCU = 0x30const R_TRL = 0x12const R_TRLA = 0x13const SAIAMAG = 0x8const SSUBTYP_DWABREV = 0x60000const SSUBTYP_DWARNGE = 0x50000const SSUBTYP_DWFRAME = 0xA0000const SSUBTYP_DWINFO = 0x10000const SSUBTYP_DWLINE = 0x20000const SSUBTYP_DWLOC = 0x90000const SSUBTYP_DWMAC = 0xB0000const SSUBTYP_DWPBNMS = 0x30000const SSUBTYP_DWPBTYP = 0x40000const SSUBTYP_DWRNGES = 0x80000const SSUBTYP_DWSTR = 0x70000Flags defining the section type.
const STYP_BSS = 0x0080Flags defining the section type.
const STYP_DATA = 0x0040Flags defining the section type.
const STYP_DEBUG = 0x2000Flags defining the section type.
const STYP_DWARF = 0x0010Flags defining the section type.
const STYP_EXCEPT = 0x0100Flags defining the section type.
const STYP_INFO = 0x0200Flags defining the section type.
const STYP_LOADER = 0x1000Flags defining the section type.
const STYP_OVRFLO = 0x8000Flags defining the section type.
const STYP_TBSS = 0x0800Flags defining the section type.
const STYP_TDATA = 0x0400Flags defining the section type.
const STYP_TEXT = 0x0020Flags defining the section type.
const STYP_TYPCHK = 0x4000const SYMESZ = 18const SYM_TYPE_FUNC = 0x0020const SYM_V_EXPORTED = 0x4000const SYM_V_HIDDEN = 0x2000Ntype
const SYM_V_INTERNAL = 0x1000const SYM_V_PROTECTED = 0x3000const U64_TOCMAGIC = 0767const U802TOCMAGIC = 0737Defines for File auxiliary definitions: x_ftype field of x_file
const XFT_CD = 128Defines for File auxiliary definitions: x_ftype field of x_file
const XFT_CT = 1Defines for File auxiliary definitions: x_ftype field of x_file
const XFT_CV = 2Defines for File auxiliary definitions: x_ftype field of x_file
const XFT_FN = 0Storage-mapping class.
const XMC_BS = 9Storage-mapping class.
const XMC_DB = 2Storage-mapping class.
const XMC_DS = 10Storage-mapping class.
const XMC_GL = 6Storage-mapping class.
const XMC_PR = 0Storage-mapping class.
const XMC_RO = 1Storage-mapping class.
const XMC_RW = 5Storage-mapping class.
const XMC_SV = 8Storage-mapping class.
const XMC_SV3264 = 18Storage-mapping class.
const XMC_SV64 = 17Storage-mapping class.
const XMC_TC = 3Storage-mapping class.
const XMC_TC0 = 15Storage-mapping class.
const XMC_TD = 16Storage-mapping class.
const XMC_TE = 22Storage-mapping class.
const XMC_TL = 20Storage-mapping class.
const XMC_UA = 4Storage-mapping class.
const XMC_UC = 11Storage-mapping class.
const XMC_UL = 21Storage-mapping class.
const XMC_XO = 7Symbol type field.
const XTY_CM = 3Symbol type field.
const XTY_ER = 0Symbol type field.
const XTY_LD = 2Symbol type field.
const XTY_SD = 1Auxiliary type
const _AUX_CSECT = 251Auxiliary type
const _AUX_EXCEPT = 255Auxiliary type
const _AUX_FCN = 254Auxiliary type
const _AUX_FILE = 252Auxiliary type
const _AUX_SECT = 250Auxiliary type
const _AUX_SYM = 253Archive represents an open AIX big archive.
type Archive struct {
ArchiveHeader
Members []*Member
closer io.Closer
}ArchiveHeader holds information about a big archive file header
type ArchiveHeader struct {
magic string
}csect Auxiliary Entry.
type AuxCSect32 struct {
Xscnlen uint32
Xparmhash uint32
Xsnhash uint16
Xsmtyp uint8
Xsmclas uint8
Xstab uint32
Xsnstab uint16
}type AuxCSect64 struct {
Xscnlenlo uint32
Xparmhash uint32
Xsnhash uint16
Xsmtyp uint8
Xsmclas uint8
Xscnlenhi uint32
Xpad uint8
Xauxtype uint8
}Function Auxiliary Entry
type AuxFcn32 struct {
Xexptr uint32
Xfsize uint32
Xlnnoptr uint32
Xendndx uint32
Xpad uint16
}type AuxFcn64 struct {
Xlnnoptr uint64
Xfsize uint32
Xendndx uint32
Xpad uint8
Xauxtype uint8
}File Auxiliary Entry
type AuxFile64 struct {
Xfname [8]byte
Xftype uint8
Xauxtype uint8
}type AuxSect64 struct {
Xscnlen uint64
Xnreloc uint64
pad uint8
Xauxtype uint8
}AuxiliaryCSect holds information about an XCOFF symbol in an AUX_CSECT entry.
type AuxiliaryCSect struct {
Length int64
StorageMappingClass int
SymbolType int
}AuxiliaryFcn holds information about an XCOFF symbol in an AUX_FCN entry.
type AuxiliaryFcn struct {
Size int64
}A File represents an open XCOFF file.
type File struct {
FileHeader
Sections []*Section
Symbols []*Symbol
StringTable []byte
LibraryPaths []string
closer io.Closer
}FileHeader holds information about an XCOFF file header.
type FileHeader struct {
TargetMachine uint16
}File Header.
type FileHeader32 struct {
Fmagic uint16
Fnscns uint16
Ftimedat uint32
Fsymptr uint32
Fnsyms uint32
Fopthdr uint16
Fflags uint16
}type FileHeader64 struct {
Fmagic uint16
Fnscns uint16
Ftimedat uint32
Fsymptr uint64
Fopthdr uint16
Fflags uint16
Fnsyms uint32
}ImportedSymbol holds information about an imported XCOFF symbol.
type ImportedSymbol struct {
Name string
Library string
}Loader Header.
type LoaderHeader32 struct {
Lversion uint32
Lnsyms uint32
Lnreloc uint32
Listlen uint32
Lnimpid uint32
Limpoff uint32
Lstlen uint32
Lstoff uint32
}type LoaderHeader64 struct {
Lversion uint32
Lnsyms uint32
Lnreloc uint32
Listlen uint32
Lnimpid uint32
Lstlen uint32
Limpoff uint64
Lstoff uint64
Lsymoff uint64
Lrldoff uint64
}Loader Symbol.
type LoaderSymbol32 struct {
Lname [8]byte
Lvalue uint32
Lscnum uint16
Lsmtype uint8
Lsmclas uint8
Lifile uint32
Lparm uint32
}type LoaderSymbol64 struct {
Lvalue uint64
Loffset uint32
Lscnum uint16
Lsmtype uint8
Lsmclas uint8
Lifile uint32
Lparm uint32
}Member represents a member of an AIX big archive.
type Member struct {
MemberHeader
sr *io.SectionReader
}MemberHeader holds information about a big archive member
type MemberHeader struct {
Name string
Size uint64
}type Reloc struct {
VirtualAddress uint64
Symbol *Symbol
Signed bool
InstructionFixed bool
Length uint8
Type uint8
}type Reloc32 struct {
Rvaddr uint32
Rsymndx uint32
Rsize uint8
Rtype uint8
}type Reloc64 struct {
Rvaddr uint64
Rsymndx uint32
Rsize uint8
Rtype uint8
}type Section struct {
SectionHeader
Relocs []Reloc
io.ReaderAt
sr *io.SectionReader
}SectionHeader holds information about an XCOFF section header.
type SectionHeader struct {
Name string
VirtualAddress uint64
Size uint64
Type uint32
Relptr uint64
Nreloc uint32
}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
}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
}Symbol Table Entry.
type SymEnt32 struct {
Nname [8]byte
Nvalue uint32
Nscnum uint16
Ntype uint16
Nsclass uint8
Nnumaux uint8
}type SymEnt64 struct {
Nvalue uint64
Noffset uint32
Nscnum uint16
Ntype uint16
Nsclass uint8
Nnumaux uint8
}type Symbol struct {
Name string
Value uint64
SectionNumber int
StorageClass int
AuxFcn AuxiliaryFcn
AuxCSect AuxiliaryCSect
}type bigarFileHeader struct {
Flmagic [SAIAMAG]byte
Flmemoff [20]byte
Flgstoff [20]byte
Flgst64off [20]byte
Flfstmoff [20]byte
Fllstmoff [20]byte
Flfreeoff [20]byte
}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
}type nobitsSectionReader struct {
}CSect reads and returns the contents of a csect.
func (f *File) CSect(name string) []byteClose closes the File. If the File was created using NewFile directly instead of Open, Close has no effect.
func (f *File) Close() errorClose closes the Archive. If the Archive was created using NewArchive directly instead of OpenArchive, Close has no effect.
func (a *Archive) Close() errorfunc (f *File) DWARF() (*dwarf.Data, error)Data reads and returns the contents of the XCOFF section s.
func (s *Section) Data() ([]byte, error)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 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 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 creates a new Archive for accessing an AIX big archive in an underlying reader.
func NewArchive(r io.ReaderAt) (*Archive, error)NewFile creates a new File for accessing an XCOFF binary in an underlying reader.
func NewFile(r io.ReaderAt) (*File, error)Open opens the named file using os.Open and prepares it for use as an XCOFF binary.
func Open(name string) (*File, error)OpenArchive opens the named archive using os.Open and prepares it for use as an AIX big archive.
func OpenArchive(name string) (*Archive, error)func (*nobitsSectionReader) ReadAt(p []byte, off int64) (n int, err error)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) *SectionSectionByType returns the first section in f with the given type, or nil if there is no such section.
func (f *File) SectionByType(typ uint32) *Sectioncstring converts ASCII byte sequence b to string. It stops once it finds 0 or reaches end of b.
func cstring(b []byte) stringgetString extracts a string from an XCOFF string table.
func getString(st []byte, offset uint32) (string, bool)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