From c6fff6d9cfdb2fcc9b80f1a3ff8759c3e642bdec Mon Sep 17 00:00:00 2001 From: billow Date: Sat, 8 Jun 2024 15:40:14 +0800 Subject: [PATCH] Xtensa: fix make build --- COMPILE_CMAKE.TXT | 5 +++-- HACK.TXT | 1 + Makefile | 12 +++++++++++- config.mk | 2 +- nmake.bat | 1 + suite/cstest/Makefile | 4 ++-- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/COMPILE_CMAKE.TXT b/COMPILE_CMAKE.TXT index dfe491f966..39abd7fcca 100644 --- a/COMPILE_CMAKE.TXT +++ b/COMPILE_CMAKE.TXT @@ -39,6 +39,7 @@ Get CMake for free from http://www.cmake.org. - CAPSTONE_WASM_SUPPORT: support Web Assembly. Run cmake with -DCAPSTONE_WASM_SUPPORT=0 to remove WASM. - CAPSTONE_BPF_SUPPORT: support BPF. Run cmake with -DCAPSTONE_BPF_SUPPORT=0 to remove BPF. - CAPSTONE_RISCV_SUPPORT: support RISCV. Run cmake with -DCAPSTONE_RISCV_SUPPORT=0 to remove RISCV. + - CAPSTONE_XTENSA_SUPPORT: support XTENSA. Run cmake with -DCAPSTONE_XTENSA_SUPPORT=0 to remove XTENSA. - CAPSTONE_ARCHITECTURE_DEFAULT: Whether architectures are enabled by default. Set this of OFF with -DCAPSTONE_ARCHITECTURE_DEFAULT=OFF to disable all architectures by default. You can then enable them again with one of the CAPSTONE__SUPPORT options. @@ -118,8 +119,8 @@ Get CMake for free from http://www.cmake.org. Will just target the x86 architecture. The list of available architectures is: ARM, AARCH64, M68K, MIPS, PowerPC, Sparc, SystemZ, XCore, x86, TMS320C64x, M680x, EVM, MOS65XX, - WASM, BPF, RISCV, Alpha, HPPA. - + WASM, BPF, RISCV, Alpha, HPPA, Xtensa. + (4) You can also create an installation image with cmake, by using the 'install' target. Use: diff --git a/HACK.TXT b/HACK.TXT index 5858f61cd9..13d6a90145 100644 --- a/HACK.TXT +++ b/HACK.TXT @@ -23,6 +23,7 @@ Capstone source is organized as followings. │   ├── TMS320C64x <- TMS320C64x engine │   ├── TriCore <- TriCore engine │   └── WASM <- WASM engine +│   └── Xtensa <- Xtensa engine ├── bindings <- all bindings are under this dir │   ├── java <- Java bindings + test code │   ├── ocaml <- Ocaml bindings + test code diff --git a/Makefile b/Makefile index 7a526abd16..e9ab7d08fa 100644 --- a/Makefile +++ b/Makefile @@ -345,12 +345,21 @@ ifneq (,$(findstring hppa,$(CAPSTONE_ARCHS))) LIBOBJ_HPPA += $(LIBSRC_HPPA:%.c=$(OBJDIR)/%.o) endif +DEP_XTENSA = +DEP_XTENSA += $(wildcard arch/Xtensa/Xtensa*.inc) + +LIBOBJ_XTENSA = +ifneq (,$(findstring xtensa,$(CAPSTONE_ARCHS))) + CFLAGS += -DCAPSTONE_HAS_XTENSA + LIBSRC_XTENSA += $(wildcard arch/Xtensa/Xtensa*.c) + LIBOBJ_XTENSA += $(LIBSRC_XTENSA:%.c=$(OBJDIR)/%.o) +endif LIBOBJ = LIBOBJ += $(OBJDIR)/cs.o $(OBJDIR)/utils.o $(OBJDIR)/SStream.o $(OBJDIR)/MCInstrDesc.o $(OBJDIR)/MCRegisterInfo.o $(OBJDIR)/MCInst.o $(OBJDIR)/MCInstPrinter.o $(OBJDIR)/Mapping.o LIBOBJ += $(LIBOBJ_ARM) $(LIBOBJ_AARCH64) $(LIBOBJ_M68K) $(LIBOBJ_MIPS) $(LIBOBJ_PPC) $(LIBOBJ_RISCV) $(LIBOBJ_SPARC) $(LIBOBJ_SYSZ) $(LIBOBJ_SH) LIBOBJ += $(LIBOBJ_X86) $(LIBOBJ_XCORE) $(LIBOBJ_TMS320C64X) $(LIBOBJ_M680X) $(LIBOBJ_EVM) $(LIBOBJ_MOS65XX) $(LIBOBJ_WASM) $(LIBOBJ_BPF) -LIBOBJ += $(LIBOBJ_TRICORE) $(LIBOBJ_ALPHA) $(LIBOBJ_HPPA) +LIBOBJ += $(LIBOBJ_TRICORE) $(LIBOBJ_ALPHA) $(LIBOBJ_HPPA) $(LIBOBJ_XTENSA) ifeq ($(PKG_EXTRA),) @@ -488,6 +497,7 @@ $(LIBOBJ_BPF): $(DEP_BPF) $(LIBOBJ_TRICORE): $(DEP_TRICORE) $(LIBOBJ_ALPHA): $(DEP_ALPHA) $(LIBOBJ_HPPA): $(DEP_HPPA) +$(LIBOBJ_XTENSA): $(DEP_XTENSA) ifeq ($(CAPSTONE_STATIC),yes) $(ARCHIVE): $(LIBOBJ) diff --git a/config.mk b/config.mk index fb92ac7449..ab1083d0f6 100644 --- a/config.mk +++ b/config.mk @@ -4,7 +4,7 @@ ################################################################################ # Specify which archs you want to compile in. By default, we build all archs. -CAPSTONE_ARCHS ?= arm aarch64 m68k mips powerpc sparc systemz x86 xcore tms320c64x m680x evm riscv mos65xx wasm bpf sh tricore alpha hppa +CAPSTONE_ARCHS ?= arm aarch64 m68k mips powerpc sparc systemz x86 xcore tms320c64x m680x evm riscv mos65xx wasm bpf sh tricore alpha hppa xtensa ################################################################################ diff --git a/nmake.bat b/nmake.bat index 42d64158d9..362835240c 100644 --- a/nmake.bat +++ b/nmake.bat @@ -24,6 +24,7 @@ if "%1"=="BPF" set %arch%=BPF if "%1"=="RISCV" set %arch%=RISCV if "%1"=="ALPHA" set %arch%=ALPHA if "%1"=="HPPA" set %arch%=HPPA +if "%1"=="XTENSA" set %arch%=XTENSA if not "%arch%"=="" set flags=%flags% and " -DCAPSTONE_ARCHITECTURE_DEFAULT=OFF -DCAPSTONE_%arch%_SUPPORT=ON" diff --git a/suite/cstest/Makefile b/suite/cstest/Makefile index a5ad34a798..a5d0bc9e22 100644 --- a/suite/cstest/Makefile +++ b/suite/cstest/Makefile @@ -1,12 +1,12 @@ SOURCE = src INCLUDE = include ../../include BUILD = build -LIBRARY = -lcmocka -lcapstone -L../.. +LIBRARY = -lcapstone -L../.. all: rm -rf $(BUILD) mkdir $(BUILD) - $(CC) $(SOURCE)/*.c $(INCLUDE:%=-I %) -g -o $(BUILD)/cstest $(LIBRARY) + $(CC) $(SOURCE)/*.c $(INCLUDE:%=-I %) -g -o $(BUILD)/cstest $(LIBRARY) $(shell pkg-config --libs cmocka) $(shell pkg-config --cflags cmocka) cstest: $(BUILD)/cstest -d ../MC clean: