[PATCH v5 4/5] Fix assert during static startup

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Feb 2 20:47:23 GMT 2026



On 02/02/26 14:03, Adhemerval Zanella Netto wrote:

>>
>>> diff --git a/sysdeps/unix/sysv/linux/i386/dl-mmap.h b/sysdeps/unix/sysv/linux/i386/dl-mmap.h
>>> new file mode 100644
>>> index 0000000000..944f7deb27
>>> --- /dev/null
>>> +++ b/sysdeps/unix/sysv/linux/i386/dl-mmap.h
>>> @@ -0,0 +1,38 @@
>>> +/* mmap wrapper for dynamic loader.
>>
>>> +#include <sys/mman.h>
>>> +#include <mmap_internal.h>
>>> +
>>> +/* This mmap call is used to allocate some memory to backup assert() messages
>>> +   before TLS setup is done, so it can not use "call *%gs:SYSINFO_OFFSET"
>>> +   during startup in static PIE.  */
>>> +#if BUILD_PIE_DEFAULT
>>> +# define I386_USE_SYSENTER 0
>>> +#endif
>>> +
>>> +static inline void *
>>> +_dl_mmap (void *addr, size_t len, int prot, int flags)
>>> +{
>>> +  return (void *) MMAP_CALL (mmap2, addr, len, prot, flags, -1, 0);
>>> +}
>>
>> Isn't it too late to define the macro here?  As far as I can see, it's
>> used in #if conditionals <sysdep.h>.  Maybe check that <sysdep.h> isn't
>> included at this point, via #ifdef/#error/#endif?
> 
> I think it makes sense to check for ifdef in this case. I will change it.

In fact this does work as expected, since I386_USE_SYSENTER evaluation will
be required only at the MMAP_CALL expansion and redefine it will not trigger
an error.  I will add a #undef to make it clear.


More information about the Libc-alpha mailing list