diff mbox series

[1/3] Linux: Avoid conflicting types in ld.so --list-diagnostics

Message ID a2c08b57a253edc65f05ef325ff9fcd04cc419d5.1691172895.git.fweimer@redhat.com
State New
Headers show
Series Document ld.so --list-diagnostics, add syntax tests | expand

Commit Message

Florian Weimer Aug. 4, 2023, 6:16 p.m. UTC
The path auxv[*].a_val could either be an integer or a string,
depending on the a_type value.  Use a separate field, a_val_string, to
simplify mechanical parsing of the --list-diagnostics output.
---
 sysdeps/unix/sysv/linux/dl-diagnostics-kernel.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Adhemerval Zanella Aug. 21, 2023, 4:02 p.m. UTC | #1
On 04/08/23 15:16, Florian Weimer via Libc-alpha wrote:
> The path auxv[*].a_val could either be an integer or a string,
> depending on the a_type value.  Use a separate field, a_val_string, to
> simplify mechanical parsing of the --list-diagnostics output.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  sysdeps/unix/sysv/linux/dl-diagnostics-kernel.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/dl-diagnostics-kernel.c b/sysdeps/unix/sysv/linux/dl-diagnostics-kernel.c
> index e0cfa63da6..d522e2797e 100644
> --- a/sysdeps/unix/sysv/linux/dl-diagnostics-kernel.c
> +++ b/sysdeps/unix/sysv/linux/dl-diagnostics-kernel.c
> @@ -30,16 +30,19 @@ print_auxv (void)
>    for (ElfW(auxv_t) *av = GLRO(dl_auxv); av->a_type != AT_NULL; ++av)
>      {
>        _dl_printf ("auxv[0x%x].a_type=0x%lx\n"
> -                  "auxv[0x%x].a_val=",
> +                  "auxv[0x%x].a_val",
>                    index, (unsigned long int) av->a_type, index);
>        if (av->a_type == AT_EXECFN
>            || av->a_type == AT_PLATFORM
>            || av->a_type == AT_BASE_PLATFORM)
> -        /* The address of the strings is not useful at all, so print
> -           the strings themselves.  */
> -        _dl_diagnostics_print_string ((const char *) av->a_un.a_val);
> +        {
> +          /* The address of the strings is not useful at all, so print
> +             the strings themselves.  */
> +          _dl_printf ("_string=");
> +          _dl_diagnostics_print_string ((const char *) av->a_un.a_val);
> +        }
>        else
> -        _dl_printf ("0x%lx", (unsigned long int) av->a_un.a_val);
> +        _dl_printf ("=0x%lx", (unsigned long int) av->a_un.a_val);
>        _dl_printf ("\n");
>        ++index;
>      }
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/dl-diagnostics-kernel.c b/sysdeps/unix/sysv/linux/dl-diagnostics-kernel.c
index e0cfa63da6..d522e2797e 100644
--- a/sysdeps/unix/sysv/linux/dl-diagnostics-kernel.c
+++ b/sysdeps/unix/sysv/linux/dl-diagnostics-kernel.c
@@ -30,16 +30,19 @@  print_auxv (void)
   for (ElfW(auxv_t) *av = GLRO(dl_auxv); av->a_type != AT_NULL; ++av)
     {
       _dl_printf ("auxv[0x%x].a_type=0x%lx\n"
-                  "auxv[0x%x].a_val=",
+                  "auxv[0x%x].a_val",
                   index, (unsigned long int) av->a_type, index);
       if (av->a_type == AT_EXECFN
           || av->a_type == AT_PLATFORM
           || av->a_type == AT_BASE_PLATFORM)
-        /* The address of the strings is not useful at all, so print
-           the strings themselves.  */
-        _dl_diagnostics_print_string ((const char *) av->a_un.a_val);
+        {
+          /* The address of the strings is not useful at all, so print
+             the strings themselves.  */
+          _dl_printf ("_string=");
+          _dl_diagnostics_print_string ((const char *) av->a_un.a_val);
+        }
       else
-        _dl_printf ("0x%lx", (unsigned long int) av->a_un.a_val);
+        _dl_printf ("=0x%lx", (unsigned long int) av->a_un.a_val);
       _dl_printf ("\n");
       ++index;
     }