From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
Date: Mon, 27 Mar 2023 20:07:46 +1100
Subject: [PATCH] Teach dyn_load.c about minerva
---
dyn_load.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/dyn_load.c b/dyn_load.c
index c73897e6ba0e7f70443940790d558b91f9bb75c9..bd3192ad75d68e5daa8ff4c0a989c521d3b0426d 100644
--- a/dyn_load.c
+++ b/dyn_load.c
@@ -63,7 +63,7 @@ STATIC GC_has_static_roots_func GC_has_static_roots = 0;
&& !(defined(NETBSD) && defined(__ELF__)) \
&& !(defined(OPENBSD) && (defined(__ELF__) || defined(M68K))) \
&& !defined(HAIKU) && !defined(HURD) && !defined(NACL) \
- && !defined(CPPCHECK)
+ && !defined(CPPCHECK) && !defined(MINERVA)
# error We only know how to find data segments of dynamic libraries for above.
# error Additional SVR4 variants might not be too hard to add.
#endif
@@ -89,7 +89,7 @@ STATIC GC_has_static_roots_func GC_has_static_roots = 0;
# endif
#endif /* OPENBSD */
-#if defined(SCO_ELF) || defined(DGUX) || defined(HURD) || defined(NACL) \
+#if defined(SCO_ELF) || defined(DGUX) || defined(HURD) || defined(NACL) || defined(MINERVA) \
|| (defined(__ELF__) && (defined(LINUX) || defined(FREEBSD) \
|| defined(NETBSD) || defined(OPENBSD)))
# include <stddef.h>
@@ -98,6 +98,23 @@ STATIC GC_has_static_roots_func GC_has_static_roots = 0;
/* Exclude Android because linker.h below includes its own version. */
# include <elf.h>
# endif
+# ifdef MINERVA
+# include <link.h>
+ struct link_map {
+ uintptr_t l_addr;
+ char* l_name;
+ uintptr_t l_ld;
+ struct link_map* l_next;
+ struct link_map* l_prev;
+ };
+ struct r_debug {
+ int32_t r_version;
+ struct link_map* r_map;
+ void (*r_brk)(void);
+ int32_t r_state;
+ uintptr_t r_ldbase;
+ };
+# endif
# ifdef HOST_ANDROID
/* If you don't need the "dynamic loading" feature, you may build */
/* the collector with -D IGNORE_DYNAMIC_LOADING. */
@@ -261,7 +278,7 @@ GC_INNER void GC_register_dynamic_libraries(void)
# endif /* !USE_PROC_FOR_LIBRARIES */
# endif /* SOLARISDL */
-#if defined(SCO_ELF) || defined(DGUX) || defined(HURD) || defined(NACL) \
+#if defined(SCO_ELF) || defined(DGUX) || defined(HURD) || defined(NACL) || defined(MINERVA) \
|| (defined(__ELF__) && (defined(LINUX) || defined(FREEBSD) \
|| defined(NETBSD) || defined(OPENBSD)))