0

So I am trying to build/use hsdis with openJDK-11. if I try to build it with binutils I get the following errors:

hsdis.c:316:32: error: incompatible type for argument 1 of ‘disassembler'
app_data->dfn = disassembler(native_bfd);

hsdis.c:316:19: error: too few arguments to function ‘disassembler’
app_data->dfn = disassembler(native_bfd);

I have tried building it with binutils 2.29, 2.30, 2.31 and 2.32. Got same error with all of them.

If I take a prebuilt binary from JDK-8 and place it in my build folder of JDK, netbeans refuses to acknowledge it is present in the folder. I have set up OpenJDK in netbeans and generated a slowdebug build. I tried running it step by step to see where exactly hsdis is being searched for, to my surprise it does look in the folder where I placed the file however it still says no such file or directory. For me that folder is

home/ubuntu/jdk11u-dev/build/linux-x86_64-normal-server-slowdebug/images/jdk/lib/server

I am using VMWare and running Ubuntu 18.04. Any ideas what I can do?

3
  • The version of the source you have does not work with binutils 2.29+. jdk/jdk has a patch to rectify this. See: bugs.openjdk.java.net/browse/JDK-8191006 May 12, 2019 at 21:15
  • I was finally able to build it. Thank you. Netbeans still does not load it though, do you happen to know what could be the issue?
    – Tehreem
    May 12, 2019 at 23:09
  • ok it worked by placing the .so file in /home/ubuntu/jdk11u-dev/build/linux-x86_64-normal-server-slowdebug/images/jdk/lib/server/ and changing it's name to libhsdis-amd64.so. Can you please post your link as answer so I can accept it?
    – Tehreem
    May 13, 2019 at 5:50

1 Answer 1

2

I have tried building it with binutils 2.29, 2.30, 2.31 and 2.32. Got same error with all of them.

The version of the source you have does not work with binutils 2.29+. jdk/jdk has a patch to rectify this. See: https://bugs.openjdk.java.net/browse/JDK-8191006 Which suggests the following fix to hsdis.c:

diff --git a/src/share/tools/hsdis/hsdis.c b/src/share/tools/hsdis/hsdis.c
index 3d038f1..88122fb 100644
--- a/src/share/tools/hsdis/hsdis.c
+++ b/src/share/tools/hsdis/hsdis.c
@@ -30,6 +30,7 @@
 #include <config.h> /* required by bfd.h */
 #include <libiberty.h>
 #include <bfd.h>
+#include <bfdver.h>
 #include <dis-asm.h>
 #include <inttypes.h>
 #include <string.h>
@@ -312,7 +313,13 @@ static void setup_app_data(struct hsdis_app_data* app_data,

  /* Finish linking together the various callback blocks. */
  app_data->dinfo.application_data = (void*) app_data;
- app_data->dfn = disassembler(native_bfd);
+ app_data->dfn = disassembler(
+#if BFD_VERSION >= 229000000
+ bfd_get_arch(native_bfd),
+ bfd_big_endian(native_bfd),
+ bfd_get_mach(native_bfd),
+#endif
+ native_bfd);
  app_data->dinfo.print_address_func = hsdis_print_address_func;
  app_data->dinfo.read_memory_func = hsdis_read_memory_func; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.