C++

AssemblerConfig

class AssemblerConfig

This class exposes the different elements that can be configured to assemble code.

Public Types

enum class DIALECT

The different supported dialects.

Values:

enumerator DEFAULT_DIALECT = 0
enumerator X86_INTEL

Intel syntax.

enumerator X86_ATT

AT&T syntax.

Public Functions

AssemblerConfig() = default
AssemblerConfig(const AssemblerConfig&) = default
AssemblerConfig &operator=(const AssemblerConfig&) = default
AssemblerConfig(AssemblerConfig&&) = default
AssemblerConfig &operator=(AssemblerConfig&&) = default
inline virtual optional<uint64_t> resolve_symbol(const std::string&)

This function aims to be overloaded in order to resolve symbols used in the assembly listing.

For instance, given this assembly code:

0x1000: mov rdi, rbx
0x1003: call _my_function

The function _my_function will remain undefined unless we return its address in resolve_symbol():

class MyConfig : public AssemblerConfig {
  public:
  optional<uint64_t> resolve_symbol(const std::string& name) {
    if (name == "_my_function") {
      return 0x4000;
    }
    return nullopt(); // or AssemblerConfig::resolve_symbol(name)
  }
};
virtual ~AssemblerConfig() = default

Public Members

DIALECT dialect = DIALECT::DEFAULT_DIALECT

The dialect of the input assembly code.

Public Static Functions

static inline AssemblerConfig &default_config()

Default configuration.