Package ghidra.pcode.emu.sys

# Class AnnotatedEmuSyscallUseropLibrary<T>

java.lang.Object
ghidra.pcode.exec.AnnotatedPcodeUseropLibrary<T>
ghidra.pcode.emu.sys.AnnotatedEmuSyscallUseropLibrary<T>

Type Parameters:
  `T` - the type of data processed by the library, typically `byte[]`

All Implemented Interfaces:
  `EmuSyscallLibrary<T>`, `PcodeUseropLibrary<T>`

Direct Known Subclasses:
  `AbstractEmuUnixSyscallUseropLibrary`

public abstract class AnnotatedEmuSyscallUseropLibrary<T> extends AnnotatedPcodeUseropLibrary<T> implements EmuSyscallLibrary<T>
A syscall library wherein Java methods are exported via a special annotated

This library is both a system call and a sleigh userop library. To export a system call, it must also be exported as a sleigh userop. This is more conventional, as the system call dispatcher does not require it, however, this library uses a wrapping technique that does require it. In general, exporting system calls as userops will make developers and users lives easier. To avoid naming collisions, system calls can be exported with customized names.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static @interface`
  `AnnotatedEmuSyscallUseropLibrary.EmuSyscall`
  An annotation to export a method as a system call in the library.
  `protected class`
  `AnnotatedEmuSyscallUseropLibrary.StructuredPart`

  ## Nested classes/interfaces inherited from class ghidra.pcode.exec.AnnotatedPcodeUseropLibrary

  `AnnotatedPcodeUseropLibrary.AnnotatedPcodeUseropDefinition<T>, AnnotatedPcodeUseropLibrary.FixedArgsAnnotatedPcodeUseropDefinition<T>, AnnotatedPcodeUseropLibrary.OpExecutor, AnnotatedPcodeUseropLibrary.OpLibrary, AnnotatedPcodeUseropLibrary.OpOutput, AnnotatedPcodeUseropLibrary.OpState, AnnotatedPcodeUseropLibrary.PcodeUserop, AnnotatedPcodeUseropLibrary.VariadicAnnotatedPcodeUseropDefinition<T>`

  ## Nested classes/interfaces inherited from interface ghidra.pcode.emu.sys.EmuSyscallLibrary

  `EmuSyscallLibrary.EmuSyscallDefinition<T>, EmuSyscallLibrary.SyscallPcodeUseropDefinition<T>`

  ## Nested classes/interfaces inherited from interface ghidra.pcode.exec.PcodeUseropLibrary

  `PcodeUseropLibrary.EmptyPcodeUseropLibrary, PcodeUseropLibrary.PcodeUseropDefinition<T>`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final Collection<DataTypeManager>`
  `additionalArchives`
  `protected static final Map<Class<?>,Set<Method>>`
  `CACHE_BY_CLASS`
  `protected final CompilerSpec`
  `cSpec`
  `protected final DataType`
  `dtMachineWord`
  `protected final PcodeMachine<T>`
  `machine`
  `protected final Program`
  `program`
  `static final String`
  `SYSCALL_SPACE_NAME`
  `protected final Map<Long,EmuSyscallLibrary.EmuSyscallDefinition<T>>`
  `syscallMap`

  ### Fields inherited from class ghidra.pcode.exec.AnnotatedPcodeUseropLibrary

  `ops`

  ### Fields inherited from interface ghidra.pcode.emu.sys.EmuSyscallLibrary

  `SYSCALL_CONVENTION_NAME`

  ### Fields inherited from interface ghidra.pcode.exec.PcodeUseropLibrary

  `NIL`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AnnotatedEmuSyscallUseropLibrary(PcodeMachine<T> machine, Program program)`
  Construct a new library including the "syscall" userop

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `disposeAdditionalArchives()`
  `protected Collection<DataTypeManager>`
  `getAdditionalArchives()`
  `Map<Long,EmuSyscallLibrary.EmuSyscallDefinition<T>>`
  `getSyscalls()`
  Get the map of syscalls by number
  `PcodeUseropLibrary.PcodeUseropDefinition<T>`
  `getSyscallUserop()`
  In case this is not an `AnnotatedEmuSyscallUseropLibrary` or `AnnotatedPcodeUseropLibrary`, get the definition of the "syscall" userop for inclusion in the `PcodeUseropLibrary`.
  `protected void`
  `mapAndBindSyscalls()`
  `protected void`
  `mapAndBindSyscalls(Class<?> cls)`
  `UseropEmuSyscallDefinition<T>`
  `newBoundSyscall(PcodeUseropLibrary.PcodeUseropDefinition<T> opdef, PrototypeModel convention)`
  Export a userop as a system call
  `protected AnnotatedEmuSyscallUseropLibrary<T>.StructuredPart`
  `newStructuredPart()`
  Create the structured-sleigh part of this library

  ### Methods inherited from class ghidra.pcode.exec.AnnotatedPcodeUseropLibrary

  `getMethodLookup, getOperandType, getUserops`

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

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

  ### Methods inherited from interface ghidra.pcode.emu.sys.EmuSyscallLibrary

  `handleError, readSyscallNumber, syscall`

  ### Methods inherited from interface ghidra.pcode.exec.PcodeUseropLibrary

  `compose, getSymbols, getUserops`

- ## Field Details

  - ### SYSCALL_SPACE_NAME

    public static final String SYSCALL_SPACE_NAME
    See Also:
      - Constant Field Values

  - ### CACHE_BY_CLASS

    protected static final Map<Class<?>,Set<Method>> CACHE_BY_CLASS

  - ### machine

    protected final PcodeMachine<T> machine

  - ### cSpec

    protected final CompilerSpec cSpec

  - ### program

    protected final Program program

  - ### dtMachineWord

    protected final DataType dtMachineWord

  - ### syscallMap

    protected final Map<Long,EmuSyscallLibrary.EmuSyscallDefinition<T>> syscallMap

  - ### additionalArchives

    protected final Collection<DataTypeManager> additionalArchives

- ## Constructor Details

  - ### AnnotatedEmuSyscallUseropLibrary

    public AnnotatedEmuSyscallUseropLibrary(PcodeMachine<T> machine, Program program)
    Construct a new library including the "syscall" userop
    Parameters:
      `machine` - the machine using this library
      `program` - a program from which to derive syscall configuration, conventions, etc.

- ## Method Details

  - ### getAdditionalArchives

    protected Collection<DataTypeManager> getAdditionalArchives()

  - ### disposeAdditionalArchives

    protected void disposeAdditionalArchives()

  - ### newStructuredPart

    protected AnnotatedEmuSyscallUseropLibrary<T>.StructuredPart newStructuredPart()
    Create the structured-sleigh part of this library
    Returns:
      the structured part

  - ### newBoundSyscall

    public UseropEmuSyscallDefinition<T> newBoundSyscall(PcodeUseropLibrary.PcodeUseropDefinition<T> opdef, PrototypeModel convention)
    Export a userop as a system call
    Parameters:
      `opdef` - the userop
    Returns:
      the syscall definition

  - ### mapAndBindSyscalls

    protected void mapAndBindSyscalls(Class<?> cls)

  - ### mapAndBindSyscalls

    protected void mapAndBindSyscalls()

  - ### getSyscallUserop

    public PcodeUseropLibrary.PcodeUseropDefinition<T> getSyscallUserop()
    Description copied from interface: `EmuSyscallLibrary`
    In case this is not an `AnnotatedEmuSyscallUseropLibrary` or `AnnotatedPcodeUseropLibrary`, get the definition of the "syscall" userop for inclusion in the `PcodeUseropLibrary`.

    Implementors may wish to override this to use a pre-constructed definition. That definition can be easily constructed using `EmuSyscallLibrary.SyscallPcodeUseropDefinition`.

    Specified by:
      `getSyscallUserop` in interface `EmuSyscallLibrary<T>`
    Returns:
      the syscall userop definition

  - ### getSyscalls

    public Map<Long,EmuSyscallLibrary.EmuSyscallDefinition<T>> getSyscalls()
    Description copied from interface: `EmuSyscallLibrary`
    Get the map of syscalls by number

    Note this method will be invoked for every emulated syscall, so it should be a simple accessor. Any computations needed to create the map should be done ahead of time.

    Specified by:
      `getSyscalls` in interface `EmuSyscallLibrary<T>`
    Returns:
      the system call map