diff --git a/Makefile b/Makefile index ec479dd..54e74aa 100644 --- a/Makefile +++ b/Makefile @@ -8,14 +8,15 @@ CC = gcc AS = as AR = ar LD = ld +GZIP = gzip CFLAGS = -Wall -I$(INC_DIR) ASFLAGS = LDFLAGS = -z noexecstack -lcap RTDISASM_SRC = rtdisasm.c -RTDISASM_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.s,%.o,$(patsubst %.c,%.o,$(RTDISASM_SRC)))) +RTDISASM_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.s,%.o,$(patsubst %.c,%.o,$(RTDISASM_SRC)))) $(OBJ_DIR)/rtdisasm_table.o RTDISASM_SRC := $(addprefix $(SRC_DIR)/,$(RTDISASM_SRC)) -RTDISASM_DEPS = rtdisasm.h +RTDISASM_DEPS = rtdisasm.h rtdisasm_table.h RTDISASM_DEPS := $(addprefix $(INC_DIR)/,$(RTDISASM_DEPS)) RTDISASM_TEST_SRC = rtdisasm_test.c @@ -37,6 +38,10 @@ DUMMY_TARGET_SRC := $(addprefix $(SRC_DIR)/,$(DUMMY_TARGET_SRC)) $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(CC) $(CFLAGS) -c -o $@ $< +# compressed C files +$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cgz + $(GZIP) -d -c $< | $(CC) -x c $(CFLAGS) -c -o $@ - + $(OBJ_DIR)/%.o: $(SRC_DIR)/%.s $(AS) $(ASFLAGS) -o $@ $< diff --git a/include/rtdisasm_table.h b/include/rtdisasm_table.h new file mode 100644 index 0000000..e96f9f4 --- /dev/null +++ b/include/rtdisasm_table.h @@ -0,0 +1,30 @@ +#ifndef __RTDISASM_TABLE_H +#define __RTDISASM_TABLE_H + +#include + +#define INSTRUCTION_STANDARD 0 +#define INSTRUCTION_VEX 1 +#define INSTRUCTION_EVEX 2 + +#define MAX_OPCODE_LEN 4 + +typedef struct { + struct { + uint16_t type : 4; + uint16_t has_rex : 1; + uint16_t has_digit : 1; + uint16_t has_modrm : 1; + uint16_t has_imm : 1; + uint16_t has_value : 1; + uint16_t has_opreg : 1; + } info; + + uint16_t opcode_len; + uint8_t opcode[MAX_OPCODE_LEN]; +} instruction_t; + +extern const instruction_t rtdisasm_table[]; +extern const unsigned rtdisasm_table_len; + +#endif \ No newline at end of file diff --git a/src/rtdisasm_table.cgz b/src/rtdisasm_table.cgz new file mode 100644 index 0000000..b6b8952 Binary files /dev/null and b/src/rtdisasm_table.cgz differ