add x86 instruction set lookup table, compressed in gzip to avoid diff clogging

This commit is contained in:
mykola2312 2024-08-14 01:27:40 +03:00
parent 3965e0b773
commit 585d940ece
3 changed files with 37 additions and 2 deletions

View file

@ -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 $@ $<

30
include/rtdisasm_table.h Normal file
View file

@ -0,0 +1,30 @@
#ifndef __RTDISASM_TABLE_H
#define __RTDISASM_TABLE_H
#include <stdint.h>
#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

BIN
src/rtdisasm_table.cgz Normal file

Binary file not shown.