Skip to content

Commit 20aae3c

Browse files
galderzadinn
authored andcommitted
8320533: Adjust capstone integration for v6 changes
Reviewed-by: ihse, aph
1 parent 0678253 commit 20aae3c

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

make/Hsdis.gmk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ifeq ($(HSDIS_BACKEND), capstone)
4747
CAPSTONE_ARCH := CS_ARCH_X86
4848
CAPSTONE_MODE := CS_MODE_$(OPENJDK_TARGET_CPU_BITS)
4949
else ifeq ($(call isTargetCpuArch, aarch64), true)
50-
CAPSTONE_ARCH := CS_ARCH_ARM64
50+
CAPSTONE_ARCH := CS_ARCH_$(CAPSTONE_ARCH_AARCH64_NAME)
5151
CAPSTONE_MODE := CS_MODE_ARM
5252
else
5353
$(error No support for Capstone on this platform)

make/autoconf/lib-hsdis.m4

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ AC_DEFUN([LIB_SETUP_HSDIS_CAPSTONE],
6363
AC_MSG_ERROR([Cannot continue])
6464
fi
6565
fi
66+
67+
capstone_header="\"$CAPSTONE/include/capstone/capstone.h\""
68+
AC_MSG_CHECKING([capstone aarch64 arch name])
69+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include $capstone_header],[[cs_arch test = CS_ARCH_AARCH64]])],
70+
[
71+
AC_MSG_RESULT([AARCH64])
72+
CAPSTONE_ARCH_AARCH64_NAME="AARCH64"
73+
],
74+
[
75+
AC_MSG_RESULT([ARM64])
76+
CAPSTONE_ARCH_AARCH64_NAME="ARM64"
77+
]
78+
)
6679
])
6780

6881
################################################################################
@@ -365,6 +378,7 @@ AC_DEFUN_ONCE([LIB_SETUP_HSDIS],
365378
AC_SUBST(HSDIS_CFLAGS)
366379
AC_SUBST(HSDIS_LDFLAGS)
367380
AC_SUBST(HSDIS_LIBS)
381+
AC_SUBST(CAPSTONE_ARCH_AARCH64_NAME)
368382
369383
AC_MSG_CHECKING([if hsdis should be bundled])
370384
if test "x$ENABLE_HSDIS_BUNDLING" = "xtrue"; then

make/autoconf/spec.gmk.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ ENABLE_HSDIS_BUNDLING := @ENABLE_HSDIS_BUNDLING@
377377
HSDIS_CFLAGS := @HSDIS_CFLAGS@
378378
HSDIS_LDFLAGS := @HSDIS_LDFLAGS@
379379
HSDIS_LIBS := @HSDIS_LIBS@
380+
CAPSTONE_ARCH_AARCH64_NAME := @CAPSTONE_ARCH_AARCH64_NAME@
380381

381382
# The boot jdk to use. This is overridden in bootcycle-spec.gmk. Make sure to keep
382383
# it in sync.

src/utils/hsdis/capstone/hsdis-capstone.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -52,6 +52,12 @@
5252
#include <inttypes.h>
5353
#include <string.h>
5454

55+
/* Undefine macro to avoid generating invalid C code.
56+
Capstone refactored cs_detail for AArch64 architecture
57+
from `cs_arm64 arm64` to `cs_aarch64 aarch64`
58+
and that causes invalid macro expansion.
59+
*/
60+
#undef aarch64
5561
#include <capstone.h>
5662

5763
#include "hsdis.h"

0 commit comments

Comments
 (0)