Interface CompilerSpec

  • All Known Implementing Classes:
    BasicCompilerSpec, ProgramCompilerSpec

    public interface CompilerSpec
    Interface for requesting specific information about the compiler used to build a Program being analyzed. Major elements that can be queried include: - AddressSpaces from the Language plus compiler specific ones like "stack" - DataOrganization describing size and alignment of primitive data-types: int, long, pointers, etc. - PrototypeModels describing calling conventions used by the compiler: __stdcall, __thiscall, etc. - InjectPayloads or p-code that can used for - Call-fixups, substituting p-code for compiler bookkeeping functions during analysis. - Callother-fixups, substituting p-code for user-defined p-code operations. - Memory ranges that the compiler treats as global - Context and register values known to the compiler over specific memory ranges
    • Field Detail

      • CALLING_CONVENTION_cdecl

        static final java.lang.String CALLING_CONVENTION_cdecl
        See Also:
        Constant Field Values
      • CALLING_CONVENTION_pascal

        static final java.lang.String CALLING_CONVENTION_pascal
        See Also:
        Constant Field Values
      • CALLING_CONVENTION_thiscall

        static final java.lang.String CALLING_CONVENTION_thiscall
        See Also:
        Constant Field Values
      • CALLING_CONVENTION_stdcall

        static final java.lang.String CALLING_CONVENTION_stdcall
        See Also:
        Constant Field Values
      • CALLING_CONVENTION_fastcall

        static final java.lang.String CALLING_CONVENTION_fastcall
        See Also:
        Constant Field Values
      • CALLING_CONVENTION_vectorcall

        static final java.lang.String CALLING_CONVENTION_vectorcall
        See Also:
        Constant Field Values
    • Method Detail

      • getLanguage

        Language getLanguage()
        Get the Language this compiler spec is based on. Note that compiler specs may be reused across multiple languages in the cspec files on disk, but once loaded in memory are actually separate objects. (M:N on disk, 1:N in memory)
        Returns:
        the language this compiler spec is based on
      • getCompilerSpecDescription

        CompilerSpecDescription getCompilerSpecDescription()
        Returns:
        a brief description of the compiler spec
      • getCompilerSpecID

        CompilerSpecID getCompilerSpecID()
        Returns:
        the id string associated with this compiler spec;
      • getStackPointer

        Register getStackPointer()
        Get the default Stack Pointer register for this language if there is one.
        Returns:
        default stack pointer register.
      • isStackRightJustified

        boolean isStackRightJustified()
        Indicates whether variables are right-justified within the stack alignment.
        Returns:
        true if right stack justification applies.
      • getAddressSpace

        AddressSpace getAddressSpace​(java.lang.String spaceName)
        Get an address space by name. This can be value added over the normal AddressFactory.getAddressSpace routine because the compiler spec can refer to special internal spaces like the stack space
        Parameters:
        spaceName - is the name of the address space
        Returns:
        the corresponding AddressSpace object
      • getStackSpace

        AddressSpace getStackSpace()
        Get the stack address space defined by this specification
        Returns:
        stack address space
      • getStackBaseSpace

        AddressSpace getStackBaseSpace()
        Get the physical space used for stack data storage
        Returns:
        address space which contains the stack
      • stackGrowsNegative

        boolean stackGrowsNegative()
        Returns:
        true if the stack grows with negative offsets
      • applyContextSettings

        void applyContextSettings​(DefaultProgramContext ctx)
        Apply context settings to the ProgramContext as specified by the configuration
        Parameters:
        ctx - is the ProgramContext
      • getCallingConventions

        PrototypeModel[] getCallingConventions()
        Returns:
        an array of the prototype models. Each prototype model specifies a calling convention.
      • getCallingConvention

        PrototypeModel getCallingConvention​(java.lang.String name)
        Returns the Calling Convention Model with the given name.
        Parameters:
        name - the name of the calling convention to retrieve
        Returns:
        the calling convention with the given name or null if there is none with that name.
      • getAllModels

        PrototypeModel[] getAllModels()
        Returns:
        all possible PrototypeModels, including calling conventions and merge models
      • getDefaultCallingConvention

        PrototypeModel getDefaultCallingConvention()
        Returns the prototype model that is the default calling convention or else null.
        Returns:
        the default calling convention or null.
      • getDecompilerOutputLanguage

        DecompilerLanguage getDecompilerOutputLanguage()
        Get the language that the decompiler produces
        Returns:
        an enum specifying the language
      • getPrototypeEvaluationModel

        PrototypeModel getPrototypeEvaluationModel​(CompilerSpec.EvaluationModelType modelType)
        Get the evaluation model matching the given type. If analysis needs to apply a PrototypeModel to a function but a specific model is not known, then this method can be used to select a putative PrototypeModel based on the analysis use-case: - EVAL_CURRENT indicates the model to use for the "current function" being analyzed - EVAL_CALLED indicates the model to use for a function called by the current function
        Parameters:
        modelType - is the type of evaluation model
        Returns:
        prototype evaluation model
      • isGlobal

        boolean isGlobal​(Address addr)
        Parameters:
        addr - is the (start of the) storage location
        Returns:
        true if the specified storage location has been designated "global" in scope
      • matchConvention

        PrototypeModel matchConvention​(GenericCallingConvention genericCallingConvention)
        Get the PrototypeModel corresponding to the given generic calling convention
        Parameters:
        genericCallingConvention - is the given generic calling convention
        Returns:
        the matching model or the defaultModel if nothing matches
      • findBestCallingConvention

        PrototypeModel findBestCallingConvention​(Parameter[] params)
        Find the best guess at a calling convention model from this compiler spec given an ordered list of (potential) parameters.
        Parameters:
        params - is the ordered list of parameters
        Returns:
        prototype model corresponding to the specified function signature
      • hasProperty

        boolean hasProperty​(java.lang.String key)
        Returns whether this language has a property defined.
        Parameters:
        key - the property key
        Returns:
        if the property is defined
      • doesCDataTypeConversions

        boolean doesCDataTypeConversions()
        Return true if function prototypes respect the C-language data-type conversion conventions. This amounts to converting array data-types to pointer-to-element data-types. In C, arrays are passed by reference (structures are still passed by value)
        Returns:
        if the prototype does C-language data-type conversions
      • getPropertyAsInt

        int getPropertyAsInt​(java.lang.String key,
                             int defaultInt)
        Gets the value of a property as an int, returning defaultInt if undefined.
        Parameters:
        key - the property key
        defaultInt - the default value to return if property is undefined
        Returns:
        the property value as an int, or the default value if undefined
      • getPropertyAsBoolean

        boolean getPropertyAsBoolean​(java.lang.String key,
                                     boolean defaultBoolean)
        Gets the value of a property as a boolean, returning defaultBoolean if undefined.
        Parameters:
        key - the property key
        defaultBoolean - the default value to return if property is undefined
        Returns:
        the property value as a boolean, or the default value if undefined
      • getProperty

        java.lang.String getProperty​(java.lang.String key,
                                     java.lang.String defaultString)
        Gets the value of a property as a String, returning defaultString if undefined.
        Parameters:
        key - the property key
        defaultString - the default value to return if property is undefined
        Returns:
        the property value as a String, or the default value if undefined
      • getProperty

        java.lang.String getProperty​(java.lang.String key)
        Gets a property defined for this language, or null if that property isn't defined.
        Parameters:
        key - the property key
        Returns:
        the property value, or null if not defined
      • getPropertyKeys

        java.util.Set<java.lang.String> getPropertyKeys()
        Returns a read-only set view of the property keys defined on this language.
        Returns:
        read-only set of property keys