8073139: PPC64: User-visible arch directory and os.arch value on ppc64le cause issues with Java tooling
Summary: Set LIBARCH to ppc64le, make SA and hsdis work, have os.arch return ppc64le on PowerPC64 LE
Reviewed-by: dholmes, ihse
Contributed-by: Andrew Hughes <gnu.andrew@redhat.com>, Alexander Smundak <asmundak@google.com>
--- a/hotspot/agent/src/os/linux/LinuxDebuggerLocal.c Sat Dec 12 21:23:20 2015 +0300
+++ b/hotspot/agent/src/os/linux/LinuxDebuggerLocal.c Sun Dec 13 22:32:16 2015 -0500
@@ -49,7 +49,7 @@
#include "sun_jvm_hotspot_debugger_sparc_SPARCThreadContext.h"
#endif
-#ifdef ppc64
+#if defined(ppc64) || defined(ppc64le)
#include "sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext.h"
#endif
@@ -352,7 +352,7 @@
return (err == PS_OK)? array : 0;
}
-#if defined(i386) || defined(amd64) || defined(sparc) || defined(sparcv9) | defined(ppc64) || defined(aarch64)
+#if defined(i386) || defined(amd64) || defined(sparc) || defined(sparcv9) | defined(ppc64) || defined(ppc64le) || defined(aarch64)
JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_getThreadIntegerRegisterSet0
(JNIEnv *env, jobject this_obj, jint lwp_id) {
@@ -380,7 +380,7 @@
#if defined(sparc) || defined(sparcv9)
#define NPRGREG sun_jvm_hotspot_debugger_sparc_SPARCThreadContext_NPRGREG
#endif
-#ifdef ppc64
+#if defined(ppc64) || defined(ppc64le)
#define NPRGREG sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext_NPRGREG
#endif
@@ -489,7 +489,7 @@
}
#endif /* aarch64 */
-#ifdef ppc64
+#if defined(ppc64) || defined(ppc64le)
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext_##reg
regs[REG_INDEX(LR)] = gregs.link;
--- a/hotspot/agent/src/os/linux/libproc.h Sat Dec 12 21:23:20 2015 +0300
+++ b/hotspot/agent/src/os/linux/libproc.h Sun Dec 13 22:32:16 2015 -0500
@@ -68,7 +68,7 @@
*************************************************************************************/
-#if defined(sparc) || defined(sparcv9) || defined(ppc64)
+#if defined(sparc) || defined(sparcv9) || defined(ppc64) || defined(ppc64le)
#include <asm/ptrace.h>
#define user_regs_struct pt_regs
#endif
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java Sat Dec 12 21:23:20 2015 +0300
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java Sun Dec 13 22:32:16 2015 -0500
@@ -54,7 +54,7 @@
public static boolean knownCPU(String cpu) {
final String[] KNOWN =
- new String[] {"i386", "x86", "x86_64", "amd64", "sparc", "sparcv9", "ppc64", "aarch64"};
+ new String[] {"i386", "x86", "x86_64", "amd64", "sparc", "sparcv9", "ppc64", "ppc64le", "aarch64"};
for(String s : KNOWN) {
if(s.equals(cpu))
@@ -98,6 +98,9 @@
if (cpu.equals("x86_64"))
return "amd64";
+ if (cpu.equals("ppc64le"))
+ return "ppc64";
+
return cpu;
}
--- a/hotspot/make/defs.make Sat Dec 12 21:23:20 2015 +0300
+++ b/hotspot/make/defs.make Sun Dec 13 22:32:16 2015 -0500
@@ -277,7 +277,7 @@
# Use uname output for SRCARCH, but deal with platform differences. If ARCH
# is not explicitly listed below, it is treated as x86.
- SRCARCH ?= $(ARCH/$(filter sparc sparc64 ia64 amd64 x86_64 ppc ppc64 aarch64 zero,$(ARCH)))
+ SRCARCH ?= $(ARCH/$(filter sparc sparc64 ia64 amd64 x86_64 ppc ppc64 ppc64le aarch64 zero,$(ARCH)))
ARCH/ = x86
ARCH/sparc = sparc
ARCH/sparc64= sparc
@@ -285,6 +285,7 @@
ARCH/amd64 = x86
ARCH/x86_64 = x86
ARCH/ppc64 = ppc
+ ARCH/ppc64le= ppc
ARCH/ppc = ppc
ARCH/aarch64= aarch64
ARCH/zero = zero
@@ -309,8 +310,13 @@
endif
endif
- # LIBARCH is 1:1 mapping from BUILDARCH
- LIBARCH ?= $(LIBARCH/$(BUILDARCH))
+ # LIBARCH is 1:1 mapping from BUILDARCH, except for ARCH=ppc64le
+ ifeq ($(ARCH),ppc64le)
+ LIBARCH ?= ppc64le
+ else
+ LIBARCH ?= $(LIBARCH/$(BUILDARCH))
+ endif
+
LIBARCH/i486 = i386
LIBARCH/amd64 = amd64
LIBARCH/sparc = sparc
--- a/hotspot/src/os/linux/vm/os_linux.cpp Sat Dec 12 21:23:20 2015 +0300
+++ b/hotspot/src/os/linux/vm/os_linux.cpp Sun Dec 13 22:32:16 2015 -0500
@@ -1733,7 +1733,7 @@
#if defined(VM_LITTLE_ENDIAN)
{EM_PPC64, EM_PPC64, ELFCLASS64, ELFDATA2LSB, (char*)"Power PC 64"},
#else
- {EM_PPC64, EM_PPC64, ELFCLASS64, ELFDATA2MSB, (char*)"Power PC 64"},
+ {EM_PPC64, EM_PPC64, ELFCLASS64, ELFDATA2MSB, (char*)"Power PC 64 LE"},
#endif
{EM_ARM, EM_ARM, ELFCLASS32, ELFDATA2LSB, (char*)"ARM"},
{EM_S390, EM_S390, ELFCLASSNONE, ELFDATA2MSB, (char*)"IBM System/390"},
@@ -2177,6 +2177,8 @@
const char* search_string = "model name";
#elif defined(SPARC)
const char* search_string = "cpu";
+#elif defined(PPC64)
+const char* search_string = "cpu";
#else
const char* search_string = "Processor";
#endif
--- a/hotspot/src/share/tools/hsdis/Makefile Sat Dec 12 21:23:20 2015 +0300
+++ b/hotspot/src/share/tools/hsdis/Makefile Sun Dec 13 22:32:16 2015 -0500
@@ -70,12 +70,12 @@
else #linux
CPU = $(shell uname -m)
ARCH1=$(CPU:x86_64=amd64)
-ARCH2=$(ARCH1:i686=i386)
-ARCH=$(ARCH2:ppc64le=ppc64)
+ARCH=$(ARCH1:i686=i386)
ifdef LP64
CFLAGS/sparcv9 += -m64
CFLAGS/amd64 += -m64
CFLAGS/ppc64 += -m64
+CFLAGS/ppc64le += -m64 -DABI_ELFv2
else
ARCH=$(ARCH1:amd64=i386)
CFLAGS/i386 += -m32
--- a/hotspot/src/share/tools/hsdis/hsdis-demo.c Sat Dec 12 21:23:20 2015 +0300
+++ b/hotspot/src/share/tools/hsdis/hsdis-demo.c Sun Dec 13 22:32:16 2015 -0500
@@ -66,7 +66,7 @@
printf("...And now for something completely different:\n");
void *start = (void*) &main;
void *end = (void*) &end_of_file;
-#if defined(__ia64) || defined(__powerpc__)
+#if defined(__ia64) || (defined(__powerpc__) && !defined(ABI_ELFv2))
/* On IA64 and PPC function pointers are pointers to function descriptors */
start = *((void**)start);
end = *((void**)end);
--- a/hotspot/src/share/tools/hsdis/hsdis.c Sat Dec 12 21:23:20 2015 +0300
+++ b/hotspot/src/share/tools/hsdis/hsdis.c Sun Dec 13 22:32:16 2015 -0500
@@ -461,7 +461,7 @@
#ifdef LIBARCH_sparcv9
res = "sparc:v9b";
#endif
-#ifdef LIBARCH_ppc64
+#if defined(LIBARCH_ppc64) || defined(LIBARCH_ppc64le)
res = "powerpc:common64";
#endif
#ifdef LIBARCH_aarch64
--- a/hotspot/src/share/vm/runtime/vm_version.cpp Sat Dec 12 21:23:20 2015 +0300
+++ b/hotspot/src/share/vm/runtime/vm_version.cpp Sun Dec 13 22:32:16 2015 -0500
@@ -170,14 +170,19 @@
#ifndef CPU
#ifdef ZERO
#define CPU ZERO_LIBARCH
+#elif defined(PPC64)
+#if defined(VM_LITTLE_ENDIAN)
+#define CPU "ppc64le"
+#else
+#define CPU "ppc64"
+#endif
#else
#define CPU IA32_ONLY("x86") \
IA64_ONLY("ia64") \
AMD64_ONLY("amd64") \
- PPC64_ONLY("ppc64") \
AARCH64_ONLY("aarch64") \
SPARC_ONLY("sparc")
-#endif // ZERO
+#endif //
#endif
const char *Abstract_VM_Version::vm_platform_string() {
--- a/hotspot/test/test_env.sh Sat Dec 12 21:23:20 2015 +0300
+++ b/hotspot/test/test_env.sh Sun Dec 13 22:32:16 2015 -0500
@@ -192,6 +192,11 @@
if [ $VM_BITS = "64" ]
then
VM_CPU="ppc64"
+ grep "ppc64le" vm_version.out > ${NULL}
+ if [ $? = 0 ]
+ then
+ VM_CPU="ppc64le"
+ fi
fi
fi
grep "ia64" vm_version.out > ${NULL}