diff mbox series

[v2,15/19] elf: Remove any_debug from dl_main_state

Message ID 20231017130526.2216827-16-adhemerval.zanella@linaro.org
State Superseded
Headers show
Series Improve loader environment variable handling | expand

Commit Message

Adhemerval Zanella Netto Oct. 17, 2023, 1:05 p.m. UTC
Its usage can be implied by the GLRO(dl_debug_mask).
---
 elf/dl-main.h | 3 ---
 elf/rtld.c    | 6 ++----
 2 files changed, 2 insertions(+), 7 deletions(-)

Comments

Siddhesh Poyarekar Oct. 27, 2023, 2:26 p.m. UTC | #1
On 2023-10-17 09:05, Adhemerval Zanella wrote:
> Its usage can be implied by the GLRO(dl_debug_mask).
> ---
>   elf/dl-main.h | 3 ---
>   elf/rtld.c    | 6 ++----
>   2 files changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/elf/dl-main.h b/elf/dl-main.h
> index 92766d06b4..f876904cb6 100644
> --- a/elf/dl-main.h
> +++ b/elf/dl-main.h
> @@ -97,9 +97,6 @@ struct dl_main_state
>     /* True if program should be also printed for rtld_mode_trace.  */
>     bool mode_trace_program;
>   
> -  /* True if any of the debugging options is enabled.  */
> -  bool any_debug;
> -
>     /* True if information about versions has to be printed.  */
>     bool version_info;
>   };
> diff --git a/elf/rtld.c b/elf/rtld.c
> index 8749ad6288..638b019670 100644
> --- a/elf/rtld.c
> +++ b/elf/rtld.c
> @@ -300,7 +300,6 @@ dl_main_state_init (struct dl_main_state *state)
>     state->glibc_hwcaps_prepend = NULL;
>     state->glibc_hwcaps_mask = NULL;
>     state->mode = rtld_mode_normal;
> -  state->any_debug = false;
>     state->version_info = false;
>   }
>   
> @@ -2481,7 +2480,6 @@ process_dl_debug (struct dl_main_state *state, const char *dl_debug)
>   		&& memcmp (dl_debug, debopts[cnt].name, len) == 0)
>   	      {
>   		GLRO(dl_debug_mask) |= debopts[cnt].mask;
> -		state->any_debug = true;
>   		break;
>   	      }
>   
> @@ -2552,7 +2550,7 @@ process_envvars (struct dl_main_state *state)
>   	{
>   	case 4:
>   	  /* Warning level, verbose or not.  */
> -	  if (!!__libc_enable_secure
> +	  if (!__libc_enable_secure

This probably belongs in 14/19.

>   	      && memcmp (envline, "WARN", 4) == 0)
>   	    GLRO(dl_verbose) = envline[5] != '\0';
>   	  break;
> @@ -2682,7 +2680,7 @@ process_envvars (struct dl_main_state *state)
>     /* If we have to run the dynamic linker in debugging mode and the
>        LD_DEBUG_OUTPUT environment variable is given, we write the debug
>        messages to this file.  */
> -  else if (state->any_debug && debug_output != NULL)
> +  else if (GLRO(dl_debug_mask) != 0 && debug_output != NULL)
>       {
>         const int flags = O_WRONLY | O_APPEND | O_CREAT | O_NOFOLLOW;
>         size_t name_len = strlen (debug_output);
Adhemerval Zanella Netto Oct. 30, 2023, 7:03 p.m. UTC | #2
On 27/10/23 11:26, Siddhesh Poyarekar wrote:
> 
> 
> On 2023-10-17 09:05, Adhemerval Zanella wrote:
>> Its usage can be implied by the GLRO(dl_debug_mask).
>> ---
>>   elf/dl-main.h | 3 ---
>>   elf/rtld.c    | 6 ++----
>>   2 files changed, 2 insertions(+), 7 deletions(-)
>>
>> diff --git a/elf/dl-main.h b/elf/dl-main.h
>> index 92766d06b4..f876904cb6 100644
>> --- a/elf/dl-main.h
>> +++ b/elf/dl-main.h
>> @@ -97,9 +97,6 @@ struct dl_main_state
>>     /* True if program should be also printed for rtld_mode_trace.  */
>>     bool mode_trace_program;
>>   -  /* True if any of the debugging options is enabled.  */
>> -  bool any_debug;
>> -
>>     /* True if information about versions has to be printed.  */
>>     bool version_info;
>>   };
>> diff --git a/elf/rtld.c b/elf/rtld.c
>> index 8749ad6288..638b019670 100644
>> --- a/elf/rtld.c
>> +++ b/elf/rtld.c
>> @@ -300,7 +300,6 @@ dl_main_state_init (struct dl_main_state *state)
>>     state->glibc_hwcaps_prepend = NULL;
>>     state->glibc_hwcaps_mask = NULL;
>>     state->mode = rtld_mode_normal;
>> -  state->any_debug = false;
>>     state->version_info = false;
>>   }
>>   @@ -2481,7 +2480,6 @@ process_dl_debug (struct dl_main_state *state, const char *dl_debug)
>>           && memcmp (dl_debug, debopts[cnt].name, len) == 0)
>>             {
>>           GLRO(dl_debug_mask) |= debopts[cnt].mask;
>> -        state->any_debug = true;
>>           break;
>>             }
>>   @@ -2552,7 +2550,7 @@ process_envvars (struct dl_main_state *state)
>>       {
>>       case 4:
>>         /* Warning level, verbose or not.  */
>> -      if (!!__libc_enable_secure
>> +      if (!__libc_enable_secure
> 
> This probably belongs in 14/19.
> 

Indeed.

>>             && memcmp (envline, "WARN", 4) == 0)
>>           GLRO(dl_verbose) = envline[5] != '\0';
>>         break;
>> @@ -2682,7 +2680,7 @@ process_envvars (struct dl_main_state *state)
>>     /* If we have to run the dynamic linker in debugging mode and the
>>        LD_DEBUG_OUTPUT environment variable is given, we write the debug
>>        messages to this file.  */
>> -  else if (state->any_debug && debug_output != NULL)
>> +  else if (GLRO(dl_debug_mask) != 0 && debug_output != NULL)
>>       {
>>         const int flags = O_WRONLY | O_APPEND | O_CREAT | O_NOFOLLOW;
>>         size_t name_len = strlen (debug_output);
diff mbox series

Patch

diff --git a/elf/dl-main.h b/elf/dl-main.h
index 92766d06b4..f876904cb6 100644
--- a/elf/dl-main.h
+++ b/elf/dl-main.h
@@ -97,9 +97,6 @@  struct dl_main_state
   /* True if program should be also printed for rtld_mode_trace.  */
   bool mode_trace_program;
 
-  /* True if any of the debugging options is enabled.  */
-  bool any_debug;
-
   /* True if information about versions has to be printed.  */
   bool version_info;
 };
diff --git a/elf/rtld.c b/elf/rtld.c
index 8749ad6288..638b019670 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -300,7 +300,6 @@  dl_main_state_init (struct dl_main_state *state)
   state->glibc_hwcaps_prepend = NULL;
   state->glibc_hwcaps_mask = NULL;
   state->mode = rtld_mode_normal;
-  state->any_debug = false;
   state->version_info = false;
 }
 
@@ -2481,7 +2480,6 @@  process_dl_debug (struct dl_main_state *state, const char *dl_debug)
 		&& memcmp (dl_debug, debopts[cnt].name, len) == 0)
 	      {
 		GLRO(dl_debug_mask) |= debopts[cnt].mask;
-		state->any_debug = true;
 		break;
 	      }
 
@@ -2552,7 +2550,7 @@  process_envvars (struct dl_main_state *state)
 	{
 	case 4:
 	  /* Warning level, verbose or not.  */
-	  if (!!__libc_enable_secure
+	  if (!__libc_enable_secure
 	      && memcmp (envline, "WARN", 4) == 0)
 	    GLRO(dl_verbose) = envline[5] != '\0';
 	  break;
@@ -2682,7 +2680,7 @@  process_envvars (struct dl_main_state *state)
   /* If we have to run the dynamic linker in debugging mode and the
      LD_DEBUG_OUTPUT environment variable is given, we write the debug
      messages to this file.  */
-  else if (state->any_debug && debug_output != NULL)
+  else if (GLRO(dl_debug_mask) != 0 && debug_output != NULL)
     {
       const int flags = O_WRONLY | O_APPEND | O_CREAT | O_NOFOLLOW;
       size_t name_len = strlen (debug_output);