diff --git a/decode.c b/decode.c index dcc662a..17973c1 100644 --- a/decode.c +++ b/decode.c @@ -14,7 +14,7 @@ #define UNLIKELY(x) __builtin_expect((x), 0) #define FD_DECODE_TABLE_DATA -static const uint8_t _decode_table[] = { +static __attribute__((aligned(16))) const uint8_t _decode_table[] = { #include }; #undef FD_DECODE_TABLE_DATA @@ -42,7 +42,7 @@ typedef enum DecodeMode DecodeMode; #define ENTRY_UNPACK(table,kind,entry) do { \ uint16_t entry_copy = entry; \ - table = (uint16_t*) &_decode_table[entry_copy & ~7]; \ + table = &((uint16_t*) _decode_table)[(entry_copy & ~7) >> 1]; \ kind = entry_copy & ENTRY_MASK; \ } while (0) @@ -305,11 +305,11 @@ fd_decode(const uint8_t* buffer, size_t len_sz, int mode_int, uintptr_t address, // Ensure that we can actually handle the decode request #if defined(ARCH_386) if (mode == DECODE_32) - table = (uint16_t*) &_decode_table[FD_TABLE_OFFSET_32]; + table = &((uint16_t*) _decode_table)[FD_TABLE_OFFSET_32 >> 1]; #endif #if defined(ARCH_X86_64) if (mode == DECODE_64) - table = (uint16_t*) &_decode_table[FD_TABLE_OFFSET_64]; + table = &((uint16_t*) _decode_table)[FD_TABLE_OFFSET_64 >> 1]; #endif if (UNLIKELY(table == NULL)) diff --git a/format.c b/format.c index 76d13eb..b0f8776 100644 --- a/format.c +++ b/format.c @@ -55,7 +55,7 @@ fd_format(const FdInstr* instr, char* buffer, size_t len) if (op_type == FD_OT_NONE) break; - const char* op_type_name = "reg\0imm\0mem" + op_type * 4 - 4; + const char* op_type_name = &"reg\0imm\0mem"[op_type * 4] - 4; FMT_CONCAT(buf, end, " %s%u:", op_type_name, FD_OP_SIZE(instr, i)); switch (op_type)