1 Star 0 Fork 12

zhaosai/openjdk-21

forked from src-openEuler/openjdk-21 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
add-downgrade-the-glibc-symver-of-memcpy.patch 3.35 KB
一键复制 编辑 原始数据 按行查看 历史
kuen 提交于 2024-01-05 15:51 . I8TWUM: downgrade log2f and memcpy symbols
From f277a3770d7f0785365bb6ab1c592e46c5100732 Mon Sep 17 00:00:00 2001
Subject: add downgrade-the-glibc-symver-of-memcpy
---
make/common/NativeCompilation.gmk | 9 +++++++++
make/hotspot/lib/CompileJvm.gmk | 8 ++++++++
src/hotspot/share/runtime/memcpy.cpp | 20 +++++++++++++++++++
.../linux/native/applauncher/LinuxPackage.c | 3 +++
4 files changed, 40 insertions(+)
create mode 100644 src/hotspot/share/runtime/memcpy.cpp
diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk
index 0d7ab6a7e..6a8ec3f0b 100644
--- a/make/common/NativeCompilation.gmk
+++ b/make/common/NativeCompilation.gmk
@@ -1194,6 +1194,15 @@ define SetupNativeCompilationBody
endif
endif
+ # if ldflags contain --wrap=memcpy, add memcpy.o to OBJS
+ ifneq ($$(findstring wrap=memcpy, $$($1_LDFLAGS)$$($1_EXTRA_LDFLAGS)),)
+ ifeq ($$(findstring memcpy$(OBJ_SUFFIX), $$($1_ALL_OBJS)),)
+ $$($1_BUILD_INFO):
+ $(ECHO) 'Adding $(SUPPORT_OUTPUTDIR)/memcpy/memcpy$(OBJ_SUFFIX) to $1_ALL_OBJS'
+ $1_ALL_OBJS += $(SUPPORT_OUTPUTDIR)/memcpy/memcpy$(OBJ_SUFFIX)
+ endif
+ endif
+
$1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
$$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \
$$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION) \
diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
index adb964d05..3736ea201 100644
--- a/make/hotspot/lib/CompileJvm.gmk
+++ b/make/hotspot/lib/CompileJvm.gmk
@@ -192,6 +192,14 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJVM, \
PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \
))
+MEMCPY_OBJECT_FILE := $(JVM_OUTPUTDIR)/objs/memcpy$(OBJ_SUFFIX)
+
+$(eval $(call SetupCopyFiles, COPY_MEMCPY_OBJECT_FILE, \
+ DEST := $(SUPPORT_OUTPUTDIR)/memcpy, \
+ FILES :=$(MEMCPY_OBJECT_FILE), \
+))
+TARGETS += $(COPY_MEMCPY_OBJECT_FILE)
+
# Always recompile abstract_vm_version.cpp if libjvm needs to be relinked. This ensures
# that the internal vm version is updated as it relies on __DATE__ and __TIME__
# macros.
diff --git a/src/hotspot/share/runtime/memcpy.cpp b/src/hotspot/share/runtime/memcpy.cpp
new file mode 100644
index 000000000..6ab4ddb64
--- /dev/null
+++ b/src/hotspot/share/runtime/memcpy.cpp
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2018-2024. All rights reserved.
+ */
+
+#if defined( __GNUC__ ) && \
+(__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
+#include <string.h>
+
+#if (defined AMD64) || (defined amd64)
+/* some systems do not have newest memcpy@@GLIBC_2.14 - stay with old good one */
+asm (".symver memcpy, memcpy@GLIBC_2.2.5");
+
+extern "C"{
+ void *__wrap_memcpy(void *dest, const void *src, size_t n)
+ {
+ return memcpy(dest, src, n);
+ }
+}
+#endif
+#endif
diff --git a/src/jdk.jpackage/linux/native/applauncher/LinuxPackage.c b/src/jdk.jpackage/linux/native/applauncher/LinuxPackage.c
index 26d65f806..b7b114ac3 100644
--- a/src/jdk.jpackage/linux/native/applauncher/LinuxPackage.c
+++ b/src/jdk.jpackage/linux/native/applauncher/LinuxPackage.c
@@ -34,6 +34,9 @@
#include "JvmLauncher.h"
#include "LinuxPackage.h"
+#if (defined AMD64) || (defined amd64)
+__asm__(".symver memcpy, memcpy@GLIBC_2.2.5");
+#endif
static char* getModulePath(void) {
char modulePath[PATH_MAX] = { 0 };
--
2.19.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhaosai-Simon/openjdk-21.git
git@gitee.com:zhaosai-Simon/openjdk-21.git
zhaosai-Simon
openjdk-21
openjdk-21
master

搜索帮助