179894
commit 851f32cf7bf7067f73b991610778915edd57d7b4
179894
Author: Florian Weimer <fweimer@redhat.com>
179894
Date:   Tue Mar 2 14:38:42 2021 +0100
179894
179894
    ld.so: Implement the --list-diagnostics option
179894
179894
diff --git a/elf/Makefile b/elf/Makefile
179894
index aa65ec59f143bccf..d246f1c0d9e019fd 100644
179894
--- a/elf/Makefile
179894
+++ b/elf/Makefile
179894
@@ -64,7 +64,7 @@ elide-routines.os = $(all-dl-routines) dl-support enbl-secure dl-origin \
179894
 # interpreter and operating independent of libc.
179894
 rtld-routines	= rtld $(all-dl-routines) dl-sysdep dl-environ dl-minimal \
179894
   dl-error-minimal dl-conflict dl-hwcaps dl-hwcaps_split dl-hwcaps-subdirs \
179894
-  dl-usage
179894
+  dl-usage dl-diagnostics dl-diagnostics-kernel dl-diagnostics-cpu
179894
 all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
179894
 
179894
 CFLAGS-dl-runtime.c += -fexceptions -fasynchronous-unwind-tables
179894
@@ -672,6 +672,9 @@ CFLAGS-cache.c += $(SYSCONF-FLAGS)
179894
 CFLAGS-rtld.c += $(SYSCONF-FLAGS)
179894
 CFLAGS-dl-usage.c += $(SYSCONF-FLAGS) \
179894
   -D'RTLD="$(rtlddir)/$(rtld-installed-name)"'
179894
+CFLAGS-dl-diagnostics.c += $(SYSCONF-FLAGS) \
179894
+  -D'PREFIX="$(prefix)"' \
179894
+  -D'RTLD="$(rtlddir)/$(rtld-installed-name)"'
179894
 
179894
 cpp-srcs-left := $(all-rtld-routines:=.os)
179894
 lib := rtld
179894
diff --git a/elf/dl-diagnostics-cpu.c b/elf/dl-diagnostics-cpu.c
179894
new file mode 100644
179894
index 0000000000000000..f7d149764bcb35a1
179894
--- /dev/null
179894
+++ b/elf/dl-diagnostics-cpu.c
179894
@@ -0,0 +1,24 @@
179894
+/* Print CPU diagnostics data in ld.so.  Stub version.
179894
+   Copyright (C) 2021 Free Software Foundation, Inc.
179894
+   This file is part of the GNU C Library.
179894
+
179894
+   The GNU C Library is free software; you can redistribute it and/or
179894
+   modify it under the terms of the GNU Lesser General Public
179894
+   License as published by the Free Software Foundation; either
179894
+   version 2.1 of the License, or (at your option) any later version.
179894
+
179894
+   The GNU C Library is distributed in the hope that it will be useful,
179894
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
179894
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
179894
+   Lesser General Public License for more details.
179894
+
179894
+   You should have received a copy of the GNU Lesser General Public
179894
+   License along with the GNU C Library; if not, see
179894
+   <https://www.gnu.org/licenses/>.  */
179894
+
179894
+#include <dl-diagnostics.h>
179894
+
179894
+void
179894
+_dl_diagnostics_cpu (void)
179894
+{
179894
+}
179894
diff --git a/elf/dl-diagnostics-kernel.c b/elf/dl-diagnostics-kernel.c
179894
new file mode 100644
179894
index 0000000000000000..831c358f1463cbf4
179894
--- /dev/null
179894
+++ b/elf/dl-diagnostics-kernel.c
179894
@@ -0,0 +1,24 @@
179894
+/* Print kernel diagnostics data in ld.so.  Stub version.
179894
+   Copyright (C) 2021 Free Software Foundation, Inc.
179894
+   This file is part of the GNU C Library.
179894
+
179894
+   The GNU C Library is free software; you can redistribute it and/or
179894
+   modify it under the terms of the GNU Lesser General Public
179894
+   License as published by the Free Software Foundation; either
179894
+   version 2.1 of the License, or (at your option) any later version.
179894
+
179894
+   The GNU C Library is distributed in the hope that it will be useful,
179894
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
179894
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
179894
+   Lesser General Public License for more details.
179894
+
179894
+   You should have received a copy of the GNU Lesser General Public
179894
+   License along with the GNU C Library; if not, see
179894
+   <https://www.gnu.org/licenses/>.  */
179894
+
179894
+#include <dl-diagnostics.h>
179894
+
179894
+void
179894
+_dl_diagnostics_kernel (void)
179894
+{
179894
+}
179894
diff --git a/elf/dl-diagnostics.c b/elf/dl-diagnostics.c
179894
new file mode 100644
179894
index 0000000000000000..bef224b36cbf5fc3
179894
--- /dev/null
179894
+++ b/elf/dl-diagnostics.c
179894
@@ -0,0 +1,265 @@
179894
+/* Print diagnostics data in ld.so.
179894
+   Copyright (C) 2021 Free Software Foundation, Inc.
179894
+   This file is part of the GNU C Library.
179894
+
179894
+   The GNU C Library is free software; you can redistribute it and/or
179894
+   modify it under the terms of the GNU Lesser General Public
179894
+   License as published by the Free Software Foundation; either
179894
+   version 2.1 of the License, or (at your option) any later version.
179894
+
179894
+   The GNU C Library is distributed in the hope that it will be useful,
179894
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
179894
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
179894
+   Lesser General Public License for more details.
179894
+
179894
+   You should have received a copy of the GNU Lesser General Public
179894
+   License along with the GNU C Library; if not, see
179894
+   <https://www.gnu.org/licenses/>.  */
179894
+
179894
+#include <gnu/lib-names.h>
179894
+#include <stdbool.h>
179894
+#include <stddef.h>
179894
+#include <unistd.h>
179894
+
179894
+#include <dl-diagnostics.h>
179894
+#include <dl-hwcaps.h>
179894
+#include <dl-main.h>
179894
+#include <dl-procinfo.h>
179894
+#include <dl-sysdep.h>
179894
+#include <ldsodefs.h>
179894
+#include "trusted-dirs.h"
179894
+#include "version.h"
179894
+
179894
+/* Write CH to standard output.  */
179894
+static void
179894
+_dl_putc (char ch)
179894
+{
179894
+  _dl_write (STDOUT_FILENO, &ch, 1);
179894
+}
179894
+
179894
+/* Print CH to standard output, quoting it if necessary.  */
179894
+static void
179894
+print_quoted_char (char ch)
179894
+{
179894
+  if (ch < ' ' || ch > '~')
179894
+    {
179894
+      char buf[4];
179894
+      buf[0] = '\\';
179894
+      buf[1] = '0' + ((ch >> 6) & 7);
179894
+      buf[2] = '0' + ((ch >> 6) & 7);
179894
+      buf[3] = '0' + (ch & 7);
179894
+      _dl_write (STDOUT_FILENO, buf, 4);
179894
+    }
179894
+  else
179894
+    {
179894
+      if (ch == '\\' || ch == '"')
179894
+        _dl_putc ('\\');
179894
+      _dl_putc (ch);
179894
+    }
179894
+}
179894
+
179894
+/* Print S of LEN bytes to standard output, quoting characters as
179894
+   needed.  */
179894
+static void
179894
+print_string_length (const char *s, size_t len)
179894
+{
179894
+  _dl_putc ('"');
179894
+  for (size_t i = 0; i < len; ++i)
179894
+    print_quoted_char (s[i]);
179894
+  _dl_putc ('"');
179894
+}
179894
+
179894
+void
179894
+_dl_diagnostics_print_string (const char *s)
179894
+{
179894
+  if (s == NULL)
179894
+    {
179894
+      _dl_printf ("0x0");
179894
+      return;
179894
+    }
179894
+
179894
+  _dl_putc ('"');
179894
+  while (*s != '\0')
179894
+    {
179894
+      print_quoted_char (*s);
179894
+      ++s;
179894
+    }
179894
+  _dl_putc ('"');
179894
+}
179894
+
179894
+void
179894
+_dl_diagnostics_print_labeled_string (const char *label, const char *s)
179894
+{
179894
+  _dl_printf ("%s=", label);
179894
+  _dl_diagnostics_print_string (s);
179894
+  _dl_putc ('\n');
179894
+}
179894
+
179894
+void
179894
+_dl_diagnostics_print_labeled_value (const char *label, uint64_t value)
179894
+{
179894
+  if (sizeof (value) == sizeof (unsigned long int))
179894
+    /* _dl_printf can print 64-bit values directly.  */
179894
+    _dl_printf ("%s=0x%lx\n", label, (unsigned long int) value);
179894
+  else
179894
+    {
179894
+      uint32_t high = value >> 32;
179894
+      uint32_t low = value;
179894
+      if (high == 0)
179894
+        _dl_printf ("%s=0x%x\n", label, low);
179894
+      else
179894
+        _dl_printf ("%s=0x%x%08x\n", label, high, low);
179894
+    }
179894
+}
179894
+
179894
+/* Return true if ENV is an unfiltered environment variable.  */
179894
+static bool
179894
+unfiltered_envvar (const char *env, size_t *name_length)
179894
+{
179894
+  char *env_equal = strchr (env, '=');
179894
+  if (env_equal == NULL)
179894
+    {
179894
+      /* Always dump malformed entries.  */
179894
+      *name_length = strlen (env);
179894
+      return true;
179894
+    }
179894
+  size_t envname_length = env_equal - env;
179894
+  *name_length = envname_length;
179894
+
179894
+  /* LC_ and LD_ variables.  */
179894
+  if (env[0] == 'L' && (env[1] == 'C' || env[1] == 'D')
179894
+      && env[2] == '_')
179894
+    return true;
179894
+
179894
+  /* MALLOC_ variables.  */
179894
+  if (strncmp (env, "MALLOC_", strlen ("MALLOC_")) == 0)
179894
+    return true;
179894
+
179894
+  static const char unfiltered[] =
179894
+    "DATEMSK\0"
179894
+    "GCONV_PATH\0"
179894
+    "GETCONF_DIR\0"
179894
+    "GETCONF_DIR\0"
179894
+    "GLIBC_TUNABLES\0"
179894
+    "GMON_OUTPUT_PREFIX\0"
179894
+    "HESIOD_CONFIG\0"
179894
+    "HES_DOMAIN\0"
179894
+    "HOSTALIASES\0"
179894
+    "I18NPATH\0"
179894
+    "IFS\0"
179894
+    "LANG\0"
179894
+    "LOCALDOMAIN\0"
179894
+    "LOCPATH\0"
179894
+    "MSGVERB\0"
179894
+    "NIS_DEFAULTS\0"
179894
+    "NIS_GROUP\0"
179894
+    "NIS_PATH\0"
179894
+    "NLSPATH\0"
179894
+    "PATH\0"
179894
+    "POSIXLY_CORRECT\0"
179894
+    "RESOLV_HOST_CONF\0"
179894
+    "RES_OPTIONS\0"
179894
+    "SEV_LEVEL\0"
179894
+    "TMPDIR\0"
179894
+    "TZ\0"
179894
+    "TZDIR\0"
179894
+    /* Two null bytes at the end to mark the end of the list via an
179894
+       empty substring.  */
179894
+    ;
179894
+  for (const char *candidate = unfiltered; *candidate != '\0'; )
179894
+    {
179894
+      size_t candidate_length = strlen (candidate);
179894
+      if (candidate_length == envname_length
179894
+          && memcmp (candidate, env, candidate_length) == 0)
179894
+        return true;
179894
+      candidate += candidate_length + 1;
179894
+    }
179894
+
179894
+  return false;
179894
+}
179894
+
179894
+/* Dump the process environment.  */
179894
+static void
179894
+print_environ (char **environ)
179894
+{
179894
+  unsigned int index = 0;
179894
+  for (char **envp = environ; *envp != NULL; ++envp)
179894
+    {
179894
+      char *env = *envp;
179894
+      size_t name_length;
179894
+      bool unfiltered = unfiltered_envvar (env, &name_length);
179894
+      _dl_printf ("env%s[0x%x]=",
179894
+                  unfiltered ? "" : "_filtered", index);
179894
+      if (unfiltered)
179894
+        _dl_diagnostics_print_string (env);
179894
+      else
179894
+        print_string_length (env, name_length);
179894
+      _dl_putc ('\n');
179894
+      ++index;
179894
+    }
179894
+}
179894
+
179894
+/* Print configured paths and the built-in search path.  */
179894
+static void
179894
+print_paths (void)
179894
+{
179894
+  _dl_diagnostics_print_labeled_string ("path.prefix", PREFIX);
179894
+  _dl_diagnostics_print_labeled_string ("path.rtld", RTLD);
179894
+  _dl_diagnostics_print_labeled_string ("path.sysconfdir", SYSCONFDIR);
179894
+
179894
+  unsigned int index = 0;
179894
+  static const char *system_dirs = SYSTEM_DIRS "\0";
179894
+  for (const char *e = system_dirs; *e != '\0'; )
179894
+    {
179894
+      size_t len = strlen (e);
179894
+      _dl_printf ("path.system_dirs[0x%x]=", index);
179894
+      print_string_length (e, len);
179894
+      _dl_putc ('\n');
179894
+      ++index;
179894
+      e += len + 1;
179894
+    }
179894
+}
179894
+
179894
+/* Print information about the glibc version.  */
179894
+static void
179894
+print_version (void)
179894
+{
179894
+  _dl_diagnostics_print_labeled_string ("version.release", RELEASE);
179894
+  _dl_diagnostics_print_labeled_string ("version.version", VERSION);
179894
+}
179894
+
179894
+void
179894
+_dl_print_diagnostics (char **environ)
179894
+{
179894
+#ifdef HAVE_DL_DISCOVER_OSVERSION
179894
+  _dl_diagnostics_print_labeled_value
179894
+    ("dl_discover_osversion", _dl_discover_osversion ());
179894
+#endif
179894
+  _dl_diagnostics_print_labeled_string ("dl_dst_lib", DL_DST_LIB);
179894
+  _dl_diagnostics_print_labeled_value ("dl_hwcap", GLRO (dl_hwcap));
179894
+  _dl_diagnostics_print_labeled_value ("dl_hwcap_important", HWCAP_IMPORTANT);
179894
+  _dl_diagnostics_print_labeled_value ("dl_hwcap2", GLRO (dl_hwcap2));
179894
+  _dl_diagnostics_print_labeled_string
179894
+    ("dl_hwcaps_subdirs", _dl_hwcaps_subdirs);
179894
+  _dl_diagnostics_print_labeled_value
179894
+    ("dl_hwcaps_subdirs_active", _dl_hwcaps_subdirs_active ());
179894
+  _dl_diagnostics_print_labeled_value ("dl_osversion", GLRO (dl_osversion));
179894
+  _dl_diagnostics_print_labeled_value ("dl_pagesize", GLRO (dl_pagesize));
179894
+  _dl_diagnostics_print_labeled_string ("dl_platform", GLRO (dl_platform));
179894
+  _dl_diagnostics_print_labeled_string
179894
+    ("dl_profile_output", GLRO (dl_profile_output));
179894
+  _dl_diagnostics_print_labeled_value
179894
+    ("dl_string_platform", _dl_string_platform ( GLRO (dl_platform)));
179894
+
179894
+  _dl_diagnostics_print_labeled_string ("dso.ld", LD_SO);
179894
+  _dl_diagnostics_print_labeled_string ("dso.libc", LIBC_SO);
179894
+
179894
+  print_environ (environ);
179894
+  print_paths ();
179894
+  print_version ();
179894
+
179894
+  _dl_diagnostics_kernel ();
179894
+  _dl_diagnostics_cpu ();
179894
+
179894
+  _exit (EXIT_SUCCESS);
179894
+}
179894
diff --git a/elf/dl-diagnostics.h b/elf/dl-diagnostics.h
179894
new file mode 100644
179894
index 0000000000000000..27dcb12bca12e5b6
179894
--- /dev/null
179894
+++ b/elf/dl-diagnostics.h
179894
@@ -0,0 +1,46 @@
179894
+/* Interfaces for printing diagnostics in ld.so.
179894
+   Copyright (C) 2021 Free Software Foundation, Inc.
179894
+   This file is part of the GNU C Library.
179894
+
179894
+   The GNU C Library is free software; you can redistribute it and/or
179894
+   modify it under the terms of the GNU Lesser General Public
179894
+   License as published by the Free Software Foundation; either
179894
+   version 2.1 of the License, or (at your option) any later version.
179894
+
179894
+   The GNU C Library is distributed in the hope that it will be useful,
179894
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
179894
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
179894
+   Lesser General Public License for more details.
179894
+
179894
+   You should have received a copy of the GNU Lesser General Public
179894
+   License along with the GNU C Library; if not, see
179894
+   <https://www.gnu.org/licenses/>.  */
179894
+
179894
+#ifndef _DL_DIAGNOSTICS_H
179894
+#define _DL_DIAGNOSTICS_H
179894
+
179894
+#include <stdint.h>
179894
+
179894
+/* Write the null-terminated string to standard output, surrounded in
179894
+   quotation marks.  */
179894
+void _dl_diagnostics_print_string (const char *s) attribute_hidden;
179894
+
179894
+/* Like _dl_diagnostics_print_string, but add a LABEL= prefix, and a
179894
+   newline character as a suffix.  */
179894
+void _dl_diagnostics_print_labeled_string (const char *label, const char *s)
179894
+  attribute_hidden;
179894
+
179894
+/* Print LABEL=VALUE to standard output, followed by a newline
179894
+   character.  */
179894
+void _dl_diagnostics_print_labeled_value (const char *label, uint64_t value)
179894
+  attribute_hidden;
179894
+
179894
+/* Print diagnostics data for the kernel.  Called from
179894
+   _dl_print_diagnostics.  */
179894
+void _dl_diagnostics_kernel (void) attribute_hidden;
179894
+
179894
+/* Print diagnostics data for the CPU(s).  Called from
179894
+   _dl_print_diagnostics.  */
179894
+void _dl_diagnostics_cpu (void) attribute_hidden;
179894
+
179894
+#endif /* _DL_DIAGNOSTICS_H */
179894
diff --git a/elf/dl-main.h b/elf/dl-main.h
179894
index 9e7b51d8f010e904..9fbbdb0fac09adf3 100644
179894
--- a/elf/dl-main.h
179894
+++ b/elf/dl-main.h
179894
@@ -63,7 +63,7 @@ struct audit_list
179894
 enum rtld_mode
179894
   {
179894
     rtld_mode_normal, rtld_mode_list, rtld_mode_verify, rtld_mode_trace,
179894
-    rtld_mode_list_tunables, rtld_mode_help,
179894
+    rtld_mode_list_tunables, rtld_mode_list_diagnostics, rtld_mode_help,
179894
   };
179894
 
179894
 /* Aggregated state information extracted from environment variables
179894
@@ -121,4 +121,7 @@ _Noreturn void _dl_version (void) attribute_hidden;
179894
 _Noreturn void _dl_help (const char *argv0, struct dl_main_state *state)
179894
   attribute_hidden;
179894
 
179894
+/* Print a diagnostics dump.  */
179894
+_Noreturn void _dl_print_diagnostics (char **environ) attribute_hidden;
179894
+
179894
 #endif /* _DL_MAIN */
179894
diff --git a/elf/dl-usage.c b/elf/dl-usage.c
179894
index 908b4894b3014b2d..e19e1791d9169da2 100644
179894
--- a/elf/dl-usage.c
179894
+++ b/elf/dl-usage.c
179894
@@ -261,6 +261,7 @@ setting environment variables (which would be inherited by subprocesses).\n\
179894
   --list-tunables       list all tunables with minimum and maximum values\n"
179894
 #endif
179894
 "\
179894
+  --list-diagnostics    list diagnostics information\n\
179894
   --help                display this help and exit\n\
179894
   --version             output version information and exit\n\
179894
 \n\
179894
diff --git a/elf/rtld.c b/elf/rtld.c
179894
index 54b621ec5ca014fa..d14c388f548d6d51 100644
179894
--- a/elf/rtld.c
179894
+++ b/elf/rtld.c
179894
@@ -138,6 +138,7 @@ static void dl_main_state_init (struct dl_main_state *state);
179894
 /* Process all environments variables the dynamic linker must recognize.
179894
    Since all of them start with `LD_' we are a bit smarter while finding
179894
    all the entries.  */
179894
+extern char **_environ attribute_hidden;
179894
 static void process_envvars (struct dl_main_state *state);
179894
 
179894
 #ifdef DL_ARGV_NOT_RELRO
179894
@@ -1273,6 +1274,14 @@ dl_main (const ElfW(Phdr) *phdr,
179894
 	    ++_dl_argv;
179894
 	  }
179894
 #endif
179894
+	else if (! strcmp (_dl_argv[1], "--list-diagnostics"))
179894
+	  {
179894
+	    state.mode = rtld_mode_list_diagnostics;
179894
+
179894
+	    ++_dl_skip_args;
179894
+	    --_dl_argc;
179894
+	    ++_dl_argv;
179894
+	  }
179894
 	else if (strcmp (_dl_argv[1], "--help") == 0)
179894
 	  {
179894
 	    state.mode = rtld_mode_help;
179894
@@ -1301,6 +1310,9 @@ dl_main (const ElfW(Phdr) *phdr,
179894
 	}
179894
 #endif
179894
 
179894
+      if (state.mode == rtld_mode_list_diagnostics)
179894
+	_dl_print_diagnostics (_environ);
179894
+
179894
       /* If we have no further argument the program was called incorrectly.
179894
 	 Grant the user some education.  */
179894
       if (_dl_argc < 2)
179894
@@ -2623,12 +2635,6 @@ a filename can be specified using the LD_DEBUG_OUTPUT environment variable.\n");
179894
     }
179894
 }
179894
 
179894
-/* Process all environments variables the dynamic linker must recognize.
179894
-   Since all of them start with `LD_' we are a bit smarter while finding
179894
-   all the entries.  */
179894
-extern char **_environ attribute_hidden;
179894
-
179894
-
179894
 static void
179894
 process_envvars (struct dl_main_state *state)
179894
 {
179894
diff --git a/sysdeps/unix/sysv/linux/dl-diagnostics-kernel.c b/sysdeps/unix/sysv/linux/dl-diagnostics-kernel.c
179894
new file mode 100644
179894
index 0000000000000000..59f6402c547ba590
179894
--- /dev/null
179894
+++ b/sysdeps/unix/sysv/linux/dl-diagnostics-kernel.c
179894
@@ -0,0 +1,77 @@
179894
+/* Print kernel diagnostics data in ld.so.  Linux version.
179894
+   Copyright (C) 2021 Free Software Foundation, Inc.
179894
+   This file is part of the GNU C Library.
179894
+
179894
+   The GNU C Library is free software; you can redistribute it and/or
179894
+   modify it under the terms of the GNU Lesser General Public
179894
+   License as published by the Free Software Foundation; either
179894
+   version 2.1 of the License, or (at your option) any later version.
179894
+
179894
+   The GNU C Library is distributed in the hope that it will be useful,
179894
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
179894
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
179894
+   Lesser General Public License for more details.
179894
+
179894
+   You should have received a copy of the GNU Lesser General Public
179894
+   License along with the GNU C Library; if not, see
179894
+   <https://www.gnu.org/licenses/>.  */
179894
+
179894
+#include <dl-diagnostics.h>
179894
+#include <ldsodefs.h>
179894
+#include <sys/utsname.h>
179894
+
179894
+/* Dump the auxiliary vector to standard output.  */
179894
+static void
179894
+print_auxv (void)
179894
+{
179894
+  /* See _dl_show_auxv.  The code below follows the general output
179894
+     format for diagnostic dumps.  */
179894
+  unsigned int index = 0;
179894
+  for (ElfW(auxv_t) *av = GLRO(dl_auxv); av->a_type != AT_NULL; ++av)
179894
+    {
179894
+      _dl_printf ("auxv[0x%x].a_type=0x%lx\n"
179894
+                  "auxv[0x%x].a_val=",
179894
+                  index, (unsigned long int) av->a_type, index);
179894
+      if (av->a_type == AT_EXECFN
179894
+          || av->a_type == AT_PLATFORM
179894
+          || av->a_type == AT_BASE_PLATFORM)
179894
+        /* The address of the strings is not useful at all, so print
179894
+           the strings themselvs.  */
179894
+        _dl_diagnostics_print_string ((const char *) av->a_un.a_val);
179894
+      else
179894
+        _dl_printf ("0x%lx", (unsigned long int) av->a_un.a_val);
179894
+      _dl_printf ("\n");
179894
+      ++index;
179894
+    }
179894
+}
179894
+
179894
+/* Print one uname entry.  */
179894
+static void
179894
+print_utsname_entry (const char *field, const char *value)
179894
+{
179894
+  _dl_printf ("uname.");
179894
+  _dl_diagnostics_print_labeled_string (field, value);
179894
+}
179894
+
179894
+/* Print information from uname, including the kernel version.  */
179894
+static void
179894
+print_uname (void)
179894
+{
179894
+  struct utsname uts;
179894
+  if (__uname (&uts) == 0)
179894
+    {
179894
+      print_utsname_entry ("sysname", uts.sysname);
179894
+      print_utsname_entry ("nodename", uts.nodename);
179894
+      print_utsname_entry ("release", uts.release);
179894
+      print_utsname_entry ("version", uts.version);
179894
+      print_utsname_entry ("machine", uts.machine);
179894
+      print_utsname_entry ("domainname", uts.domainname);
179894
+    }
179894
+}
179894
+
179894
+void
179894
+_dl_diagnostics_kernel (void)
179894
+{
179894
+  print_auxv ();
179894
+  print_uname ();
179894
+}