gc/0001-Do-not-probe-to-find-main-data-root-start-if-dl_iter.patch

45 lines
1.6 KiB
Diff
Raw Normal View History

From b2875e6e5262785056d49ad2f94bfed295977b2d Mon Sep 17 00:00:00 2001
From: Ivan Maidanski <ivmai@mail.ru>
Date: Mon, 13 Jun 2022 12:28:56 -0400
Subject: [PATCH] Do not probe to find main data root start if dl_iterate_phdr
exists
Issue #432 (bdwgc).
This avoids invocation of GC_find_limit to get GC_data_start value in
case of GC_register_data_segments is not called.
* misc.c [SEARCH_FOR_DATA_START] (GC_init): Call
GC_init_linux_data_start() only if GC_REGISTER_MAIN_STATIC_DATA();
move GC_init_linux_data_start() call down (to be close but precede
GC_dirty_init call); add comment.
---
misc.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/misc.c b/misc.c
index 0869e01..02dc430 100644
--- a/misc.c
+++ b/misc.c
@@ -1186,11 +1186,12 @@ GC_API void GC_CALL GC_init(void)
/* entirety as part of the root set. This will grow them to */
/* maximum size, and is generally not desirable. */
# endif
-# if defined(SEARCH_FOR_DATA_START)
- GC_init_linux_data_start();
-# endif
-# if defined(NETBSD) && defined(__ELF__)
- GC_init_netbsd_elf();
+# ifdef SEARCH_FOR_DATA_START
+ /* For MPROTECT_VDB, the temporary fault handler should be */
+ /* installed first, before the write fault one in GC_dirty_init. */
+ if (GC_REGISTER_MAIN_STATIC_DATA()) GC_init_linux_data_start();
+# elif defined(NETBSD) && defined(__ELF__)
+ if (GC_REGISTER_MAIN_STATIC_DATA()) GC_init_netbsd_elf();
# endif
# if !defined(THREADS) || defined(GC_PTHREADS) \
|| defined(NN_PLATFORM_CTR) || defined(NINTENDO_SWITCH) \
--
2.36.0