mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8277089: Use system binutils to build hsdis
Reviewed-by: ihse
This commit is contained in:
parent
f3eb5014aa
commit
d5e47d6b84
@ -817,26 +817,53 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_HSDIS],
|
||||
BINUTILS_DIR="$with_binutils"
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for binutils to use with hsdis])
|
||||
if test "x$BINUTILS_DIR" != x; then
|
||||
binutils_system_error=""
|
||||
HSDIS_LIBS=""
|
||||
if test "x$BINUTILS_DIR" = xsystem; then
|
||||
AC_CHECK_LIB(bfd, bfd_openr, [ HSDIS_LIBS="-lbfd" ], [ binutils_system_error="libbfd not found" ])
|
||||
AC_CHECK_LIB(opcodes, disassembler, [ HSDIS_LIBS="$HSDIS_LIBS -lopcodes" ], [ binutils_system_error="libopcodes not found" ])
|
||||
AC_CHECK_LIB(iberty, xmalloc, [ HSDIS_LIBS="$HSDIS_LIBS -liberty" ], [ binutils_system_error="libiberty not found" ])
|
||||
AC_CHECK_LIB(z, deflate, [ HSDIS_LIBS="$HSDIS_LIBS -lz" ], [ binutils_system_error="libz not found" ])
|
||||
elif test "x$BINUTILS_DIR" != x; then
|
||||
if test -e $BINUTILS_DIR/bfd/libbfd.a && \
|
||||
test -e $BINUTILS_DIR/opcodes/libopcodes.a && \
|
||||
test -e $BINUTILS_DIR/libiberty/libiberty.a; then
|
||||
AC_MSG_RESULT([$BINUTILS_DIR])
|
||||
HSDIS_CFLAGS="-I$BINUTILS_DIR/include -I$BINUTILS_DIR/bfd -DLIBARCH_$OPENJDK_TARGET_CPU_LEGACY_LIB"
|
||||
HSDIS_LIBS="$BINUTILS_DIR/bfd/libbfd.a $BINUTILS_DIR/opcodes/libopcodes.a $BINUTILS_DIR/libiberty/libiberty.a $BINUTILS_DIR/zlib/libz.a"
|
||||
else
|
||||
AC_MSG_RESULT([invalid])
|
||||
AC_MSG_ERROR([$BINUTILS_DIR does not contain a proper binutils installation])
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT([missing])
|
||||
AC_MSG_NOTICE([--with-hsdis=binutils requires specifying a binutils installation.])
|
||||
AC_MSG_NOTICE([Download binutils from https://www.gnu.org/software/binutils and unpack it,])
|
||||
AC_MSG_NOTICE([and point --with-binutils-src to the resulting directory, or use])
|
||||
AC_MSG_NOTICE([--with-binutils to point to a pre-built binutils installation.])
|
||||
AC_MSG_ERROR([Cannot continue])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for binutils to use with hsdis])
|
||||
case "x$BINUTILS_DIR" in
|
||||
xsystem)
|
||||
if test "x$OPENJDK_TARGET_OS" != xlinux; then
|
||||
AC_MSG_RESULT([invalid])
|
||||
AC_MSG_ERROR([binutils on system is supported for Linux only])
|
||||
elif test "x$binutils_system_error" = x; then
|
||||
AC_MSG_RESULT([system])
|
||||
HSDIS_CFLAGS="-DSYSTEM_BINUTILS"
|
||||
else
|
||||
AC_MSG_RESULT([invalid])
|
||||
AC_MSG_ERROR([$binutils_system_error])
|
||||
fi
|
||||
;;
|
||||
x)
|
||||
AC_MSG_RESULT([missing])
|
||||
AC_MSG_NOTICE([--with-hsdis=binutils requires specifying a binutils installation.])
|
||||
AC_MSG_NOTICE([Download binutils from https://www.gnu.org/software/binutils and unpack it,])
|
||||
AC_MSG_NOTICE([and point --with-binutils-src to the resulting directory, or use])
|
||||
AC_MSG_NOTICE([--with-binutils to point to a pre-built binutils installation.])
|
||||
AC_MSG_ERROR([Cannot continue])
|
||||
;;
|
||||
*)
|
||||
if test "x$HSDIS_LIBS" != x; then
|
||||
AC_MSG_RESULT([$BINUTILS_DIR])
|
||||
else
|
||||
AC_MSG_RESULT([invalid])
|
||||
AC_MSG_ERROR([$BINUTILS_DIR does not contain a proper binutils installation])
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
else
|
||||
AC_MSG_RESULT([invalid])
|
||||
AC_MSG_ERROR([Incorrect hsdis backend "$with_hsdis"])
|
||||
|
||||
@ -67,6 +67,10 @@ you can replace it with "--with-binutils=<location>".
|
||||
If you have pre-built binutils binaries, you can point to them directly using
|
||||
"--with-binutils=<location>".
|
||||
|
||||
If you want to build hsdis with binutils provided by system
|
||||
(e.g. binutils-devel from Fedora, binutils-dev from Ubuntu), you can pass
|
||||
"--with-binutils=system". "system" is available on Linux only.
|
||||
|
||||
When you have created a proper configuration, you can then build the hsdis
|
||||
library using "make build-hsdis".
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2021, 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
|
||||
@ -49,14 +49,16 @@
|
||||
HotSpot PrintAssembly option.
|
||||
*/
|
||||
|
||||
#ifndef SYSTEM_BINUTILS
|
||||
#include <config.h> /* required by bfd.h */
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libiberty.h>
|
||||
#include <bfd.h>
|
||||
#include <bfdver.h>
|
||||
#include <dis-asm.h>
|
||||
|
||||
#include "hsdis.h"
|
||||
@ -565,7 +567,7 @@ static void init_disassemble_info_from_bfd(struct disassemble_info* dinfo,
|
||||
dinfo->arch = bfd_get_arch(abfd);
|
||||
dinfo->mach = bfd_get_mach(abfd);
|
||||
dinfo->disassembler_options = disassembler_options;
|
||||
#if BFD_VERSION >= 234000000
|
||||
#ifdef SEC_ELF_OCTETS
|
||||
/* bfd_octets_per_byte() has 2 args since binutils 2.34 */
|
||||
dinfo->octets_per_byte = bfd_octets_per_byte (abfd, NULL);
|
||||
#else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user