Package ghidra.program.model.address

# Class GlobalSymbol

java.lang.Object
ghidra.program.model.address.GlobalSymbol

All Implemented Interfaces:
  `Symbol`

public class GlobalSymbol extends Object implements Symbol
The global symbol implementation class

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `delete()`
  Delete the symbol and its associated resources.
  `boolean`
  `equals(Object obj)`
  `Address`
  `getAddress()`
  `Reference[]`
  `getAssociatedReferences()`
  `long`
  `getID()`
  `String`
  `getName()`
  `String`
  `getName(boolean includeNamespace)`
  Returns the symbol name, optionally prepended with the namespace path.
  `Object`
  `getObject()`
  `Namespace`
  `getParentNamespace()`
  Return the parent namespace for this symbol.
  `Symbol`
  `getParentSymbol()`
  Returns namespace symbol of the namespace containing this symbol
  `String[]`
  `getPath()`
  Gets the full path name for this symbol as an ordered array of strings ending with the symbol name.
  `Program`
  `getProgram()`
  Get the program associated with this symbol
  `ProgramLocation`
  `getProgramLocation()`
  `int`
  `getReferenceCount()`
  `Reference[]`
  `getReferences()`
  Returns all memory references to the address of this symbol.
  `Reference[]`
  `getReferences(TaskMonitor monitor)`
  Returns all memory references to the address of this symbol.
  `SourceType`
  `getSource()`
  This method doesn't apply to the global symbol, since a program always has a global symbol and it can't be renamed.
  `SymbolType`
  `getSymbolType()`
  Returns this symbol's type
  `int`
  `hashCode()`
  `boolean`
  `hasMultipleReferences()`
  `boolean`
  `hasReferences()`
  `boolean`
  `isDeleted()`
  Determine if this symbol object has been deleted.
  `boolean`
  `isDescendant(Namespace namespace)`
  Returns true if the given namespace symbol is a descendant of this symbol.
  `boolean`
  `isDynamic()`
  `boolean`
  `isExternal()`
  Returns true if this an external symbol.
  `boolean`
  `isExternalEntryPoint()`
  `boolean`
  `isGlobal()`
  `boolean`
  `isPinned()`
  This returns false, since the global symbol isn't associated with a specific program memory address.
  `boolean`
  `isPrimary()`
  `boolean`
  `isValidParent(Namespace parent)`
  Determines if the given parent is valid for this Symbol.
  `void`
  `setName(String newName, SourceType source)`
  Sets the name this symbol.
  `void`
  `setNameAndNamespace(String newName, Namespace newNamespace, SourceType source)`
  Sets the symbols name and namespace.
  `void`
  `setNamespace(Namespace newNamespace)`
  Sets the symbols namespace
  `void`
  `setPinned(boolean pinned)`
  This method doesn't apply to the global symbol, since it isn't associated with a specific program memory address.
  `boolean`
  `setPrimary()`
  Sets this symbol to be primary.
  `void`
  `setSource(SourceType source)`
  This method doesn't apply to the global symbol, since a program always has a global symbol and it can't be renamed.

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

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

- ## Method Details

  - ### isDeleted

    public boolean isDeleted()
    Description copied from interface: `Symbol`
    Determine if this symbol object has been deleted. NOTE: the symbol could be deleted at anytime due to asynchronous activity.
    Specified by:
      `isDeleted` in interface `Symbol`
    Returns:
      true if symbol has been deleted, false if not.

  - ### isExternal

    public boolean isExternal()
    Description copied from interface: `Symbol`
    Returns true if this an external symbol.
    Specified by:
      `isExternal` in interface `Symbol`
    Returns:
      true if this an external symbol.
    See Also:
      - `Address.isExternalAddress()`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### getAddress

    public Address getAddress()
    Specified by:
      `getAddress` in interface `Symbol`
    Returns:
      the address for the symbol.

  - ### getProgram

    public Program getProgram()
    Description copied from interface: `Symbol`
    Get the program associated with this symbol
    Specified by:
      `getProgram` in interface `Symbol`
    Returns:
      the program associated with this symbol.

  - ### getName

    public String getName()
    Specified by:
      `getName` in interface `Symbol`
    Returns:
      the name of this symbol.

  - ### getName

    public String getName(boolean includeNamespace)
    Description copied from interface: `Symbol`
    Returns the symbol name, optionally prepended with the namespace path.
    Specified by:
      `getName` in interface `Symbol`
    Parameters:
      `includeNamespace` - if true, the namespace path is prepended to the name.
    Returns:
      formatted name

  - ### getPath

    public String[] getPath()
    Description copied from interface: `Symbol`
    Gets the full path name for this symbol as an ordered array of strings ending with the symbol name. The global symbol will return an empty array.
    Specified by:
      `getPath` in interface `Symbol`
    Returns:
      the array indicating the full path name for this symbol.

  - ### getParentNamespace

    public Namespace getParentNamespace()
    Description copied from interface: `Symbol`
    Return the parent namespace for this symbol.
    Specified by:
      `getParentNamespace` in interface `Symbol`
    Returns:
      the namespace that contains this symbol.

  - ### getParentSymbol

    public Symbol getParentSymbol()
    Description copied from interface: `Symbol`
    Returns namespace symbol of the namespace containing this symbol
    Specified by:
      `getParentSymbol` in interface `Symbol`
    Returns:
      parent namespace symbol

  - ### isDescendant

    public boolean isDescendant(Namespace namespace)
    Description copied from interface: `Symbol`
    Returns true if the given namespace symbol is a descendant of this symbol.
    Specified by:
      `isDescendant` in interface `Symbol`
    Parameters:
      `namespace` - to test as descendant symbol of this Symbol
    Returns:
      true if this symbol is an ancestor of the given namespace symbol

  - ### isValidParent

    public boolean isValidParent(Namespace parent)
    Description copied from interface: `Symbol`
    Determines if the given parent is valid for this Symbol. Specified namespace must belong to the same symbol table as this symbol.
    Specified by:
      `isValidParent` in interface `Symbol`
    Parameters:
      `parent` - prospective parent namespace for this symbol
    Returns:
      true if parent is valid

  - ### getSymbolType

    public SymbolType getSymbolType()
    Description copied from interface: `Symbol`
    Returns this symbol's type
    Specified by:
      `getSymbolType` in interface `Symbol`
    Returns:
      symbol type

  - ### getReferenceCount

    public int getReferenceCount()
    Specified by:
      `getReferenceCount` in interface `Symbol`
    Returns:
      the number of References to this symbol.

  - ### hasMultipleReferences

    public boolean hasMultipleReferences()
    Specified by:
      `hasMultipleReferences` in interface `Symbol`
    Returns:
      true if this symbol has more than one reference to it.

  - ### hasReferences

    public boolean hasReferences()
    Specified by:
      `hasReferences` in interface `Symbol`
    Returns:
      true if this symbol has at least one reference to it.

  - ### getReferences

    public Reference[] getReferences()
    Description copied from interface: `Symbol`
    Returns all memory references to the address of this symbol.
    Specified by:
      `getReferences` in interface `Symbol`
    Returns:
      all memory references to the address of this symbol
    See Also:
      - `Symbol.getReferences(TaskMonitor)`

  - ### getReferences

    public Reference[] getReferences(TaskMonitor monitor)
    Description copied from interface: `Symbol`
    Returns all memory references to the address of this symbol. If you do not have a `TaskMonitor` instance, then you can pass `TaskMonitor.DUMMY` or `null`.
    Specified by:
      `getReferences` in interface `Symbol`
    Parameters:
      `monitor` - the monitor that is used to report progress and to cancel this potentially long-running call
    Returns:
      all memory references to the address of this symbol.

  - ### getAssociatedReferences

    public Reference[] getAssociatedReferences()

  - ### getProgramLocation

    public ProgramLocation getProgramLocation()
    Specified by:
      `getProgramLocation` in interface `Symbol`
    Returns:
      a program location corresponding to this symbol

  - ### setName

    public void setName(String newName, SourceType source) throws DuplicateNameException, InvalidInputException
    Description copied from interface: `Symbol`
    Sets the name this symbol. If this symbol is dynamic, then the name is set and the symbol is no longer dynamic.
    Specified by:
      `setName` in interface `Symbol`
    Parameters:
      `newName` - the new name for this symbol.
      `source` - the source of this symbol
      Some symbol types, such as function symbols, can set the source to Symbol.DEFAULT.
    Throws:
      `DuplicateNameException` - if name already exists as the name of another symbol or alias.
      `InvalidInputException` - if alias contains blank characters, is zero length, or is null

  - ### delete

    public boolean delete()
    Description copied from interface: `Symbol`
    Delete the symbol and its associated resources. Any references symbol associations will be discarded.
    Specified by:
      `delete` in interface `Symbol`
    Returns:
      true if successful

  - ### isPinned

    public boolean isPinned()
    This returns false, since the global symbol isn't associated with a specific program memory address.
    Specified by:
      `isPinned` in interface `Symbol`
    Returns:
      true if the symbol is pinned to its current address.

  - ### setPinned

    public void setPinned(boolean pinned)
    This method doesn't apply to the global symbol, since it isn't associated with a specific program memory address. Therefore calling it will have no effect.
    Specified by:
      `setPinned` in interface `Symbol`
    Parameters:
      `pinned` - true indicates this symbol is anchored to its address. false indicates this symbol is not anchored to its address.

  - ### setSource

    public void setSource(SourceType source)
    This method doesn't apply to the global symbol, since a program always has a global symbol and it can't be renamed. Therefore calling it will throw an UnsupportedOperationException.
    Specified by:
      `setSource` in interface `Symbol`
    Parameters:
      `source` - the source of this symbol: Symbol.DEFAULT, Symbol.IMPORTED, Symbol.ANALYSIS, or Symbol.USER_DEFINED.
    Throws:
      `UnsupportedOperationException` - whenever called.

  - ### getSource

    public SourceType getSource()
    This method doesn't apply to the global symbol, since a program always has a global symbol and it can't be renamed. Therefore calling it will throw an UnsupportedOperationException. return source the source of this symbol: default, imported, analysis, or user defined.
    Specified by:
      `getSource` in interface `Symbol`
    Returns:
      the source of this symbol
    Throws:
      `UnsupportedOperationException` - whenever called.

  - ### isDynamic

    public boolean isDynamic()
    Specified by:
      `isDynamic` in interface `Symbol`
    Returns:
      true if this symbol is a dynamic symbol (not actually defined in the database).

  - ### isPrimary

    public boolean isPrimary()
    Specified by:
      `isPrimary` in interface `Symbol`
    Returns:
      true if this symbol is primary

  - ### setPrimary

    public boolean setPrimary()
    Description copied from interface: `Symbol`
    Sets this symbol to be primary. All other symbols at the same address will be set to !primary. Only applies to non-function symbols.
    Specified by:
      `setPrimary` in interface `Symbol`
    Returns:
      returns true if the symbol was not primary and now it is, otherwise false

  - ### isExternalEntryPoint

    public boolean isExternalEntryPoint()
    Specified by:
      `isExternalEntryPoint` in interface `Symbol`
    Returns:
      true if the symbol is at an address set as a external entry point.

  - ### getID

    public long getID()
    Specified by:
      `getID` in interface `Symbol`
    Returns:
      this symbol's ID.

  - ### getObject

    public Object getObject()
    Specified by:
      `getObject` in interface `Symbol`
    Returns:
      object associated with this symbol or null if symbol has been deleted

  - ### setNamespace

    public void setNamespace(Namespace newNamespace) throws DuplicateNameException, InvalidInputException, CircularDependencyException
    Description copied from interface: `Symbol`
    Sets the symbols namespace
    Specified by:
      `setNamespace` in interface `Symbol`
    Parameters:
      `newNamespace` - new parent namespace
    Throws:
      `DuplicateNameException` - if newNamespace already contains a symbol with this symbol's name
      `InvalidInputException` - is newNamespace is not a valid parent for this symbol
      `CircularDependencyException` - if this symbol is an ancestor of newNamespace

  - ### setNameAndNamespace

    public void setNameAndNamespace(String newName, Namespace newNamespace, SourceType source) throws DuplicateNameException, InvalidInputException, CircularDependencyException
    Description copied from interface: `Symbol`
    Sets the symbols name and namespace. This is provided to allow the caller to avoid a name conflict by creating an autonomous action.
    Specified by:
      `setNameAndNamespace` in interface `Symbol`
    Parameters:
      `newName` - new symbol name
      `newNamespace` - new parent namespace
      `source` - the source of this symbol
      Some symbol types, such as function symbols, can set the source to Symbol.DEFAULT.
    Throws:
      `DuplicateNameException` - if newNamespace already contains a symbol with this symbol's name
      `InvalidInputException` - is newNamespace is not a valid parent for this symbol
      `CircularDependencyException` - if this symbol is an ancestor of newNamespace

  - ### isGlobal

    public boolean isGlobal()
    Specified by:
      `isGlobal` in interface `Symbol`
    Returns:
      true if the symbol is global