[PATCH v4 3/6] Initialize l_mach field from rtld link_map

Jovan Dmitrovic jovan.dmitrovic@htecgroup.com
Wed Nov 26 13:54:12 GMT 2025


From: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>

Based on patch submitted by Sandra Loosemore:
https://sourceware.org/ml/libc-alpha/2015-03/msg00704.html

For MIPS builds, l_mach field contains fpabi value.
If l_mach isn't zero-initialized, we may get dynamic linking
failures due to incompatible FP ABIs. Similar issue may arise
or is already present on other platforms.

Reported-by: Sandra Loosemore <sandra@codesourcery.com>
---
 elf/rtld.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/elf/rtld.c b/elf/rtld.c
index 753ce6690b..bc878b49cb 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -534,11 +534,17 @@ _dl_start (void *arg)
 #ifndef DONT_USE_BOOTSTRAP_MAP
 # ifdef HAVE_BUILTIN_MEMSET
   __builtin_memset (bootstrap_map.l_info, '\0', sizeof (bootstrap_map.l_info));
+  __builtin_memset (bootstrap_map.l_mach, '\0', sizeof (bootstrap_map.l_mach));
 # else
   for (size_t cnt = 0;
        cnt < sizeof (bootstrap_map.l_info) / sizeof (bootstrap_map.l_info[0]);
        ++cnt)
     bootstrap_map.l_info[cnt] = 0;
+
+  char *p = (char*) &bootstrap_map.l_mach;
+  char *pend = p + sizeof (bootstrap_map.l_mach);
+  while (p < pend)
+    *(p++) = '\0';
 # endif
 #endif
 
-- 
2.34.1


More information about the Libc-alpha mailing list