[v3,3/6] Initialize l_mach field from rtld link_map

Message ID 20250903135251.679132-4-jovan.dmitrovic@htecgroup.com (mailing list archive)
State New
Headers
Series Improve Mips target |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Jovan Dmitrovic Sept. 3, 2025, 1:53 p.m. UTC
  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 | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Adhemerval Zanella Netto Sept. 17, 2025, 9:08 p.m. UTC | #1
On 03/09/25 10:53, Jovan Dmitrovic wrote:
> 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 | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/elf/rtld.c b/elf/rtld.c
> index 753ce6690b..10bf816e7f 100644
> --- a/elf/rtld.c
> +++ b/elf/rtld.c
> @@ -532,6 +532,7 @@ _dl_start (void *arg)
>       do not have to use the temporary bootstrap_map.  Global variables
>       are initialized to zero by default.  */
>  #ifndef DONT_USE_BOOTSTRAP_MAP
> +  bootstrap_map.l_mach = (struct link_map_machine) {};
>  # ifdef HAVE_BUILTIN_MEMSET
>    __builtin_memset (bootstrap_map.l_info, '\0', sizeof (bootstrap_map.l_info));
>  # else

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.
  
Sandra Loosemore Sept. 18, 2025, 4:22 a.m. UTC | #2
On 9/17/25 15:08, Adhemerval Zanella Netto wrote:
> 
> 
> On 03/09/25 10:53, Jovan Dmitrovic wrote:
>> 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 | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/elf/rtld.c b/elf/rtld.c
>> index 753ce6690b..10bf816e7f 100644
>> --- a/elf/rtld.c
>> +++ b/elf/rtld.c
>> @@ -532,6 +532,7 @@ _dl_start (void *arg)
>>        do not have to use the temporary bootstrap_map.  Global variables
>>        are initialized to zero by default.  */
>>   #ifndef DONT_USE_BOOTSTRAP_MAP
>> +  bootstrap_map.l_mach = (struct link_map_machine) {};
>>   # ifdef HAVE_BUILTIN_MEMSET
>>     __builtin_memset (bootstrap_map.l_info, '\0', sizeof (bootstrap_map.l_info));
>>   # else
> 
> 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.

That's what my original version of the patch did....  :-)

-Sandra
  

Patch

diff --git a/elf/rtld.c b/elf/rtld.c
index 753ce6690b..10bf816e7f 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -532,6 +532,7 @@  _dl_start (void *arg)
      do not have to use the temporary bootstrap_map.  Global variables
      are initialized to zero by default.  */
 #ifndef DONT_USE_BOOTSTRAP_MAP
+  bootstrap_map.l_mach = (struct link_map_machine) {};
 # ifdef HAVE_BUILTIN_MEMSET
   __builtin_memset (bootstrap_map.l_info, '\0', sizeof (bootstrap_map.l_info));
 # else