8320533: Adjust capstone integration for v6 changes

Reviewed-by: ihse, aph
This commit is contained in:
Galder Zamarreño 2023-11-28 08:33:23 +00:00 committed by Andrew Dinn
parent 0678253bff
commit 20aae3c438
4 changed files with 23 additions and 2 deletions

View File

@ -47,7 +47,7 @@ ifeq ($(HSDIS_BACKEND), capstone)
CAPSTONE_ARCH := CS_ARCH_X86
CAPSTONE_MODE := CS_MODE_$(OPENJDK_TARGET_CPU_BITS)
else ifeq ($(call isTargetCpuArch, aarch64), true)
CAPSTONE_ARCH := CS_ARCH_ARM64
CAPSTONE_ARCH := CS_ARCH_$(CAPSTONE_ARCH_AARCH64_NAME)
CAPSTONE_MODE := CS_MODE_ARM
else
$(error No support for Capstone on this platform)

View File

@ -63,6 +63,19 @@ AC_DEFUN([LIB_SETUP_HSDIS_CAPSTONE],
AC_MSG_ERROR([Cannot continue])
fi
fi
capstone_header="\"$CAPSTONE/include/capstone/capstone.h\""
AC_MSG_CHECKING([capstone aarch64 arch name])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include $capstone_header],[[cs_arch test = CS_ARCH_AARCH64]])],
[
AC_MSG_RESULT([AARCH64])
CAPSTONE_ARCH_AARCH64_NAME="AARCH64"
],
[
AC_MSG_RESULT([ARM64])
CAPSTONE_ARCH_AARCH64_NAME="ARM64"
]
)
])
################################################################################
@ -365,6 +378,7 @@ AC_DEFUN_ONCE([LIB_SETUP_HSDIS],
AC_SUBST(HSDIS_CFLAGS)
AC_SUBST(HSDIS_LDFLAGS)
AC_SUBST(HSDIS_LIBS)
AC_SUBST(CAPSTONE_ARCH_AARCH64_NAME)
AC_MSG_CHECKING([if hsdis should be bundled])
if test "x$ENABLE_HSDIS_BUNDLING" = "xtrue"; then

View File

@ -377,6 +377,7 @@ ENABLE_HSDIS_BUNDLING := @ENABLE_HSDIS_BUNDLING@
HSDIS_CFLAGS := @HSDIS_CFLAGS@
HSDIS_LDFLAGS := @HSDIS_LDFLAGS@
HSDIS_LIBS := @HSDIS_LIBS@
CAPSTONE_ARCH_AARCH64_NAME := @CAPSTONE_ARCH_AARCH64_NAME@
# The boot jdk to use. This is overridden in bootcycle-spec.gmk. Make sure to keep
# it in sync.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
@ -52,6 +52,12 @@
#include <inttypes.h>
#include <string.h>
/* Undefine macro to avoid generating invalid C code.
Capstone refactored cs_detail for AArch64 architecture
from `cs_arm64 arm64` to `cs_aarch64 aarch64`
and that causes invalid macro expansion.
*/
#undef aarch64
#include <capstone.h>
#include "hsdis.h"