Documentation ¶
Overview ¶
Package earpointer introduces a pointer analysis based on unifying equivalent abstract references (EAR), which implements Steensgaard's algorithm. Extensions include adding context sensitivity and field sensitivity. Abstract references defines the data structure to represent abstract heap.
Index ¶
- Variables
- func NewState() *state
- type Context
- type Field
- type FieldMap
- type Global
- type Local
- type Partitions
- func (p *Partitions) FieldParents(ref Reference) []Reference
- func (p *Partitions) Has(ref Reference) bool
- func (p *Partitions) MembersForRep(rep Reference) []Reference
- func (p *Partitions) NumPartitions() int
- func (p *Partitions) PartitionFieldMap(ref Reference) FieldMap
- func (p *Partitions) PartitionMembers(ref Reference) []Reference
- func (p *Partitions) References() ReferenceSet
- func (p *Partitions) Representative(ref Reference) Reference
- func (p *Partitions) Representatives() ReferenceSet
- func (p *Partitions) String() string
- type Reference
- type ReferenceSet
- type SourceSinkTrace
- type Synthetic
- type SyntheticKind
Constants ¶
This section is empty.
Variables ¶
var Analyzer = &analysis.Analyzer{ Name: "earpointer", Doc: "EAR pointer analysis", Flags: config.FlagSet, Run: run, ResultType: reflect.TypeOf(new(Partitions)), Requires: []*analysis.Analyzer{buildssa.Analyzer}, }
Analyzer traverses the packages and constructs an EAR partitions unifying all the IR elements in these packages.
Functions ¶
Types ¶
type Context ¶
type Context []ssa.Instruction
Context represents the calling context of a reference. Typically, it contains a stack of call instructions.
type Field ¶
type Field struct { Name string // contains filtered or unexported fields }
Field can be (1) a struct field linked to an IR field (Var); (2) or one with a name but not linked to any IR element (irField = nil).
type FieldMap ¶
FieldMap maps from Fields to a reference handle. It is used for maintaining points-to relationships for the fields of a reference partition. The number of fields is not expected to be high on average, so a tree map may be used instead to save memory.
type Global ¶
type Global struct {
// contains filtered or unexported fields
}
Global is a heap partition that represents all abstract objects that a global of reference type can point to.
func MakeGlobal ¶
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local is a heap partition that represents all abstract objects that a register of reference type can point to in a specific context.
func MakeLocal ¶
Constructs Reference for local "reg" in context "context". TODO: hashconst the object to save memory.
type Partitions ¶
type Partitions struct {
// contains filtered or unexported fields
}
Partitions represents the state with the partitions fully constructed, after which no more mutation operations will be performed. Its internal data structures are optimized for lookups only.
func (*Partitions) FieldParents ¶
func (p *Partitions) FieldParents(ref Reference) []Reference
FieldParents returns the parents of a field reference. Return nil if ref has no parent. For example, return o for r if "o[x -> r]" is in partitions. This shall be called only after the partitions have been finalized.
func (*Partitions) Has ¶
func (p *Partitions) Has(ref Reference) bool
Has returns true if "ref" is a reference present in the partitions.
func (*Partitions) MembersForRep ¶
func (p *Partitions) MembersForRep(rep Reference) []Reference
MembersForRep gets the list of members in the partition for which "prep" is the representative. Precondition: "prep" must be a partition representative.
func (*Partitions) NumPartitions ¶
func (p *Partitions) NumPartitions() int
NumPartitions returns the number of representatives (i.e., the size of the partition).
func (*Partitions) PartitionFieldMap ¶
func (p *Partitions) PartitionFieldMap(ref Reference) FieldMap
PartitionFieldMap gets the partition-level field map for partition representative "ref". The result maps a field (ConstTermHandle type) to a reference that is a partition representative. Note "ref" must be a partition representative.
func (*Partitions) PartitionMembers ¶
func (p *Partitions) PartitionMembers(ref Reference) []Reference
PartitionMembers gets the list of members in the partition to which "ref" belongs. Precondition: "ref" must be a reference present in the partitions.
func (*Partitions) References ¶
func (p *Partitions) References() ReferenceSet
References gets all references.
func (*Partitions) Representative ¶
func (p *Partitions) Representative(ref Reference) Reference
Representative gets the partition representative of reference "ref" ("ref" must belong to this partitions).
func (*Partitions) Representatives ¶
func (p *Partitions) Representatives() ReferenceSet
Representatives gets all references that are partition representatives.
type Reference ¶
type Reference interface { fmt.Stringer Type() types.Type // Return the data type of the underlying element Value() ssa.Value // Return the underlying local or global }
Reference is the base interface for local, global, and synthetic references.
type SourceSinkTrace ¶ added in v0.1.6
func SourcesToSinks ¶ added in v0.1.6
func SourcesToSinks(funcSources source.ResultType, isTaintField func(named *types.Named, index int) bool, heap *Partitions, conf *config.Config) []*SourceSinkTrace
Look for <source, sink> pairs by examining the heap alias information.
type Synthetic ¶
type Synthetic struct {
// contains filtered or unexported fields
}
Synthetic is for references created internally with an operator and an operand reference. It is for creating references not directly associated with an IR element. For example, (1) *r0 can be represented by using operator SyntheticValueOf (*); (2) a unknown field can be represented by using operator SyntheticField.
For example, when a struct is cloned, some fields may not appear in the IR, these "unused" fields can be synthesized and stored in the heap.
func MakeSynthetic ¶
func MakeSynthetic(kind SyntheticKind, ref Reference) Synthetic
Constructs synthetic reference.
type SyntheticKind ¶
type SyntheticKind int
const ( SyntheticValueOf SyntheticKind = iota SyntheticField )