Blame jdk8073139-pr2236-rh1191652--use_ppc64le_as_the_arch_directory_on_that_platform_and_report_it_in_os_arch_aarch64_forest.patch

deb3d7b
# HG changeset patch
Severin Gehwolf 7c7bff6
# User sgehwolf
Severin Gehwolf 7c7bff6
# Date 1537885415 -7200
Severin Gehwolf 7c7bff6
#      Tue Sep 25 16:23:35 2018 +0200
Severin Gehwolf 7c7bff6
# Node ID 5044428520866481f438bfd1375da75adbc89243
Severin Gehwolf 7c7bff6
# Parent  a3df1579a8647b06559f41d345da7bea162b26e9
Severin Gehwolf 7c7bff6
8073139: PPC64: User-visible arch directory and os.arch value on ppc64le cause issues with Java tooling
Severin Gehwolf 7c7bff6
Reviewed-by: erikj, goetz, dholmes
deb3d7b
Severin Gehwolf 7c7bff6
diff --git a/make/defs.make b/make/defs.make
Severin Gehwolf 7c7bff6
--- openjdk/hotspot/make/defs.make
Severin Gehwolf 7c7bff6
+++ openjdk/hotspot/make/defs.make
Severin Gehwolf 7c7bff6
@@ -285,7 +285,7 @@ ifneq ($(OSNAME),windows)
deb3d7b
 
Severin Gehwolf 7c7bff6
   # Use uname output for SRCARCH, but deal with platform differences. If ARCH
Severin Gehwolf 7c7bff6
   # is not explicitly listed below, it is treated as x86.
Severin Gehwolf 7c7bff6
-  SRCARCH    ?= $(ARCH/$(filter sparc sparc64 ia64 amd64 x86_64 ppc ppc64 zero aarch64,$(ARCH)))
Severin Gehwolf 7c7bff6
+  SRCARCH    ?= $(ARCH/$(filter sparc sparc64 ia64 amd64 x86_64 ppc ppc64 ppc64le zero aarch64,$(ARCH)))
Severin Gehwolf 7c7bff6
   ARCH/       = x86
Severin Gehwolf 7c7bff6
   ARCH/sparc  = sparc
Severin Gehwolf 7c7bff6
   ARCH/sparc64= sparc
Severin Gehwolf 7c7bff6
@@ -293,6 +293,7 @@ ifneq ($(OSNAME),windows)
Severin Gehwolf 7c7bff6
   ARCH/amd64  = x86
Severin Gehwolf 7c7bff6
   ARCH/x86_64 = x86
Severin Gehwolf 7c7bff6
   ARCH/ppc64  = ppc
Severin Gehwolf 7c7bff6
+  ARCH/ppc64le= ppc
Severin Gehwolf 7c7bff6
   ARCH/ppc    = ppc
Severin Gehwolf 7c7bff6
   ARCH/zero   = zero
Severin Gehwolf 7c7bff6
   ARCH/aarch64 = aarch64
Severin Gehwolf 7c7bff6
@@ -316,7 +317,12 @@
Severin Gehwolf 7c7bff6
     endif
Severin Gehwolf 7c7bff6
   endif
deb3d7b
 
Severin Gehwolf 7c7bff6
-  # LIBARCH is 1:1 mapping from BUILDARCH
Severin Gehwolf 7c7bff6
+  # LIBARCH is 1:1 mapping from BUILDARCH, except for ARCH=ppc64le
Severin Gehwolf 7c7bff6
+  ifeq ($(ARCH),ppc64le)
Severin Gehwolf 7c7bff6
+    LIBARCH      ?= ppc64le
Severin Gehwolf 7c7bff6
+  else
Severin Gehwolf 7c7bff6
+    LIBARCH      ?= $(LIBARCH/$(BUILDARCH))
Severin Gehwolf 7c7bff6
+  endif
Severin Gehwolf 7c7bff6
   LIBARCH        ?= $(LIBARCH/$(BUILDARCH))
Severin Gehwolf 7c7bff6
   LIBARCH/i486    = i386
Severin Gehwolf 7c7bff6
   LIBARCH/amd64   = amd64
Severin Gehwolf 7c7bff6
diff --git a/src/os/linux/vm/os_linux.cpp b/src/os/linux/vm/os_linux.cpp
Severin Gehwolf 7c7bff6
--- openjdk/hotspot/src/os/linux/vm/os_linux.cpp
Severin Gehwolf 7c7bff6
+++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp
Severin Gehwolf 7c7bff6
@@ -1956,7 +1956,7 @@
Severin Gehwolf 7c7bff6
     {EM_SPARCV9,     EM_SPARCV9, ELFCLASS64, ELFDATA2MSB, (char*)"Sparc v9 64"},
Severin Gehwolf 7c7bff6
     {EM_PPC,         EM_PPC,     ELFCLASS32, ELFDATA2MSB, (char*)"Power PC 32"},
Severin Gehwolf 7c7bff6
 #if defined(VM_LITTLE_ENDIAN)
Severin Gehwolf 7c7bff6
-    {EM_PPC64,       EM_PPC64,   ELFCLASS64, ELFDATA2LSB, (char*)"Power PC 64"},
Severin Gehwolf 7c7bff6
+    {EM_PPC64,       EM_PPC64,   ELFCLASS64, ELFDATA2LSB, (char*)"Power PC 64 LE"},
Severin Gehwolf 7c7bff6
 #else
Severin Gehwolf 7c7bff6
     {EM_PPC64,       EM_PPC64,   ELFCLASS64, ELFDATA2MSB, (char*)"Power PC 64"},
Severin Gehwolf 7c7bff6
 #endif
Severin Gehwolf 7c7bff6
diff --git a/src/share/tools/hsdis/Makefile b/src/share/tools/hsdis/Makefile
Severin Gehwolf 7c7bff6
--- openjdk/hotspot/src/share/tools/hsdis/Makefile
Severin Gehwolf 7c7bff6
+++ openjdk/hotspot/src/share/tools/hsdis/Makefile
Severin Gehwolf 7c7bff6
@@ -97,6 +97,7 @@
Severin Gehwolf 7c7bff6
 CFLAGS/sparcv9	+= -m64
Severin Gehwolf 7c7bff6
 CFLAGS/amd64	+= -m64
Severin Gehwolf 7c7bff6
 CFLAGS/ppc64	+= -m64
Severin Gehwolf 7c7bff6
+CFLAGS/ppc64le  += -m64 -DABI_ELFv2
Severin Gehwolf 7c7bff6
 else
Severin Gehwolf 7c7bff6
 ARCH=$(ARCH1:amd64=i386)
Severin Gehwolf 7c7bff6
 CFLAGS/i386	+= -m32
Severin Gehwolf 7c7bff6
diff --git a/src/share/tools/hsdis/hsdis-demo.c b/src/share/tools/hsdis/hsdis-demo.c
Severin Gehwolf 7c7bff6
--- openjdk/hotspot/src/share/tools/hsdis/hsdis-demo.c
Severin Gehwolf 7c7bff6
+++ openjdk/hotspot/src/share/tools/hsdis/hsdis-demo.c
Severin Gehwolf 7c7bff6
@@ -88,7 +88,7 @@
Severin Gehwolf 7c7bff6
   printf("...And now for something completely different:\n");
Severin Gehwolf 7c7bff6
   void *start = (void*) &mai;;
Severin Gehwolf 7c7bff6
   void *end = (void*) &end_of_file;
Severin Gehwolf 7c7bff6
-#if defined(__ia64) || defined(__powerpc__)
Severin Gehwolf 7c7bff6
+#if defined(__ia64) || (defined(__powerpc__) && !defined(ABI_ELFv2))
Severin Gehwolf 7c7bff6
   /* On IA64 and PPC function pointers are pointers to function descriptors */
Severin Gehwolf 7c7bff6
   start = *((void**)start);
Severin Gehwolf 7c7bff6
   end = *((void**)end);
Severin Gehwolf 7c7bff6
diff --git a/src/share/tools/hsdis/hsdis.c b/src/share/tools/hsdis/hsdis.c
Severin Gehwolf 7c7bff6
--- openjdk/hotspot/src/share/tools/hsdis/hsdis.c
Severin Gehwolf 7c7bff6
+++ openjdk/hotspot/src/share/tools/hsdis/hsdis.c
Severin Gehwolf 7c7bff6
@@ -461,7 +461,7 @@ static const char* native_arch_name() {
Severin Gehwolf 7c7bff6
 #ifdef LIBARCH_sparcv9
Severin Gehwolf 7c7bff6
   res = "sparc:v9b";
Severin Gehwolf 7c7bff6
 #endif
Severin Gehwolf 7c7bff6
-#ifdef LIBARCH_ppc64
Severin Gehwolf 7c7bff6
+#if defined(LIBARCH_ppc64) || defined(LIBARCH_ppc64le)
Severin Gehwolf 7c7bff6
   res = "powerpc:common64";
Severin Gehwolf 7c7bff6
 #endif
Severin Gehwolf 7c7bff6
 #else
Severin Gehwolf 7c7bff6
diff --git a/src/share/vm/runtime/vm_version.cpp b/src/share/vm/runtime/vm_version.cpp
Severin Gehwolf 7c7bff6
--- openjdk/hotspot/src/share/vm/runtime/vm_version.cpp
Severin Gehwolf 7c7bff6
+++ openjdk/hotspot/src/share/vm/runtime/vm_version.cpp
Severin Gehwolf 7c7bff6
@@ -187,11 +187,16 @@ const char* Abstract_VM_Version::jre_release_version() {
Severin Gehwolf 7c7bff6
 #ifndef CPU
Severin Gehwolf 7c7bff6
 #ifdef ZERO
Severin Gehwolf 7c7bff6
 #define CPU      ZERO_LIBARCH
Severin Gehwolf 7c7bff6
+#elif defined(PPC64)
Severin Gehwolf 7c7bff6
+#if defined(VM_LITTLE_ENDIAN)
Severin Gehwolf 7c7bff6
+#define CPU      "ppc64le"
Severin Gehwolf 7c7bff6
+#else
Severin Gehwolf 7c7bff6
+#define CPU      "ppc64"
Severin Gehwolf 7c7bff6
+#endif
Severin Gehwolf 7c7bff6
 #else
Severin Gehwolf 7c7bff6
 #define CPU      IA32_ONLY("x86")                \
Severin Gehwolf 7c7bff6
                  IA64_ONLY("ia64")               \
Severin Gehwolf 7c7bff6
                  AMD64_ONLY("amd64")             \
Severin Gehwolf 7c7bff6
-                 PPC64_ONLY("ppc64")             \
Severin Gehwolf 7c7bff6
                  AARCH64_ONLY("aarch64")	 \
Severin Gehwolf 7c7bff6
                  SPARC_ONLY("sparc")
Severin Gehwolf 7c7bff6
 #endif // ZERO
Severin Gehwolf 7c7bff6
diff --git a/test/test_env.sh b/test/test_env.sh
Severin Gehwolf 7c7bff6
--- openjdk/hotspot/test/test_env.sh
Severin Gehwolf 7c7bff6
+++ openjdk/hotspot/test/test_env.sh
Severin Gehwolf 7c7bff6
@@ -185,6 +185,15 @@
Severin Gehwolf 7c7bff6
 if [ $? = 0 ]
Severin Gehwolf 7c7bff6
 then
Severin Gehwolf 7c7bff6
   VM_CPU="ppc"
Severin Gehwolf 7c7bff6
+  if [ $VM_BITS = "64" ]
Severin Gehwolf 7c7bff6
+  then
Severin Gehwolf 7c7bff6
+    VM_CPU="ppc64"
Severin Gehwolf 7c7bff6
+    grep "ppc64le" vm_version.out > ${NULL}
Severin Gehwolf 7c7bff6
+    if [ $? = 0 ]
Severin Gehwolf 7c7bff6
+    then
Severin Gehwolf 7c7bff6
+      VM_CPU="ppc64le"
Severin Gehwolf 7c7bff6
+    fi
Severin Gehwolf 7c7bff6
+  fi
Severin Gehwolf 7c7bff6
 fi
Severin Gehwolf 7c7bff6
 grep "ia64" vm_version.out > ${NULL}
Severin Gehwolf 7c7bff6
 if [ $? = 0 ]