[PATCH v3 3/6] Initialize l_mach field from rtld link_map
Jovan Dmitrovic
jovan.dmitrovic@htecgroup.com
Fri Oct 31 14:02:27 GMT 2025
Hello everyone,
sorry for the long delay.
> That's what my original version of the patch did.... 🙂
Almost the same, I only changed it to zero out only the l_mach field. Of
course, the l_info
zeroing remained. AFAIK, only the l_mach and l_info fields are
problematic, and there is no need
to zero out bootstrap_map in its entirety.
> Even if compiler inlines the zero clearing, I think it would be better to
> follow the same strategy done for l_info and either user __builtin_memset
> or a open-coded memset.
You would be correct, this part is not portable. What we can do is what
Sandra did, but only on the l_mach field. Something like this:
--- 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
Regards,
Jovan
More information about the Libc-alpha
mailing list