mirror of
https://github.com/capstone-engine/capstone.git
synced 2024-11-23 05:29:53 +00:00
Fix: bug that static link does not know constructor
This commit is contained in:
parent
5696d98f63
commit
701b850af9
5
Makefile
5
Makefile
@ -40,18 +40,21 @@ LIBOBJ =
|
||||
LIBOBJ += cs.o utils.o SStream.o MCInstrDesc.o MCRegisterInfo.o
|
||||
|
||||
ifneq (,$(findstring powerpc,$(CAPSTONE_ARCHS)))
|
||||
CFLAGS += -DCAPSTONE_HAS_POWERPC
|
||||
LIBOBJ += arch/PowerPC/PPCDisassembler.o
|
||||
LIBOBJ += arch/PowerPC/PPCInstPrinter.o
|
||||
LIBOBJ += arch/PowerPC/mapping.o
|
||||
LIBOBJ += arch/PowerPC/module.o
|
||||
endif
|
||||
ifneq (,$(findstring arm,$(CAPSTONE_ARCHS)))
|
||||
CFLAGS += -DCAPSTONE_HAS_ARM
|
||||
LIBOBJ += arch/ARM/ARMDisassembler.o
|
||||
LIBOBJ += arch/ARM/ARMInstPrinter.o
|
||||
LIBOBJ += arch/ARM/mapping.o
|
||||
LIBOBJ += arch/ARM/module.o
|
||||
endif
|
||||
ifneq (,$(findstring x86,$(CAPSTONE_ARCHS)))
|
||||
CFLAGS += -DCAPSTONE_HAS_X86
|
||||
LIBOBJ += arch/X86/X86DisassemblerDecoder.o
|
||||
LIBOBJ += arch/X86/X86Disassembler.o
|
||||
LIBOBJ += arch/X86/X86IntelInstPrinter.o
|
||||
@ -59,12 +62,14 @@ ifneq (,$(findstring x86,$(CAPSTONE_ARCHS)))
|
||||
LIBOBJ += arch/X86/mapping.o arch/X86/module.o
|
||||
endif
|
||||
ifneq (,$(findstring mips,$(CAPSTONE_ARCHS)))
|
||||
CFLAGS += -DCAPSTONE_HAS_MIPS
|
||||
LIBOBJ += arch/Mips/MipsDisassembler.o
|
||||
LIBOBJ += arch/Mips/MipsInstPrinter.o
|
||||
LIBOBJ += arch/Mips/mapping.o
|
||||
LIBOBJ += arch/Mips/module.o
|
||||
endif
|
||||
ifneq (,$(findstring aarch64,$(CAPSTONE_ARCHS)))
|
||||
CFLAGS += -DCAPSTONE_HAS_ARM64
|
||||
LIBOBJ += arch/AArch64/AArch64BaseInfo.o
|
||||
LIBOBJ += arch/AArch64/AArch64Disassembler.o
|
||||
LIBOBJ += arch/AArch64/AArch64InstPrinter.o
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "AArch64InstPrinter.h"
|
||||
#include "mapping.h"
|
||||
|
||||
void enable_arm64() {}
|
||||
|
||||
static cs_err init(cs_struct *ud)
|
||||
{
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "ARMInstPrinter.h"
|
||||
#include "mapping.h"
|
||||
|
||||
void enable_arm() {};
|
||||
|
||||
static cs_err init(cs_struct *ud)
|
||||
{
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "MipsInstPrinter.h"
|
||||
#include "mapping.h"
|
||||
|
||||
void enable_mips() {};
|
||||
|
||||
static cs_err init(cs_struct *ud)
|
||||
{
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "PPCInstPrinter.h"
|
||||
#include "mapping.h"
|
||||
|
||||
void enable_powerpc() {};
|
||||
|
||||
static cs_err init(cs_struct *ud)
|
||||
{
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "X86InstPrinter.h"
|
||||
#include "mapping.h"
|
||||
|
||||
void enable_x86() {};
|
||||
|
||||
static cs_err init(cs_struct *ud)
|
||||
{
|
||||
// by default, we use Intel syntax
|
||||
|
23
cs.c
23
cs.c
@ -14,6 +14,12 @@ cs_err (*arch_init[MAX_ARCH])(cs_struct *) = { NULL };
|
||||
cs_err (*arch_option[MAX_ARCH]) (cs_struct *, cs_opt_type, size_t value) = { NULL };
|
||||
void (*arch_destroy[MAX_ARCH]) (cs_struct *) = { NULL };
|
||||
|
||||
extern void enable_arm();
|
||||
extern void enable_arm64();
|
||||
extern void enable_mips();
|
||||
extern void enable_x86();
|
||||
extern void enable_powerpc();
|
||||
|
||||
unsigned int all_arch = 0;
|
||||
|
||||
#ifdef USE_SYS_DYN_MEM
|
||||
@ -84,8 +90,25 @@ const char *cs_strerror(cs_err code)
|
||||
}
|
||||
}
|
||||
|
||||
void enable_construct() {
|
||||
enable_arm();
|
||||
#ifdef CAPSTONE_HAS_ARM64
|
||||
enable_arm64();
|
||||
#endif
|
||||
#ifdef CAPSTONE_HAS_MIPS
|
||||
enable_mips();
|
||||
#endif
|
||||
#ifdef CAPSTONE_HAS_X86
|
||||
enable_x86();
|
||||
#endif
|
||||
#ifdef CAPSTONE_HAS_POWERPC
|
||||
enable_powerpc();
|
||||
#endif
|
||||
}
|
||||
|
||||
cs_err cs_open(cs_arch arch, cs_mode mode, csh *handle)
|
||||
{
|
||||
enable_construct();
|
||||
if (!my_malloc || !my_calloc || !my_realloc || !my_free)
|
||||
// Error: before cs_open(), dynamic memory management must be initialized
|
||||
// with cs_option(CS_OPT_MEM)
|
||||
|
Loading…
Reference in New Issue
Block a user