From 4934a47067bbc74b725ce88c8f21f3949cf84418 Mon Sep 17 00:00:00 2001 From: Jiangli Zhou Date: Mon, 15 Jan 2024 20:33:56 -0800 Subject: [PATCH] 8311846: Resolve duplicate 'Thread' related symbols with JDK static linking --- src/hotspot/os_cpu/linux_aarch64/threadLS_linux_aarch64.S | 8 ++++---- src/hotspot/share/runtime/threadLocalStorage.hpp | 1 + src/hotspot/share/utilities/globalDefinitions.hpp | 4 ++++ .../share/classes/sun/jvm/hotspot/runtime/Thread.java | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/hotspot/os_cpu/linux_aarch64/threadLS_linux_aarch64.S b/src/hotspot/os_cpu/linux_aarch64/threadLS_linux_aarch64.S index ac60d6aa94168..ddc2447325801 100644 --- a/src/hotspot/os_cpu/linux_aarch64/threadLS_linux_aarch64.S +++ b/src/hotspot/os_cpu/linux_aarch64/threadLS_linux_aarch64.S @@ -31,10 +31,10 @@ _ZN10JavaThread25aarch64_get_thread_helperEv: hint #0x19 // paciasp stp x29, x30, [sp, -16]! - adrp x0, :tlsdesc:_ZN6Thread12_thr_currentE - ldr x1, [x0, #:tlsdesc_lo12:_ZN6Thread12_thr_currentE] - add x0, x0, :tlsdesc_lo12:_ZN6Thread12_thr_currentE - .tlsdesccall _ZN6Thread12_thr_currentE + adrp x0, :tlsdesc:_ZN17HotspotBaseThread12_thr_currentE + ldr x1, [x0, #:tlsdesc_lo12:_ZN17HotspotBaseThread12_thr_currentE] + add x0, x0, :tlsdesc_lo12:_ZN17HotspotBaseThread12_thr_currentE + .tlsdesccall _ZN17HotspotBaseThread12_thr_currentE blr x1 mrs x1, tpidr_el0 add x0, x1, x0 diff --git a/src/hotspot/share/runtime/threadLocalStorage.hpp b/src/hotspot/share/runtime/threadLocalStorage.hpp index 604b624757e6f..d7c4a68929396 100644 --- a/src/hotspot/share/runtime/threadLocalStorage.hpp +++ b/src/hotspot/share/runtime/threadLocalStorage.hpp @@ -26,6 +26,7 @@ #define SHARE_RUNTIME_THREADLOCALSTORAGE_HPP #include "memory/allStatic.hpp" +#include "utilities/globalDefinitions.hpp" // forward-decl as we can't have an include cycle class Thread; diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index 08eb25828703f..4a563f38704b2 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -1022,6 +1022,10 @@ enum LockingMode { LM_LIGHTWEIGHT = 2 }; +// Redefine Thread as BaseThread to avoid duplicate symbol issues for +// JDK static builds. See runtime/thread.hpp for Thread class. +#define Thread HotspotBaseThread + //---------------------------------------------------------------------------------------------------- // Special constants for debugging diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java index 8267f12a9e9ac..7e767d184e953 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java @@ -49,7 +49,7 @@ public void update(Observable o, Object data) { } private static synchronized void initialize(TypeDataBase db) { - Type typeThread = db.lookupType("Thread"); + Type typeThread = db.lookupType("HotspotBaseThread"); Type typeJavaThread = db.lookupType("JavaThread"); suspendFlagsField = typeJavaThread.getCIntegerField("_suspend_flags");