Class GnuUtils

java.lang.Object
ghidra.app.cmd.data.rtti.gcc.GnuUtils

public final class GnuUtils
extends Object
Static Utility Class for GNU Binaries
  • Field Details

    • COMPILER_NAMES

      public static final Set<String> COMPILER_NAMES
  • Method Details

    • getCxxAbiCategoryPath

      public static CategoryPath getCxxAbiCategoryPath()
      Gets the "__cxxabiv1" CategoryPath
      Returns:
      the "__cxxabiv1" CategoryPath
    • isLLP64

      public static boolean isLLP64​(DataTypeManager dtm)
      Parameters:
      dtm - the programs datatype manager
      Returns:
      true if LLP64 was defined
    • getPtrDiff_t

      public static DataType getPtrDiff_t​(DataTypeManager dtm)
      Gets the appropriate TypeDefDataType for the builtin __PTRDIFF_TYPE__
      Parameters:
      dtm - the programs datatype manager
      Returns:
      the appropriate TypeDefDataType for the builtin __PTRDIFF_TYPE__
    • getPtrDiffSize

      public static int getPtrDiffSize​(DataTypeManager dtm)
      Gets the size in bytes of __PTRDIFF_TYPE__
      Parameters:
      dtm - the programs datatype manager
      Returns:
      the size in bytes of __PTRDIFF_TYPE__
    • getAllDataBlocks

      @Deprecated(forRemoval=true) public static List<MemoryBlock> getAllDataBlocks​(Program program)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets all MemoryBlocks in a Program which hold non-volatile data
      Parameters:
      program - the program to be searched
      Returns:
      A list of all memory blocks whose name contains "data" with non-volatile data
    • isDataBlock

      @Deprecated(forRemoval=true) public static boolean isDataBlock​(MemoryBlock block)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns true if this MemoryBlock has non-volatile data
      Parameters:
      block - the memory block to test
      Returns:
      true if this MemoryBlock has non-volatile data
    • hasFunctionDescriptors

      public static boolean hasFunctionDescriptors​(Program program)
      Checks if a Program's language is PowerPC64
      Parameters:
      program - the program to test
      Returns:
      true if the program's language is PowerPC64
    • isGnuCompiler

      public static boolean isGnuCompiler​(Program program)
      Checks if the Program was compiled by a GNU variant
      Parameters:
      program - the program to check
      Returns:
      true if compiled by a GNU variant
    • isFunctionPointer

      public static boolean isFunctionPointer​(Program program, Address address)
      Checks if a function pointer is located at the specified address
      Parameters:
      program - the program containing the data
      address - the address of the data
      Returns:
      true if a function pointer is located at the specified address
    • isNullPointer

      public static boolean isNullPointer​(Program program, Address address)
      Checks if a null pointer is located at the specified address
      Parameters:
      program - the program containing the data
      address - the address of the data
      Returns:
      true if a null pointer is located at the specified address
    • isNullPointer

      public static boolean isNullPointer​(MemBuffer buf)
      Checks if a null pointer is located at the specified address
      Parameters:
      buf - the memory buffer containing the data
      Returns:
      true if a null pointer is located at the specified address
    • isValidPointer

      public static boolean isValidPointer​(Program program, Address address)
      Checks if a valid pointer is located at the specified address
      Parameters:
      program - the program containing the data
      address - the address of the data
      Returns:
      true if a valid pointer is located at the specified address
    • isValidPointer

      public static boolean isValidPointer​(MemBuffer buf)
      Checks if a valid pointer is located at the specified address
      Parameters:
      buf - the memory buffer containing the data
      Returns:
      true if a valid pointer is located at the specified address
    • isDataPointer

      public static boolean isDataPointer​(MemBuffer buf)
      Checks if a valid pointer to a .*data section address is located at the specified address
      Parameters:
      buf - the memory buffer containing the data
      Returns:
      true if a valid data pointer is located at the specified address
    • getDirectDataReferences

      public static Set<Address> getDirectDataReferences​(Program program, Address address)
      Gets all direct data references to the specified address
      Parameters:
      program - the program containing the data
      address - the address of the data
      Returns:
      a set of all direct data references to the specified address
    • getDirectDataReferences

      public static Set<Address> getDirectDataReferences​(Program program, Address address, TaskMonitor monitor) throws CancelledException
      Gets all direct data references to the specified address
      Parameters:
      program - the program containing the data
      address - the address of the data
      monitor - the task monitor
      Returns:
      a set of all direct data references to the specified address
      Throws:
      CancelledException - if the search is cancelled
    • getExternalProgram

      public static Program getExternalProgram​(Program program, Relocation reloc)
      Attempts to get the Program containing the data for the relocation
      Parameters:
      program - the program containing the relocation
      reloc - the relocation
      Returns:
      the external program or null if not resolved
    • isExternal

      public static boolean isExternal​(Program program, Address address)
      Checks if the provided address is located within the "EXTERNAL" memory block.
      Parameters:
      program - the program containing the address
      address - the address to check
      Returns:
      true if it is an external address