我正在尝试编译 JVM 反汇编 JIT 编译代码所需的 hsdis-amd64.dll
库。
我遵循了 this 接受的答案。
我创建了这样的文件夹结构:
+
+- hsdis // unzipped dir hotspot/src/share/tools/hsdis of openjdk zip
+- binutils-2.24 // unzipped binutils-2.24.tar.gz
首先,我尝试使用以下方法编译它:
$ make OS=Linux MINGW=x86_64-w64-mingw32 BINUTILS=../binutils-2.24
但它失败了
/Linux-amd64/opcodes/libopcodes.a build/Linux-amd64/libiberty/libiberty.a
hsdis.c:32:20: fatal error: sysdep.h: No such file or directory
#include <sysdep.h>
^
compilation terminated.
所以我应用了 this accepted answer 中提供的补丁并再次尝试。
编译再次失败
In file included from hsdis.c:34:0:
build/Linux-amd64/bfd/bfd.h:35:2: error: #error config.h must be included before this header
#error config.h must be included before this header
^
我按照编译器的建议,在
config.h
include 之前添加了 errno.h
。然后错误是
e -I../binutils-2.24/bfd -Ibuild/Linux-amd64/bfd -DLIBARCH_amd64 -DLIBARCH=\"amd64\" -DLIB_EXT=\".dll\" -O hsdis.c -shared build/Linux-amd64/bfd/libbfd.a build/Linux-amd64/opcodes/libopcodes.a build/Linux-amd64/libiberty/libiberty.a
build/Linux-amd64/bfd/libbfd.a(compress.o):compress.c:(.text+0x15): undefined reference to `compressBound'
build/Linux-amd64/bfd/libbfd.a(compress.o):compress.c:(.text+0x48): undefined reference to `compress'
build/Linux-amd64/bfd/libbfd.a(compress.o):compress.c:(.text+0x28a): undefined reference to `inflateInit_'
build/Linux-amd64/bfd/libbfd.a(compress.o):compress.c:(.text+0x2c7): undefined reference to `inflate'
build/Linux-amd64/bfd/libbfd.a(compress.o):compress.c:(.text+0x2d6): undefined reference to `inflateReset'
build/Linux-amd64/bfd/libbfd.a(compress.o):compress.c:(.text+0x2f1): undefined reference to `inflateEnd'
/usr/lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld: build/Linux-amd64/bfd/libbfd.a(compress.o): bad reloc address 0x0 in section `.pdata'
collect2: error: ld returned 1 exit status
我知道这是一个链接器问题。对我来说,它似乎试图链接到错误的版本,但我可能是错的。
有谁知道如何解决这个问题,或者可以告诉我如何编译 hsdis(HotSpot 反汇编插件)?
最佳答案
需要添加针对 zlib 的链接(确保在 cygwin 中安装包 mingw64-x86_64-zlib)。
然后在编辑器中打开 Makefile,找到规则:
$(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR)
$(CC) $(OUTFLAGS) $(CPPFLAGS) $(CFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES)
将“-static -lz”添加到第二行以使其:
$(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR)
$(CC) $(OUTFLAGS) $(CPPFLAGS) $(CFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES) -static -lz
关于java - 在 cygwin 上编译 hsdis(Java HotSpot 反汇编器插件)时出现错误的 reloc 地址 0x0,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21042809/