unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Stefan Liebler <stli@linux.ibm.com>
To: GNU C Library <libc-alpha@sourceware.org>
Subject: [PATCH] Fix output of LD_SHOW_AUXV=1.
Date: Fri, 8 Mar 2019 13:52:26 +0100	[thread overview]
Message-ID: <dbc57505-7375-2344-d3db-c9fa65ced3ca@linux.ibm.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1036 bytes --]

Hi,

starting with commit 1616d034b61622836d3a36af53dcfca7624c844e
the output was corrupted on some platforms as _dl_procinfo
was called for every auxv entry and on some architectures like s390
all entries were represented as "AT_HWCAP".

This patch fixes the condition which determines if _dl_procinfo
is called and adjusts _dl_procinfo implementations which assumed
that they are only called for AT_HWCAP or AT_HWCAP2.

A further question is if we should always call _dl_procinfo without a 
condition and let it decide if it is able to print an entry or if it 
should be printed with help of the auxvars list?

Okay to commit?
Once it is committed I would also backport it to glibc 2.29 release branch.

Bye,
Stefan

ChangeLog:

	* elf/dl-sysdep.c (_dl_show_auxv): Fix condition if _dl_procinfo
	is called.
	* sysdeps/unix/sysv/linux/s390/dl-procinfo.h (_dl_procinfo):
	Ignore types other than AT_HWCAP.
	* sysdeps/sparc/dl-procinfo.h (_dl_procinfo): Likewise.
	* sysdeps/unix/sysv/linux/i386/dl-procinfo.h (_dl_procinfo):
	Likewise.

[-- Attachment #2: 20190308_ldshowauxv.patch --]
[-- Type: text/x-patch, Size: 3021 bytes --]

commit 5bbde0719d7c5fa58b0140d6fb1c6fa31a372772
Author: Stefan Liebler <stli@linux.ibm.com>
Date:   Fri Mar 8 11:18:53 2019 +0100

    Fix output of LD_SHOW_AUXV=1.
    
    Starting with commit 1616d034b61622836d3a36af53dcfca7624c844e
    the output was corrupted on some platforms as _dl_procinfo
    was called for every auxv entry and on some architectures like s390
    all entries were represented as "AT_HWCAP".
    
    This patch fixes the condition which determines if _dl_procinfo
    is called and adjusts _dl_procinfo implementations which assumed
    that they are only called for AT_HWCAP or AT_HWCAP2.
    
    ChangeLog:
    
            * elf/dl-sysdep.c (_dl_show_auxv): Fix condition if _dl_procinfo
            is called.
            * sysdeps/unix/sysv/linux/s390/dl-procinfo.h (_dl_procinfo):
            Ignore types other than AT_HWCAP.
            * sysdeps/sparc/dl-procinfo.h (_dl_procinfo): Likewise.
            * sysdeps/unix/sysv/linux/i386/dl-procinfo.h (_dl_procinfo): Likewise.

diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c
index 5f6c679a3f..1588555651 100644
--- a/elf/dl-sysdep.c
+++ b/elf/dl-sysdep.c
@@ -329,8 +329,10 @@ _dl_show_auxv (void)
       assert (AT_IGNORE == 1);
 
       if (av->a_type == AT_HWCAP || av->a_type == AT_HWCAP2
-	  || AT_L1I_CACHEGEOMETRY || AT_L1D_CACHEGEOMETRY
-	  || AT_L2_CACHEGEOMETRY || AT_L3_CACHEGEOMETRY)
+	  || av->a_type == AT_L1I_CACHEGEOMETRY
+	  || av->a_type == AT_L1D_CACHEGEOMETRY
+	  || av->a_type == AT_L2_CACHEGEOMETRY
+	  || av->a_type == AT_L3_CACHEGEOMETRY)
 	{
 	  /* These are handled in a special way per platform.  */
 	  if (_dl_procinfo (av->a_type, av->a_un.a_val) == 0)
diff --git a/sysdeps/sparc/dl-procinfo.h b/sysdeps/sparc/dl-procinfo.h
index 282b8c5117..cc2687e99b 100644
--- a/sysdeps/sparc/dl-procinfo.h
+++ b/sysdeps/sparc/dl-procinfo.h
@@ -32,7 +32,7 @@ _dl_procinfo (unsigned int type, unsigned long int word)
   int i;
 
   /* Fallback to unknown output mechanism.  */
-  if (type == AT_HWCAP2)
+  if (type != AT_HWCAP)
     return -1;
 
   _dl_printf ("AT_HWCAP:   ");
diff --git a/sysdeps/unix/sysv/linux/i386/dl-procinfo.h b/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
index 22b43431bc..3aef14c6c1 100644
--- a/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
+++ b/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
@@ -31,7 +31,7 @@ _dl_procinfo (unsigned int type, unsigned long int word)
   int i;
 
   /* Fallback to unknown output mechanism.  */
-  if (type == AT_HWCAP2)
+  if (type != AT_HWCAP)
     return -1;
 
   _dl_printf ("AT_HWCAP:   ");
diff --git a/sysdeps/unix/sysv/linux/s390/dl-procinfo.h b/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
index 19329a335b..16739fd6cd 100644
--- a/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
+++ b/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
@@ -33,7 +33,7 @@ _dl_procinfo (unsigned int type, unsigned long int word)
   int i;
 
   /* Fallback to unknown output mechanism.  */
-  if (type == AT_HWCAP2)
+  if (type != AT_HWCAP)
     return -1;
 
   _dl_printf ("AT_HWCAP:   ");

             reply	other threads:[~2019-03-08 12:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-08 12:52 Stefan Liebler [this message]
2019-03-08 14:51 ` [PATCH] Fix output of LD_SHOW_AUXV=1 Carlos O'Donell
2019-03-12 15:06   ` Stefan Liebler
2019-03-12 20:11     ` Carlos O'Donell
2019-03-13  9:54       ` [2.29 COMMITTED] " Stefan Liebler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dbc57505-7375-2344-d3db-c9fa65ced3ca@linux.ibm.com \
    --to=stli@linux.ibm.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).