Blame SOURCES/jdk8073139-pr2236-rh1191652--use_ppc64le_as_the_arch_directory_on_that_platform_and_report_it_in_os_arch_aarch64_forest.patch

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