bad reloc address 0x0 when compiling hsdis (Java HotSpot disassembler plugin) on cygwin

匿名 (未验证) 提交于 2019-12-03 01:20:02

问题:

I'm trying to compile the hsdis-amd64.dll library that the JVM needs to disassemble JIT compiled code.

I followed this accepted answer.

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 

First I tried to just compile it using:

$ make OS=Linux MINGW=x86_64-w64-mingw32 BINUTILS=../binutils-2.24 

but it failed with

/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.

The compilation failed 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 ^ 

I followed the proposal of the compiler and added config.h just before the errno.h include.

Then the error is

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.

Does anyone knows how to solve this problem or can tell me how to compile the hsdis (HotSpot disassembler plugin)?

回答1:

There is need to add linking against zlib (Be sure that you install package mingw64-x86_64-zlib in cygwin).

Then open Makefile in editor, find rule:

$(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR)     $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES) 

Add "-static -lz" to second line to make that:

$(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR)     $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES) -static -lz 


回答2:

The problem could be solved following Marat Buharov's answer.

Nevertheless here are some links where you can find a pre-comiled hsdis plugin:

I tried http://lafo.ssw.uni-linz.ac.at/hsdis/intel/hsdis-amd64.dll with jdk1.7.0_02 and it worked.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!