2014-01-10 81 views
4

我正在编译JVM需要反编译JIT编译代码的hsdis-amd64.dll库。在cygwin上编译hsdis(Java HotSpot反汇编程序插件)时出现错误的重定位地址0x0

我跟着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之前的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反汇编程序插件)?

回答

2

需要添加链接以防止zlib(请确保您在cygwin中安装了软件包mingw64-x86_64-zlib)。 correct zlib package for x86_64

然后在编辑器中打开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 
+0

你需要安装包mingw64-x86_64的-zlib在cygwin中。 –

+0

我刚更新了我的答案。 –

+0

我编译了hsdis-amd64.dll,效果很好。 –