[PATCH] elf: Use dl-symbol-redir-ifunc.h instead _dl_strlen

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Wed Feb 11 18:54:43 GMT 2026



On 11/02/26 15:52, Florian Weimer wrote:
> * Adhemerval Zanella Netto:
> 
>> On 11/02/26 15:31, Florian Weimer wrote:
>>> * Adhemerval Zanella Netto:
>>>
>>>> On 11/02/26 10:58, Florian Weimer wrote:
>>>>> * Adhemerval Zanella:
>>>>>
>>>>>>  static char **
>>>>>>  get_next_env (char **envp, char **name, char **val, char ***prev_envp)
>>>>>>  {
>>>>>> @@ -334,8 +324,9 @@ __tunables_init (char **envp)
>>>>>>  
>>>>>>  	  if (tunable_is_name (name, envname))
>>>>>>  	    {
>>>>>> +	      size_t envvallen = 0;
>>>>>>  	      /* The environment variable is always null-terminated.  */
>>>>>> -	      size_t envvallen = _dl_strlen (envval);
>>>>>> +	      for (const char *p = envval; *p != '\0'; p++, envvallen++);
>>>>>
>>>>
>>>> Because it would require potentially more dl-symbol-redir-ifunc.h change
>>>> than the ones I am testing now (x86_64/aarch64).  At least for clang-21,
>>>> we only supports these architectures.
>>>
>>> Then this needs a comment why we can't use strlen.
>>
>> I think we can, it is just that it might require additional machinery on
>> dl-symbol-redir-ifunc.h for different architectures than the one I checked
>> for the _dl_strlen addition.  
>>
>> So I went for simplicity, where I know that it should not change gcc code 
>> generation. 
> 
> Still I think this should a comment that refers to the 
> -fno-tree-loop-distribute-patterns flag used to build elf/dl-tunables.c
> (otherwise this strlen avoidance wouldn't work).

I might check whether we still require it. I think we still need it for
rtld.c becase DONT_USE_BOOTSTRAP_MAP/HAVE_BUILTIN_MEMSET; but I think we
can remove it from dl-tunables.c


More information about the Libc-alpha mailing list