Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8185567

fix hsdis cpu to architecture mapping on various Linux platforms

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 10
    • 10
    • hotspot
    • b21
    • linux

      OOTB linux builds of hsdis often result in binaries targeted to the "wrong" architecture on the following platforms:

      arm (32-bit)
      ia32
      sparcv9

      === arm (32-bit) example ===
      $ ls orig/hsdis/build/linux-armv6l/hsdis*
      orig/hsdis/build/linux-armv6l/hsdis-armv6l.so
      $ LD_LIBRARY_PATH=orig/hsdis/build/linux-armv6l/ java/jdk1.8.0_141/bin/java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -version
      Java HotSpot(TM) Client VM warning: PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output
      Could not load hsdis-arm.so; library not loadable; PrintAssembly is disabled
      ===

      === ia32 x86 example ===
      $ ls ../orig/hsdis/build/linux-i686/hsdis*
      ../orig/hsdis/build/linux-i686/hsdis-i686.so
      $ LD_LIBRARY_PATH=../orig/hsdis/build/linux-i686/ jdk1.8.0_141/bin/java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -version
      Java HotSpot(TM) Server VM warning: PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output
      Could not load hsdis-i386.so; library not loadable; PrintAssembly is disabled
      ===

      === sparcv9 example ===
      $ ls ../orig/hsdis/build/linux-sparc64/hsdis*
      ../orig/hsdis/build/linux-sparc64/hsdis-sparc64.so
      $ LD_LIBRARY_PATH=../orig/hsdis/build/linux-sparc64/ jdk1.8.0_141/bin/java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -version
      Java HotSpot(TM) 64-Bit Server VM warning: PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output
      Could not load hsdis-sparcv9.so; library not loadable; PrintAssembly is disabled
      ===

      Of course, it is not just a matter of the resulting library file name:

      === ia32 example ===
      $ mv ../orig/hsdis/build/linux-i686/hsdis-i686.so ../orig/hsdis/build/linux-i686/hsdis-i386.so
      $ LD_LIBRARY_PATH=../orig/hsdis/build/linux-i686/ jdk1.8.0_141/bin/java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -version
      Java HotSpot(TM) Server VM warning: PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output
      Loaded disassembler from hsdis-i386.so
      Decoding compiled method 0xa77a15c8:
      Code:
      hsdis: bad native mach=architecture not set in Makefile!; please port hsdis to this platform
      ===

      For sparcv9 and ia32, simple Makefile fixes are all that is needed. For 32-bit arm, we also need to add an "arm" architecture to hsdis.c.

      After fixing this, the following mappings between "uname -m" output and ARCH should work:

      i686 -> i386
      sparc64 -> sparcv9
      *arm* -> arm

      (There are so many variations on 32-bit arm (armel, armeb, armv6l,etc) that the only reasonable thing to do seems to be to map all strings with "arm" in them to "arm". This is not a problem because Linux always seems to use aarch64 for 64-bit arm. We seem to only come across "arm64" on iOS or as an LLVM target.)

            dbuck David Buck
            dbuck David Buck
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: