Package ghidra.program.model.pcode

# Class GlobalSymbolMap

java.lang.Object
ghidra.program.model.pcode.GlobalSymbolMap

public class GlobalSymbolMap extends Object
A container for global symbols in the decompiler's model of a function. It contains HighSymbol objects for any symbol accessed by the particular function that is in either the global scope or some other global namespace. Currently the container is populated indirectly from the HighGlobal objects marshaled back from the decompiler, using either the populateSymbol() or newSymbol() methods. HighSymbols are stored by Address and by id, which matches the formal SymbolDB id when it exists.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GlobalSymbolMap(HighFunction f)`
  Construct a global symbol map attached to a particular function model.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `HighSymbol`
  `getSymbol(long id)`
  Retrieve a HighSymbol based on an id
  `HighSymbol`
  `getSymbol(Address addr)`
  Retrieve a HighSymbol based on an Address
  `Iterator<HighSymbol>`
  `getSymbols()`
  Get an iterator over all HighSymbols in this container
  `HighCodeSymbol`
  `newSymbol(long id, Address addr, DataType dataType, int sz)`
  Create a HighSymbol corresponding to an underlying Data object.
  `void`
  `populateAnnotation(Varnode vn)`
  Some Varnode annotations refer to global symbols.
  `HighSymbol`
  `populateSymbol(long id, DataType dataType, int sz)`
  Create a HighSymbol based on the id of the underlying Ghidra Symbol.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### GlobalSymbolMap

    public GlobalSymbolMap(HighFunction f)
    Construct a global symbol map attached to a particular function model.
    Parameters:
      `f` - is the decompiler function model

- ## Method Details

  - ### populateSymbol

    public HighSymbol populateSymbol(long id, DataType dataType, int sz)
    Create a HighSymbol based on the id of the underlying Ghidra Symbol. The Symbol is looked up in the SymbolTable and then a HighSymbol is created with the name and dataType associated with the Symbol. If a Symbol cannot be found, null is returned.
    Parameters:
      `id` - is the database id of the CodeSymbol
      `dataType` - is the recovered data-type of the symbol
      `sz` - is the size in bytes of the desired symbol
    Returns:
      the CodeSymbol wrapped as a HighSymbol or null

  - ### populateAnnotation

    public void populateAnnotation(Varnode vn)
    Some Varnode annotations refer to global symbols. Check if there is symbol at the Varnode address and, if there is, create a corresponding HighSymbol
    Parameters:
      `vn` - is the annotation Varnode

  - ### newSymbol

    public HighCodeSymbol newSymbol(long id, Address addr, DataType dataType, int sz)
    Create a HighSymbol corresponding to an underlying Data object. The name of the symbol is generated dynamically. A symbol is always returned unless the address is invalid, in which case null is returned.
    Parameters:
      `id` - is the id to associate with the new symbol
      `addr` - is the address of the Data object
      `dataType` - is the recovered data-type of the symbol
      `sz` - is the size in bytes of the symbol
    Returns:
      the new HighSymbol or null

  - ### getSymbol

    public HighSymbol getSymbol(long id)
    Retrieve a HighSymbol based on an id
    Parameters:
      `id` - is the id
    Returns:
      the matching HighSymbol or null

  - ### getSymbol

    public HighSymbol getSymbol(Address addr)
    Retrieve a HighSymbol based on an Address
    Parameters:
      `addr` - is the given Address
    Returns:
      the matching HighSymbol or null

  - ### getSymbols

    public Iterator<HighSymbol> getSymbols()
    Get an iterator over all HighSymbols in this container
    Returns:
      the iterator