在cygwin上编译hsdis(Java HotSpot反汇编插件)时,错误的reloc地址0x0 [英] bad reloc address 0x0 when compiling hsdis (Java HotSpot disassembler plugin) on cygwin
问题描述
我试图编译JVM需要反汇编JIT编译代码的 hsdis-amd64.dll
库。
I'm trying to compile the hsdis-amd64.dll
library that the JVM needs to disassemble JIT compiled code.
我遵循此接受的答案。
- 我安装了cygwin
- 已下载 openjdk-7u40-fcs-src-b43-26_aug_2013.zip
- 并下载了 binutils-2.24.tar.gz
- I installed cygwin
- downloaded openjdk-7u40-fcs-src-b43-26_aug_2013.zip
- and downloaded binutils-2.24.tar.gz
我创建了一个这样的文件夹结构:
I created a folder structure like 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.
所以我应用了接受答案并再次尝试。
So I applied the patch provided in this accepted answer and tried again.
失败了
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
c $ c> errno.h include。
I followed the proposal of the compiler and added config.h
just before the errno.h
include.
然后错误是
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
我知道这是一个链接器问题。对我来说,它似乎是试图链接到一个错误的版本,但我可能是错误的。
I know that it is a linker problem. For me it seems that it is trying to link against a wrong version, but I might be wrong.
有人知道如何解决这个问题或可以告诉我如何编译hsdis(HotSpot反汇编插件)?
Does anyone knows how to solve this problem or can tell me how to compile the hsdis (HotSpot disassembler plugin)?
推荐答案
需要添加对zlib的链接(确保安装包mingw64 -x86_64-zlib in cygwin)。
There is need to add linking against zlib (Be sure that you install package mingw64-x86_64-zlib in cygwin).
在编辑器中打开Makefile,找到规则:
Open Makefile in editor, find rule:
$(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR)
$(CC) $(OUTFLAGS) $(CPPFLAGS) $(CFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES)
将-static -lz添加到第二行,以便:
Add "-static -lz" to second line to make that:
$(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR)
$(CC) $(OUTFLAGS) $(CPPFLAGS) $(CFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES) -static -lz
这篇关于在cygwin上编译hsdis(Java HotSpot反汇编插件)时,错误的reloc地址0x0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!