csym

package
v0.0.0-...-546480d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2022 License: Unlicense Imports: 6 Imported by: 0

Documentation

Overview

Package csym translates Playstation 1 symbol information to C declarations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SliceIndex

func SliceIndex(limit int, predicate func(i int) bool) int

SliceIndex returns index within slece for which the func returns true

func UniqueEnumTag

func UniqueEnumTag(EnumTags map[string][]*c.EnumType, t *c.EnumType) string

UniqueEnumTag returns a unique enum tag based on the given enum and set of present enums mapped by tags.

func UniqueFuncName

func UniqueFuncName(funcNames map[string][]*c.FuncDecl, f *c.FuncDecl) string

UniqueFuncName returns a unique function name based on the given function and set of present functions mapped by names.

func UniqueName

func UniqueName(name string, addr uint32) string

UniqueName returns a unique name based on the given name and address.

func UniqueStructTag

func UniqueStructTag(structTags map[string][]*c.StructType, t *c.StructType) string

UniqueStructTag returns a unique struct tag based on the given struct and set of present structs mapped by tags.

func UniqueTag

func UniqueTag(tag string, typ string, idx int) string

UniqueTag returns a unique tag based on the given tag and duplicate index.

func UniqueUnionTag

func UniqueUnionTag(unionTags map[string][]*c.UnionType, t *c.UnionType) string

UniqueUnionTag returns a unique union tag based on the given union and set of present unions mapped by tags.

func UniqueVarName

func UniqueVarName(varNames map[string][]*c.VarDecl, v *c.VarDecl) string

UniqueVarName returns a unique variable name based on the given variable and set of present variables mapped by names.

Types

type Line

type Line struct {
	// Address.
	Addr uint32
	// Source file name.
	Path string
	// Line number.
	Line uint32
}

A Line associates a line number in a source file with an address.

type Overlay

type Overlay struct {
	// Base address at which the overlay is loaded.
	Addr uint32
	// Overlay ID.
	ID uint32
	// Overlay length in bytes.
	Length uint32

	// Variable delcarations.
	Vars []*c.VarDecl
	// Function delcarations.
	Funcs []*c.FuncDecl

	// Symbols.
	Symbols []*Symbol
	// Source file line numbers.
	Lines []*Line
	// contains filtered or unexported fields
}

An Overlay is an overlay appended to the end of the executable.

type Parser

type Parser struct {

	// Struct maps from struct tag to struct types.
	StructTags map[string][]*c.StructType
	// Unions maps from union tag to union types.
	UnionTags map[string][]*c.UnionType
	// Enums maps from enum tag to enum types.
	EnumTags map[string][]*c.EnumType
	// types maps from type name to underlying type definition.
	Types map[string]c.Type
	// Structs in order of occurrence in SYM file.
	Structs []*c.StructType
	// Unions in order of occurrence in SYM file.
	Unions []*c.UnionType
	// Enums in order of occurrence in SYM file.
	Enums []*c.EnumType
	// Type definitions in order of occurrence in SYM file.
	Typedefs []c.Type

	// Declarations.
	*Overlay // default binary

	// Overlays.
	Overlays []*Overlay
	// contains filtered or unexported fields
}

Parser tracks type information used for parsing.

func NewParser

func NewParser(opts *sym.Options) *Parser

NewParser returns a new parser.

func (*Parser) AddEnum

func (p *Parser) AddEnum(t *c.EnumType) *c.EnumType

AddEnum adds the type instance to lists within parser

func (*Parser) AddStruct

func (p *Parser) AddStruct(t *c.StructType) *c.StructType

AddStruct adds the type instance to lists within parser

func (*Parser) AddUnion

func (p *Parser) AddUnion(t *c.UnionType) *c.UnionType

AddUnion adds the type instance to lists within parser

func (*Parser) MakeNamesUnique

func (p *Parser) MakeNamesUnique()

MakeNamesUnique goes through parsed symbols and renames duplicate names.

func (*Parser) ParseDecls

func (p *Parser) ParseDecls(syms []*sym.Symbol)

ParseDecls parses the symbols into the equivalent C declarations.

func (*Parser) ParseTypes

func (p *Parser) ParseTypes(syms []*sym.Symbol)

ParseTypes parses the SYM types into the equivalent C types.

func (*Parser) RemoveDuplicateTypes

func (p *Parser) RemoveDuplicateTypes()

RemoveDuplicateTypes goes through parsed types and marks exact duplicates.

func (*Parser) ReplaceEnums

func (p *Parser) ReplaceEnums(typeRemap map[c.Type]c.Type)

ReplaceEnums replaces types with another in lists within parser It does not replace use of the enum in other types

func (*Parser) ReplaceStructs

func (p *Parser) ReplaceStructs(typeRemap map[c.Type]c.Type)

ReplaceStructs replaces types with another in lists within parser It does not replace use of the struct in other types

func (*Parser) ReplaceUnions

func (p *Parser) ReplaceUnions(typeRemap map[c.Type]c.Type)

ReplaceUnions replaces types with another in lists within parser It does not replace use of the union in other types

func (*Parser) ReplaceUsedTypes

func (p *Parser) ReplaceUsedTypes(typeRemap map[c.Type]c.Type)

func (*Parser) RmNilEnums

func (p *Parser) RmNilEnums()

func (*Parser) RmNilStructs

func (p *Parser) RmNilStructs()

func (*Parser) RmNilUnions

func (p *Parser) RmNilUnions()

type Symbol

type Symbol struct {
	// Symbol address.
	Addr uint32
	// Symbol name.
	Name string
}

A Symbol associates a symbol name with an address.

Directories

Path Synopsis
c
Package c provides an AST for a subset of C.
Package c provides an AST for a subset of C.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL