diff --git a/include/unicorn/unicorn.h b/include/unicorn/unicorn.h index 6ecd6dc2..11772b9a 100644 --- a/include/unicorn/unicorn.h +++ b/include/unicorn/unicorn.h @@ -104,6 +104,7 @@ typedef enum uc_mode { UC_MODE_32 = 1 << 2, // 32-bit mode UC_MODE_64 = 1 << 3, // 64-bit mode // ppc + UC_MODE_PPC32 = 1 << 2, // 32-bit mode (currently unsupported) UC_MODE_PPC64 = 1 << 3, // 64-bit mode (currently unsupported) UC_MODE_QPX = 1 << 4, // Quad Processing eXtensions mode (currently unsupported) // sparc diff --git a/samples/sample_sparc.c b/samples/sample_sparc.c index 88bbd01e..e6276b14 100644 --- a/samples/sample_sparc.c +++ b/samples/sample_sparc.c @@ -57,7 +57,7 @@ static void test_sparc(void) printf("Emulate SPARC code\n"); // Initialize emulator in Sparc mode - err = uc_open(UC_ARCH_SPARC, UC_MODE_SPARC32, &uc); + err = uc_open(UC_ARCH_SPARC, UC_MODE_SPARC32|UC_MODE_BIG_ENDIAN, &uc); if (err) { printf("Failed on uc_open() with error returned: %u (%s)\n", err, uc_strerror(err)); diff --git a/tests/regress/sparc_jump_to_zero.c b/tests/regress/sparc_jump_to_zero.c index c816b700..2baaa69f 100644 --- a/tests/regress/sparc_jump_to_zero.c +++ b/tests/regress/sparc_jump_to_zero.c @@ -1,7 +1,7 @@ #include #define HARDWARE_ARCHITECTURE UC_ARCH_SPARC -#define HARDWARE_MODE UC_ARCH_SPARC32 +#define HARDWARE_MODE UC_ARCH_SPARC32|UC_MODE_BIG_ENDIAN #define MEMORY_STARTING_ADDRESS 0x1000000 #define MEMORY_SIZE 2 * 1024 * 1024 diff --git a/uc.c b/uc.c index d93fa4e5..1a419e8c 100644 --- a/uc.c +++ b/uc.c @@ -245,7 +245,9 @@ uc_err uc_open(uc_arch arch, uc_mode mode, uc_engine **result) #ifdef UNICORN_HAS_SPARC case UC_ARCH_SPARC: - if (mode & ~UC_MODE_SPARC_MASK) { + if ((mode & ~UC_MODE_SPARC_MASK) || + !(mode & UC_MODE_BIG_ENDIAN) || + !(mode & (UC_MODE_SPARC32|UC_MODE_SPARC64))) { free(uc); return UC_ERR_MODE; }