Blame SOURCES/coreclr-libunwind-fno-common.patch

c5c2e3
From 29e17d8d2ccbca07c423e3089a6d5ae8a1c9cb6e Mon Sep 17 00:00:00 2001
c5c2e3
From: Yichao Yu <yyc1992@gmail.com>
c5c2e3
Date: Tue, 31 Mar 2020 00:43:32 -0400
c5c2e3
Subject: [PATCH] Fix compilation with -fno-common.
c5c2e3
c5c2e3
Making all other archs consistent with IA64 which should not have this problem.
c5c2e3
Also move the FIXME to the correct place.
c5c2e3
c5c2e3
Also add some minimum comments about this...
c5c2e3
---
c5c2e3
 src/aarch64/Ginit.c                        | 15 +++++++--------
c5c2e3
 src/arm/Ginit.c                            | 15 +++++++--------
c5c2e3
 src/coredump/_UPT_get_dyn_info_list_addr.c |  5 +++++
c5c2e3
 src/hppa/Ginit.c                           | 15 +++++++--------
c5c2e3
 src/ia64/Ginit.c                           |  1 +
c5c2e3
 src/mi/Gfind_dynamic_proc_info.c           |  1 +
c5c2e3
 src/mips/Ginit.c                           | 15 +++++++--------
c5c2e3
 src/ppc32/Ginit.c                          | 11 +++++++----
c5c2e3
 src/ppc64/Ginit.c                          | 11 +++++++----
c5c2e3
 src/ptrace/_UPT_get_dyn_info_list_addr.c   |  5 +++++
c5c2e3
 src/s390x/Ginit.c                          | 15 +++++++--------
c5c2e3
 src/sh/Ginit.c                             | 15 +++++++--------
c5c2e3
 src/tilegx/Ginit.c                         | 15 +++++++--------
c5c2e3
 src/x86/Ginit.c                            | 15 +++++++--------
c5c2e3
 src/x86_64/Ginit.c                         | 15 +++++++--------
c5c2e3
 15 files changed, 89 insertions(+), 80 deletions(-)
c5c2e3
c5c2e3
diff --git a/src/pal/src/libunwind/src/aarch64/Ginit.c b/src/pal/src/libunwind/src/aarch64/Ginit.c
c5c2e3
index dec235c82..35389762f 100644
c5c2e3
--- a/src/pal/src/libunwind/src/aarch64/Ginit.c
c5c2e3
+++ b/src/pal/src/libunwind/src/aarch64/Ginit.c
c5c2e3
@@ -61,13 +61,6 @@ tdep_uc_addr (unw_tdep_context_t *uc, int reg)
c5c2e3
 
c5c2e3
 # endif /* UNW_LOCAL_ONLY */
c5c2e3
 
c5c2e3
-HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
c5c2e3
-
c5c2e3
-/* XXX fix me: there is currently no way to locate the dyn-info list
c5c2e3
-       by a remote unwinder.  On ia64, this is done via a special
c5c2e3
-       unwind-table entry.  Perhaps something similar can be done with
c5c2e3
-       DWARF2 unwind info.  */
c5c2e3
-
c5c2e3
 static void
c5c2e3
 put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
c5c2e3
 {
c5c2e3
@@ -78,7 +71,13 @@ static int
c5c2e3
 get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
c5c2e3
                         void *arg)
c5c2e3
 {
c5c2e3
-  *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
c5c2e3
+#ifndef UNW_LOCAL_ONLY
c5c2e3
+# pragma weak _U_dyn_info_list_addr
c5c2e3
+  if (!_U_dyn_info_list_addr)
c5c2e3
+    return -UNW_ENOINFO;
c5c2e3
+#endif
c5c2e3
+  // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
c5c2e3
+  *dyn_info_list_addr = _U_dyn_info_list_addr ();
c5c2e3
   return 0;
c5c2e3
 }
c5c2e3
 
c5c2e3
diff --git a/src/pal/src/libunwind/src/arm/Ginit.c b/ssrc/pal/src/libunwind/src/arm/Ginit.c
c5c2e3
index 2720d063a..0bac0d72d 100644
c5c2e3
--- a/src/pal/src/libunwind/src/arm/Ginit.c
c5c2e3
+++ b/src/pal/src/libunwind/src/arm/Ginit.c
c5c2e3
@@ -57,18 +57,17 @@ tdep_uc_addr (unw_tdep_context_t *uc, int reg)
c5c2e3
 
c5c2e3
 # endif /* UNW_LOCAL_ONLY */
c5c2e3
 
c5c2e3
-HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
c5c2e3
-
c5c2e3
-/* XXX fix me: there is currently no way to locate the dyn-info list
c5c2e3
-       by a remote unwinder.  On ia64, this is done via a special
c5c2e3
-       unwind-table entry.  Perhaps something similar can be done with
c5c2e3
-       DWARF2 unwind info.  */
c5c2e3
-
c5c2e3
 static int
c5c2e3
 get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
c5c2e3
                         void *arg)
c5c2e3
 {
c5c2e3
-  *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
c5c2e3
+#ifndef UNW_LOCAL_ONLY
c5c2e3
+# pragma weak _U_dyn_info_list_addr
c5c2e3
+  if (!_U_dyn_info_list_addr)
c5c2e3
+    return -UNW_ENOINFO;
c5c2e3
+#endif
c5c2e3
+  // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
c5c2e3
+  *dyn_info_list_addr = _U_dyn_info_list_addr ();
c5c2e3
   return 0;
c5c2e3
 }
c5c2e3
 
c5c2e3
diff --git a/src/pal/src/libunwind/src/coredump/_UPT_get_dyn_info_list_addr.c b/src/pal/src/libunwind/src/coredump/_UPT_get_dyn_info_list_addr.c
c5c2e3
index 0d1190556..739ed0569 100644
c5c2e3
--- a/src/pal/src/libunwind/src/coredump/_UPT_get_dyn_info_list_addr.c
c5c2e3
+++ b/src/pal/src/libunwind/src/coredump/_UPT_get_dyn_info_list_addr.c
c5c2e3
@@ -74,6 +74,11 @@ get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg,
c5c2e3
 
c5c2e3
 #else
c5c2e3
 
c5c2e3
+/* XXX fix me: there is currently no way to locate the dyn-info list
c5c2e3
+       by a remote unwinder.  On ia64, this is done via a special
c5c2e3
+       unwind-table entry.  Perhaps something similar can be done with
c5c2e3
+       DWARF2 unwind info.  */
c5c2e3
+
c5c2e3
 static inline int
c5c2e3
 get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg,
c5c2e3
                int *countp)
c5c2e3
diff --git a/src/pal/src/libunwind/src/hppa/Ginit.c b/src/pal/src/libunwind/src/hppa/Ginit.c
c5c2e3
index 461e4b93d..265455a68 100644
c5c2e3
--- a/src/pal/src/libunwind/src/hppa/Ginit.c
c5c2e3
+++ b/src/pal/src/libunwind/src/hppa/Ginit.c
c5c2e3
@@ -64,13 +64,6 @@ _Uhppa_uc_addr (ucontext_t *uc, int reg)
c5c2e3
 
c5c2e3
 # endif /* UNW_LOCAL_ONLY */
c5c2e3
 
c5c2e3
-HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
c5c2e3
-
c5c2e3
-/* XXX fix me: there is currently no way to locate the dyn-info list
c5c2e3
-       by a remote unwinder.  On ia64, this is done via a special
c5c2e3
-       unwind-table entry.  Perhaps something similar can be done with
c5c2e3
-       DWARF2 unwind info.  */
c5c2e3
-
c5c2e3
 static void
c5c2e3
 put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
c5c2e3
 {
c5c2e3
@@ -81,7 +74,13 @@ static int
c5c2e3
 get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
c5c2e3
                         void *arg)
c5c2e3
 {
c5c2e3
-  *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
c5c2e3
+#ifndef UNW_LOCAL_ONLY
c5c2e3
+# pragma weak _U_dyn_info_list_addr
c5c2e3
+  if (!_U_dyn_info_list_addr)
c5c2e3
+    return -UNW_ENOINFO;
c5c2e3
+#endif
c5c2e3
+  // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
c5c2e3
+  *dyn_info_list_addr = _U_dyn_info_list_addr ();
c5c2e3
   return 0;
c5c2e3
 }
c5c2e3
 
c5c2e3
diff --git a/src/pal/src/libunwind/src/ia64/Ginit.c b/src/pal/src/libunwind/src/ia64/Ginit.c
c5c2e3
index b09a2ad57..8601bb3ca 100644
c5c2e3
--- a/src/pal/src/libunwind/src/ia64/Ginit.c
c5c2e3
+++ b/src/pal/src/libunwind/src/ia64/Ginit.c
c5c2e3
@@ -68,6 +68,7 @@ get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
c5c2e3
   if (!_U_dyn_info_list_addr)
c5c2e3
     return -UNW_ENOINFO;
c5c2e3
 #endif
c5c2e3
+  // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
c5c2e3
   *dyn_info_list_addr = _U_dyn_info_list_addr ();
c5c2e3
   return 0;
c5c2e3
 }
c5c2e3
diff --git a/src/pal/src/libunwind/src/mi/Gfind_dynamic_proc_info.c b/src/pal/src/libunwind/src/mi/Gfind_dynamic_proc_info.c
c5c2e3
index 98d350128..2e7c62e5e 100644
c5c2e3
--- a/src/pal/src/libunwind/src/mi/Gfind_dynamic_proc_info.c
c5c2e3
+++ b/src/pal/src/libunwind/src/mi/Gfind_dynamic_proc_info.c
c5c2e3
@@ -49,6 +49,7 @@ local_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
c5c2e3
     return -UNW_ENOINFO;
c5c2e3
 #endif
c5c2e3
 
c5c2e3
+  // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
c5c2e3
   list = (unw_dyn_info_list_t *) (uintptr_t) _U_dyn_info_list_addr ();
c5c2e3
   for (di = list->first; di; di = di->next)
c5c2e3
     if (ip >= di->start_ip && ip < di->end_ip)
c5c2e3
diff --git a/src/pal/src/libunwind/src/mips/Ginit.c b/src/pal/src/libunwind/src/mips/Ginit.c
c5c2e3
index 3df170c75..bf7a8f5a8 100644
c5c2e3
--- a/src/pal/src/libunwind/src/mips/Ginit.c
c5c2e3
+++ b/src/pal/src/libunwind/src/mips/Ginit.c
c5c2e3
@@ -69,13 +69,6 @@ tdep_uc_addr (ucontext_t *uc, int reg)
c5c2e3
 
c5c2e3
 # endif /* UNW_LOCAL_ONLY */
c5c2e3
 
c5c2e3
-HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
c5c2e3
-
c5c2e3
-/* XXX fix me: there is currently no way to locate the dyn-info list
c5c2e3
-       by a remote unwinder.  On ia64, this is done via a special
c5c2e3
-       unwind-table entry.  Perhaps something similar can be done with
c5c2e3
-       DWARF2 unwind info.  */
c5c2e3
-
c5c2e3
 static void
c5c2e3
 put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
c5c2e3
 {
c5c2e3
@@ -86,7 +79,13 @@ static int
c5c2e3
 get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
c5c2e3
                         void *arg)
c5c2e3
 {
c5c2e3
-  *dyn_info_list_addr = (unw_word_t) (intptr_t) &_U_dyn_info_list;
c5c2e3
+#ifndef UNW_LOCAL_ONLY
c5c2e3
+# pragma weak _U_dyn_info_list_addr
c5c2e3
+  if (!_U_dyn_info_list_addr)
c5c2e3
+    return -UNW_ENOINFO;
c5c2e3
+#endif
c5c2e3
+  // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
c5c2e3
+  *dyn_info_list_addr = _U_dyn_info_list_addr ();
c5c2e3
   return 0;
c5c2e3
 }
c5c2e3
 
c5c2e3
diff --git a/src/pal/src/libunwind/src/ppc32/Ginit.c b/src/pal/src/libunwind/src/ppc32/Ginit.c
c5c2e3
index ba302448a..7b4545580 100644
c5c2e3
--- a/src/pal/src/libunwind/src/ppc32/Ginit.c
c5c2e3
+++ b/src/pal/src/libunwind/src/ppc32/Ginit.c
c5c2e3
@@ -91,9 +91,6 @@ tdep_uc_addr (ucontext_t *uc, int reg)
c5c2e3
 
c5c2e3
 # endif /* UNW_LOCAL_ONLY */
c5c2e3
 
c5c2e3
-HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
c5c2e3
-
c5c2e3
-
c5c2e3
 static void
c5c2e3
 put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
c5c2e3
 {
c5c2e3
@@ -104,7 +101,13 @@ static int
c5c2e3
 get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
c5c2e3
                         void *arg)
c5c2e3
 {
c5c2e3
-  *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
c5c2e3
+#ifndef UNW_LOCAL_ONLY
c5c2e3
+# pragma weak _U_dyn_info_list_addr
c5c2e3
+  if (!_U_dyn_info_list_addr)
c5c2e3
+    return -UNW_ENOINFO;
c5c2e3
+#endif
c5c2e3
+  // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
c5c2e3
+  *dyn_info_list_addr = _U_dyn_info_list_addr ();
c5c2e3
   return 0;
c5c2e3
 }
c5c2e3
 
c5c2e3
diff --git a/src/pal/src/libunwind/src/ppc64/Ginit.c b/src/pal/src/libunwind/src/ppc64/Ginit.c
c5c2e3
index 4c88cd6e7..7bfb395a7 100644
c5c2e3
--- a/src/pal/src/libunwind/src/ppc64/Ginit.c
c5c2e3
+++ b/src/pal/src/libunwind/src/ppc64/Ginit.c
c5c2e3
@@ -95,9 +95,6 @@ tdep_uc_addr (ucontext_t *uc, int reg)
c5c2e3
 
c5c2e3
 # endif /* UNW_LOCAL_ONLY */
c5c2e3
 
c5c2e3
-HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
c5c2e3
-
c5c2e3
-
c5c2e3
 static void
c5c2e3
 put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
c5c2e3
 {
c5c2e3
@@ -108,7 +105,13 @@ static int
c5c2e3
 get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
c5c2e3
                         void *arg)
c5c2e3
 {
c5c2e3
-  *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
c5c2e3
+#ifndef UNW_LOCAL_ONLY
c5c2e3
+# pragma weak _U_dyn_info_list_addr
c5c2e3
+  if (!_U_dyn_info_list_addr)
c5c2e3
+    return -UNW_ENOINFO;
c5c2e3
+#endif
c5c2e3
+  // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
c5c2e3
+  *dyn_info_list_addr = _U_dyn_info_list_addr ();
c5c2e3
   return 0;
c5c2e3
 }
c5c2e3
 
c5c2e3
diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_get_dyn_info_list_addr.c b/src/pal/src/libunwind/src/ptrace/_UPT_get_dyn_info_list_addr.c
c5c2e3
index cc5ed0441..16671d453 100644
c5c2e3
--- a/src/pal/src/libunwind/src/ptrace/_UPT_get_dyn_info_list_addr.c
c5c2e3
+++ b/src/pal/src/libunwind/src/ptrace/_UPT_get_dyn_info_list_addr.c
c5c2e3
@@ -71,6 +71,11 @@ get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg,
c5c2e3
 
c5c2e3
 #else
c5c2e3
 
c5c2e3
+/* XXX fix me: there is currently no way to locate the dyn-info list
c5c2e3
+       by a remote unwinder.  On ia64, this is done via a special
c5c2e3
+       unwind-table entry.  Perhaps something similar can be done with
c5c2e3
+       DWARF2 unwind info.  */
c5c2e3
+
c5c2e3
 static inline int
c5c2e3
 get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg,
c5c2e3
                int *countp)
c5c2e3
diff --git a/src/pal/src/libunwind/src/sh/Ginit.c b/src/pal/src/libunwind/src/sh/Ginit.c
c5c2e3
index 52988a721..9fe96d2bd 100644
c5c2e3
--- a/src/pal/src/libunwind/src/sh/Ginit.c
c5c2e3
+++ b/src/pal/src/libunwind/src/sh/Ginit.c
c5c2e3
@@ -58,13 +58,6 @@ tdep_uc_addr (ucontext_t *uc, int reg)
c5c2e3
 
c5c2e3
 # endif /* UNW_LOCAL_ONLY */
c5c2e3
 
c5c2e3
-HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
c5c2e3
-
c5c2e3
-/* XXX fix me: there is currently no way to locate the dyn-info list
c5c2e3
-       by a remote unwinder.  On ia64, this is done via a special
c5c2e3
-       unwind-table entry.  Perhaps something similar can be done with
c5c2e3
-       DWARF2 unwind info.  */
c5c2e3
-
c5c2e3
 static void
c5c2e3
 put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
c5c2e3
 {
c5c2e3
@@ -75,7 +68,13 @@ static int
c5c2e3
 get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
c5c2e3
                         void *arg)
c5c2e3
 {
c5c2e3
-  *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
c5c2e3
+#ifndef UNW_LOCAL_ONLY
c5c2e3
+# pragma weak _U_dyn_info_list_addr
c5c2e3
+  if (!_U_dyn_info_list_addr)
c5c2e3
+    return -UNW_ENOINFO;
c5c2e3
+#endif
c5c2e3
+  // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
c5c2e3
+  *dyn_info_list_addr = _U_dyn_info_list_addr ();
c5c2e3
   return 0;
c5c2e3
 }
c5c2e3
 
c5c2e3
diff --git a/src/pal/src/libunwind/src/tilegx/Ginit.c b/src/pal/src/libunwind/src/tilegx/Ginit.c
c5c2e3
index 7564a558b..925e64132 100644
c5c2e3
--- a/src/pal/src/libunwind/src/tilegx/Ginit.c
c5c2e3
+++ b/src/pal/src/libunwind/src/tilegx/Ginit.c
c5c2e3
@@ -64,13 +64,6 @@ tdep_uc_addr (ucontext_t *uc, int reg)
c5c2e3
 
c5c2e3
 # endif /* UNW_LOCAL_ONLY */
c5c2e3
 
c5c2e3
-HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
c5c2e3
-
c5c2e3
-/* XXX fix me: there is currently no way to locate the dyn-info list
c5c2e3
-       by a remote unwinder.  On ia64, this is done via a special
c5c2e3
-       unwind-table entry.  Perhaps something similar can be done with
c5c2e3
-       DWARF2 unwind info.  */
c5c2e3
-
c5c2e3
 static void
c5c2e3
 put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
c5c2e3
 {
c5c2e3
@@ -81,7 +74,13 @@ static int
c5c2e3
 get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
c5c2e3
                         void *arg)
c5c2e3
 {
c5c2e3
-  *dyn_info_list_addr = (unw_word_t) (intptr_t) &_U_dyn_info_list;
c5c2e3
+#ifndef UNW_LOCAL_ONLY
c5c2e3
+# pragma weak _U_dyn_info_list_addr
c5c2e3
+  if (!_U_dyn_info_list_addr)
c5c2e3
+    return -UNW_ENOINFO;
c5c2e3
+#endif
c5c2e3
+  // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
c5c2e3
+  *dyn_info_list_addr = _U_dyn_info_list_addr ();
c5c2e3
   return 0;
c5c2e3
 }
c5c2e3
 
c5c2e3
diff --git a/src/pal/src/libunwind/src/x86/Ginit.c b/src/pal/src/libunwind/src/x86/Ginit.c
c5c2e3
index f6b8dc27d..3cec74a21 100644
c5c2e3
--- a/src/pal/src/libunwind/src/x86/Ginit.c
c5c2e3
+++ b/src/pal/src/libunwind/src/x86/Ginit.c
c5c2e3
@@ -54,13 +54,6 @@ tdep_uc_addr (ucontext_t *uc, int reg)
c5c2e3
 
c5c2e3
 # endif /* UNW_LOCAL_ONLY */
c5c2e3
 
c5c2e3
-HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
c5c2e3
-
c5c2e3
-/* XXX fix me: there is currently no way to locate the dyn-info list
c5c2e3
-       by a remote unwinder.  On ia64, this is done via a special
c5c2e3
-       unwind-table entry.  Perhaps something similar can be done with
c5c2e3
-       DWARF2 unwind info.  */
c5c2e3
-
c5c2e3
 static void
c5c2e3
 put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
c5c2e3
 {
c5c2e3
@@ -71,7 +64,13 @@ static int
c5c2e3
 get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
c5c2e3
                         void *arg)
c5c2e3
 {
c5c2e3
-  *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
c5c2e3
+#ifndef UNW_LOCAL_ONLY
c5c2e3
+# pragma weak _U_dyn_info_list_addr
c5c2e3
+  if (!_U_dyn_info_list_addr)
c5c2e3
+    return -UNW_ENOINFO;
c5c2e3
+#endif
c5c2e3
+  // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
c5c2e3
+  *dyn_info_list_addr = _U_dyn_info_list_addr ();
c5c2e3
   return 0;
c5c2e3
 }
c5c2e3
 
c5c2e3
diff --git a/src/pal/src/libunwind/src/x86_64/Ginit.c b/src/pal/src/libunwind/src/x86_64/Ginit.c
c5c2e3
index a865d3385..fd8d418b1 100644
c5c2e3
--- a/src/pal/src/libunwind/src/x86_64/Ginit.c
c5c2e3
+++ b/src/pal/src/libunwind/src/x86_64/Ginit.c
c5c2e3
@@ -49,13 +49,6 @@ static struct unw_addr_space local_addr_space;
c5c2e3
 
c5c2e3
 unw_addr_space_t unw_local_addr_space = &local_addr_space;
c5c2e3
 
c5c2e3
-HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
c5c2e3
-
c5c2e3
-/* XXX fix me: there is currently no way to locate the dyn-info list
c5c2e3
-       by a remote unwinder.  On ia64, this is done via a special
c5c2e3
-       unwind-table entry.  Perhaps something similar can be done with
c5c2e3
-       DWARF2 unwind info.  */
c5c2e3
-
c5c2e3
 static void
c5c2e3
 put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
c5c2e3
 {
c5c2e3
@@ -66,7 +59,13 @@ static int
c5c2e3
 get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
c5c2e3
                         void *arg)
c5c2e3
 {
c5c2e3
-  *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
c5c2e3
+#ifndef UNW_LOCAL_ONLY
c5c2e3
+# pragma weak _U_dyn_info_list_addr
c5c2e3
+  if (!_U_dyn_info_list_addr)
c5c2e3
+    return -UNW_ENOINFO;
c5c2e3
+#endif
c5c2e3
+  // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
c5c2e3
+  *dyn_info_list_addr = _U_dyn_info_list_addr ();
c5c2e3
   return 0;
c5c2e3
 }
c5c2e3