#include #include #include "type.h" #define arch_typedef(_a, _t) { \ .ttype = T_TYPEDEF, \ .t = { .tdef = { .name = #_a, .type = _t } }, \ } type_t t_s8 = arch_typedef(s8, &t_char); type_t t_u8 = arch_typedef(u8, &t_uchar); type_t t_s16 = arch_typedef(s16, &t_short); type_t t_u16 = arch_typedef(u16, &t_ushort); type_t t_s32 = arch_typedef(s32, &t_int); type_t t_u32 = arch_typedef(u32, &t_uint); type_t t_s64 = arch_typedef(s64, &t_long); type_t t_u64 = arch_typedef(u64, &t_ulong); field_t f_pt_regs_fields[] = { { .name = "r15", .type = &t_ulong }, { .name = "r14", .type = &t_ulong }, { .name = "r13", .type = &t_ulong }, { .name = "r12", .type = &t_ulong }, { .name = "rbp", .type = &t_ulong }, { .name = "rbx", .type = &t_ulong }, { .name = "r11", .type = &t_ulong }, { .name = "r10", .type = &t_ulong }, { .name = "r9", .type = &t_ulong }, { .name = "r8", .type = &t_ulong }, { .name = "rax", .type = &t_ulong }, { .name = "rcx", .type = &t_ulong }, { .name = "rdx", .type = &t_ulong }, { .name = "rsi", .type = &t_ulong }, { .name = "rdi", .type = &t_ulong }, { .name = "orig_rax", .type = &t_ulong }, { .name = "rip", .type = &t_ulong }, { .name = "cs", .type = &t_ulong }, { .name = "eflags", .type = &t_ulong }, { .name = "rsp", .type = &t_ulong }, { .name = "ss", .type = &t_ulong }, { .type = NULL } }; type_t t_pt_regs = { .ttype = T_STRUCT, .t.sou = { .name = "pt_regs", .fields = f_pt_regs_fields, }, }; type_t *arch_types[] = { &t_s8, &t_u8, &t_s16, &t_u16, &t_s32, &t_u32, &t_s64, &t_u64, &t_pt_regs, NULL }; __attribute__((constructor)) static void arch_init(void) { type_add_list(arch_types); assert(t_pt_regs.size == sizeof(struct pt_regs)); }