# HG changeset patch # User coleenp # Date 1296577399 18000 # Node ID 19106a0203fb6cdb12afcc8233a849d540d09436 # Parent 96d498ec7ae11d97ce08e34333f6a7ca553b0876 6588413: Use -fvisibility=hidden for gcc compiles Summary: Add option for gcc 4 and above, define JNIEXPORT and JNIIMPORT to visibility=default, add for jio_snprintf and others since -fvisibility=hidden overrides --version-script definitions. Reviewed-by: kamg, never diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/make/linux/makefiles/gcc.make --- a/hotspot/make/linux/makefiles/gcc.make Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/make/linux/makefiles/gcc.make Tue Feb 01 11:23:19 2011 -0500 @@ -75,6 +75,11 @@ CFLAGS += -fno-exceptions CFLAGS += -D_REENTRANT CFLAGS += -fcheck-new +# version 4 and above support fvisibility=hidden (matches jni_x86.h file) +# except 4.1.2 gives pointless warnings that can't be disabled (afaik) +ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" +CFLAGS += -fvisibility=hidden +endif ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) ARCHFLAG/i486 = -m32 -march=i586 diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/make/linux/makefiles/mapfile-vers-debug --- a/hotspot/make/linux/makefiles/mapfile-vers-debug Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/make/linux/makefiles/mapfile-vers-debug Tue Feb 01 11:23:19 2011 -0500 @@ -262,14 +262,6 @@ JVM_SetField; JVM_SetPrimitiveField; - # Needed for dropping VM into JDK 1.3.x, 1.4 - _JVM_native_threads; - jdk_sem_init; - jdk_sem_post; - jdk_sem_wait; - jdk_pthread_sigmask; - jdk_waitpid; - # debug JVM JVM_AccessVMBooleanFlag; JVM_AccessVMIntFlag; diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/make/linux/makefiles/mapfile-vers-product --- a/hotspot/make/linux/makefiles/mapfile-vers-product Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/make/linux/makefiles/mapfile-vers-product Tue Feb 01 11:23:19 2011 -0500 @@ -262,14 +262,6 @@ JVM_SetField; JVM_SetPrimitiveField; - # Needed for dropping VM into JDK 1.3.x, 1.4 - _JVM_native_threads; - jdk_sem_init; - jdk_sem_post; - jdk_sem_wait; - jdk_pthread_sigmask; - jdk_waitpid; - # miscellaneous functions jio_fprintf; jio_printf; diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/cpu/sparc/vm/jni_sparc.h --- a/hotspot/src/cpu/sparc/vm/jni_sparc.h Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/cpu/sparc/vm/jni_sparc.h Tue Feb 01 11:23:19 2011 -0500 @@ -23,8 +23,13 @@ * questions. */ -#define JNIEXPORT -#define JNIIMPORT +#if defined(__GNUC__) && (__GNUC__ >= 4) + #define JNIEXPORT __attribute__((visibility("default"))) + #define JNIIMPORT __attribute__((visibility("default"))) +#else + #define JNIEXPORT + #define JNIIMPORT +#endif #define JNICALL typedef int jint; diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/cpu/x86/vm/jni_x86.h --- a/hotspot/src/cpu/x86/vm/jni_x86.h Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/cpu/x86/vm/jni_x86.h Tue Feb 01 11:23:19 2011 -0500 @@ -27,10 +27,16 @@ #define _JAVASOFT_JNI_MD_H_ #if defined(SOLARIS) || defined(LINUX) + +#if defined(__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2) + #define JNIEXPORT __attribute__((visibility("default"))) + #define JNIIMPORT __attribute__((visibility("default"))) +#else #define JNIEXPORT #define JNIIMPORT +#endif + #define JNICALL - typedef int jint; #ifdef _LP64 diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/cpu/zero/vm/jni_zero.h --- a/hotspot/src/cpu/zero/vm/jni_zero.h Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/cpu/zero/vm/jni_zero.h Tue Feb 01 11:23:19 2011 -0500 @@ -24,8 +24,14 @@ * questions. */ -#define JNIEXPORT -#define JNIIMPORT + +#if defined(__GNUC__) && (__GNUC__ >= 4) + #define JNIEXPORT __attribute__((visibility("default"))) + #define JNIIMPORT __attribute__((visibility("default"))) +#else + #define JNIEXPORT + #define JNIIMPORT +#endif #define JNICALL typedef int jint; diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/os/linux/vm/jvm_linux.cpp --- a/hotspot/src/os/linux/vm/jvm_linux.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/os/linux/vm/jvm_linux.cpp Tue Feb 01 11:23:19 2011 -0500 @@ -29,11 +29,6 @@ #include -/* - * FIXME: This is temporary hack to keep Linux Runtime.exec() - * code happy. See $JDK/src/linux/native/java/lang/UnixProcess_md.c - */ -int _JVM_native_threads = 1; // sun.misc.Signal /////////////////////////////////////////////////////////// // Signal code is mostly copied from classic vm, signals_md.c 1.4 98/08/23 diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/os/linux/vm/os_linux.cpp --- a/hotspot/src/os/linux/vm/os_linux.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/os/linux/vm/os_linux.cpp Tue Feb 01 11:23:19 2011 -0500 @@ -2509,8 +2509,10 @@ return end; } -extern "C" void numa_warn(int number, char *where, ...) { } -extern "C" void numa_error(char *where) { } +// Something to do with the numa-aware allocator needs these symbols +extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { } +extern "C" JNIEXPORT void numa_error(char *where) { } +extern "C" JNIEXPORT int fork1() { return fork(); } // If we are running with libnuma version > 2, then we should @@ -3483,7 +3485,7 @@ // Note that the VM will print warnings if it detects conflicting signal // handlers, unless invoked with the option "-XX:+AllowUserSignalHandlers". // -extern "C" int +extern "C" JNIEXPORT int JVM_handle_linux_signal(int signo, siginfo_t* siginfo, void* ucontext, int abort_if_unrecognized); @@ -4678,44 +4680,6 @@ } } -extern "C" { - -/** - * NOTE: the following code is to keep the green threads code - * in the libjava.so happy. Once the green threads is removed, - * these code will no longer be needed. - */ -int -jdk_waitpid(pid_t pid, int* status, int options) { - return waitpid(pid, status, options); -} - -int -fork1() { - return fork(); -} - -int -jdk_sem_init(sem_t *sem, int pshared, unsigned int value) { - return sem_init(sem, pshared, value); -} - -int -jdk_sem_post(sem_t *sem) { - return sem_post(sem); -} - -int -jdk_sem_wait(sem_t *sem) { - return sem_wait(sem); -} - -int -jdk_pthread_sigmask(int how , const sigset_t* newmask, sigset_t* oldmask) { - return pthread_sigmask(how , newmask, oldmask); -} - -} // Refer to the comments in os_solaris.cpp park-unpark. // diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/os/solaris/vm/os_solaris.cpp --- a/hotspot/src/os/solaris/vm/os_solaris.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp Tue Feb 01 11:23:19 2011 -0500 @@ -4221,7 +4221,9 @@ // Note that the VM will print warnings if it detects conflicting signal // handlers, unless invoked with the option "-XX:+AllowUserSignalHandlers". // -extern "C" int JVM_handle_solaris_signal(int signo, siginfo_t* siginfo, void* ucontext, int abort_if_unrecognized); +extern "C" JNIEXPORT int +JVM_handle_solaris_signal(int signo, siginfo_t* siginfo, void* ucontext, + int abort_if_unrecognized); void signalHandler(int sig, siginfo_t* info, void* ucVoid) { diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp --- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp Tue Feb 01 11:23:19 2011 -0500 @@ -542,7 +542,7 @@ return false; } -extern "C" int +extern "C" JNIEXPORT int JVM_handle_linux_signal(int sig, siginfo_t* info, void* ucVoid, diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp --- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp Tue Feb 01 11:23:19 2011 -0500 @@ -216,7 +216,7 @@ extern "C" void FetchNResume () ; #endif // AMD64 -extern "C" int +extern "C" JNIEXPORT int JVM_handle_linux_signal(int sig, siginfo_t* info, void* ucVoid, diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp --- a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp Tue Feb 01 11:23:19 2011 -0500 @@ -116,7 +116,7 @@ ShouldNotCallThis(); } -extern "C" int +extern "C" JNIEXPORT int JVM_handle_linux_signal(int sig, siginfo_t* info, void* ucVoid, diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp --- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Tue Feb 01 11:23:19 2011 -0500 @@ -317,9 +317,9 @@ extern "C" void FetchNPFI () ; extern "C" void FetchNResume () ; -extern "C" int JVM_handle_solaris_signal(int signo, siginfo_t* siginfo, void* ucontext, int abort_if_unrecognized); - -int JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, int abort_if_unrecognized) { +extern "C" JNIEXPORT int +JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, + int abort_if_unrecognized) { ucontext_t* uc = (ucontext_t*) ucVoid; Thread* t = ThreadLocalStorage::get_thread_slow(); diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp --- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Tue Feb 01 11:23:19 2011 -0500 @@ -365,8 +365,6 @@ } -extern "C" int JVM_handle_solaris_signal(int signo, siginfo_t* siginfo, void* ucontext, int abort_if_unrecognized); - extern "C" void Fetch32PFI () ; extern "C" void Fetch32Resume () ; #ifdef AMD64 @@ -374,7 +372,9 @@ extern "C" void FetchNResume () ; #endif // AMD64 -int JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, int abort_if_unrecognized) { +extern "C" JNIEXPORT int +JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, + int abort_if_unrecognized) { ucontext_t* uc = (ucontext_t*) ucVoid; #ifndef AMD64 diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/share/vm/prims/forte.cpp --- a/hotspot/src/share/vm/prims/forte.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/share/vm/prims/forte.cpp Tue Feb 01 11:23:19 2011 -0500 @@ -520,6 +520,7 @@ // method_id - jmethodID of the method being executed extern "C" { +JNIEXPORT void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) { // This is if'd out because we no longer use thread suspension. diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/share/vm/prims/jvm.cpp --- a/hotspot/src/share/vm/prims/jvm.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/share/vm/prims/jvm.cpp Tue Feb 01 11:23:19 2011 -0500 @@ -2585,7 +2585,7 @@ } -int jio_printf(const char *fmt, ...) { +JNIEXPORT int jio_printf(const char *fmt, ...) { int len; va_list args; va_start(args, fmt); diff -r 96d498ec7ae1 -r 19106a0203fb hotspot/src/share/vm/prims/jvm.h --- a/hotspot/src/share/vm/prims/jvm.h Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/share/vm/prims/jvm.h Tue Feb 01 11:23:19 2011 -0500 @@ -1417,16 +1417,16 @@ * BE CAREFUL! The following functions do not implement the * full feature set of standard C printf formats. */ -int +JNIEXPORT int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args); -int +JNIEXPORT int jio_snprintf(char *str, size_t count, const char *fmt, ...); -int +JNIEXPORT int jio_fprintf(FILE *, const char *fmt, ...); -int +JNIEXPORT int jio_vfprintf(FILE *, const char *fmt, va_list args);