diff --git a/src/adbg/disassembler.d b/src/adbg/disassembler.d index 16d7cee..2376145 100644 --- a/src/adbg/disassembler.d +++ b/src/adbg/disassembler.d @@ -25,6 +25,20 @@ //TODO: Close function should close CS lib too // Make sure we have a function to reconfigure machine +// NOTE: Longest architectural instruction contest +// x86: 15 bytes +// AArch32: 2 or 4 bytes +// AArch64: 4 bytes +// Power: 4 bytes +// MIPS: 4 bytes +// RISC-V: 24 bytes (reserved) +// SPARC: 4 bytes +// IA64: 16 bytes +// Alpha: 4 bytes + +/// Maximum instruction size in bytes. +enum MAX_INSTR_SIZE = 16; + version (X86) { // CS_OPT_SYNTAX_DEFAULT private enum { CS_DEFAULT_PLATFORM = CS_ARCH_X86, /// Platform default platform @@ -64,10 +78,6 @@ static assert(0, "Set DEFAULT_PLATFORM and DEFAULT_SYNTAX"); } -/// Maximum instruction size in bytes. -/// Currently, this title goes to x86 with 15 bytes. Congrats! -enum MAX_INSTR_SIZE = 16; - private { enum ADBG_MAGIC = 0xcafebabe; } diff --git a/src/adbg/object/server.d b/src/adbg/object/server.d index 0e1a237..073677a 100644 --- a/src/adbg/object/server.d +++ b/src/adbg/object/server.d @@ -759,6 +759,17 @@ return adbg_oops(AdbgError.objectUnknownFormat); } +export +void* adbg_object_header(adbg_object_t *o) { + if (o == null) { + adbg_oops(AdbgError.invalidArgument); + return null; + } + + // NOTE: Cleared on allocation until image is loaded + return o.i.header; +} + adbg_section_t* adbg_object_section_n(adbg_object_t *o, const(char)* name, uint flags = 0) { if (o == null || name == null) { adbg_oops(AdbgError.invalidArgument); diff --git a/src/adbg/platform.d b/src/adbg/platform.d index 29a6444..0427744 100644 --- a/src/adbg/platform.d +++ b/src/adbg/platform.d @@ -244,6 +244,7 @@ /// Get compilation information structure. /// Note: This can be interpreted as a null-terminated array of string pointers. /// Returns: AdbgInfo structure pointer +export immutable(adbg_build_info_t)* adbg_build_info() { static immutable adbg_build_info_t info; return &info; diff --git a/src/adbg/symbols.d b/src/adbg/symbols.d index 1d636b4..bab02c7 100644 --- a/src/adbg/symbols.d +++ b/src/adbg/symbols.d @@ -15,13 +15,13 @@ // - https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling // NOTE: Support notes -// | Language | Description | -// |----------|-------------------| -// | C | Varies. | -// | C++ | Varies. | -// | D | Uses `_D` prefix. | -// | Zig | Uses C names. | -// | Rust | Uses `_R` prefix. | +// | Language | Description | +// |----------|-------------------| +// | C | Varies. | +// | C++ | Varies. | +// | D | Uses `_D` prefix. | +// | Zig | Uses C names. | +// | Rust | Uses `_R` prefix. | extern (C): @@ -37,7 +37,7 @@ /// Exact mangled symbol name, as given. exact, /// C mangled name. (Most 32-bit targets) - /// Example: int g(int) -> _g + /// Example: int g(int) -> _g (Windows, 32 and 64 bit targets) cdecl, /// Windows Standard Call mangled name. (32-bit targets) /// Example: (C) int g(int) -> _g@4 @@ -48,7 +48,7 @@ /// Example: (C++) int g(int) -> ?g@@YIHH@Z fastcall, /// C++ mangled name for GCC/Clang. - /// Example: int g(int) -> _Z1gi + /// Example: (C++) int g(int) -> _Z1gi gnucpp, // C++ mangled name for old GCC (2.9x) //oldgnucpp,