[External] : Re: [RFC][PATCH 1/3] [gdb] Fix parsing of auxiliary vector on Solaris.

Simon Marchi simon.marchi@polymtl.ca
Thu Jul 15 12:56:35 GMT 2021


On 2021-07-15 3:40 a.m., Libor Bukata wrote:
> I revised the patch based on Simon's hints (thanks!) and verified
> that auxiliary vector is correctly parsed on Solaris SPARC/x86.
> Added binutils@sourceware.org to get an approval of
> elf/common.h changes. Thank you.
> 
> From 94228f4bffe0665ecdaae343aa042c2b7620c6b5 Mon Sep 17 00:00:00 2001
> From: Libor Bukata <libor.bukata@oracle.com>
> Date: Wed, 14 Jul 2021 09:43:27 +0200
> Subject: [PATCH 1/3] [gdb] Fix parsing of auxiliary vector on Solaris.
> 
> GDB fails to parse auxv vector on Solaris:
> $ echo 'int main(void) { return *(volatile int *)0=0; }' | \
>   gcc -o segv -Og -g -fPIE -pie -x c -
> $ ./segv
> Segmentation Fault (core dumped)
> $ gdb -batch ./segv core -ex 'info auxv'
> ...
> Core was generated by `./segv'.
> Program terminated with signal SIGSEGV, Segmentation fault.
> 0  0xffffffff7f400f04 in ?? ()
> ...
> 8650064134145  ???                 0xffffffff7ffff9f4
> 8624294339865  ???                 0xffffffff7ffff9f9
> 12884901888    ???                 0xffffffff7f400040
> 19327352832    ???                 0x38
> 23622254592    ???                 0x5
> 38654705664    ???                 0xffffffff7f400ca0
> 8658654068736  ???                 0xffffffff7f344000
> 30064771072    ???                 0xffffffff7f100000
> 34359738368    ???                 0xb00
> 25769803776    ???                 0x2000
> 8662949036032  ???                 0x102
> 8628589297664  ???                 0x3ff68df7
> 8688718839808  ???                 0xc01fe
> 8693013807104  ???                 0x0
> 0              AT_NULL             End of vector     0x0
> 
> Backtrace stopped prematurely because AT_ENTRY value was
> not correctly parsed from auxiliary vector. The reason
> why GDB failed to parse Solaris's auxiliary vector is
> that auxiliary type has 4 bytes (int type) on Solaris.
> 
> Tested on Solaris x86_64/sparcv9 and Linux x86_64.
> 
> include/ChangeLog:
> 
> 2021-07-15 Libor Bukata <libor.bukata@oracle.com>
> 
>   * elf/common.h (AT_SUN_CAP_HW3): New.
> ---
>  gdb/auxv.c           | 2 ++
>  gdb/sol2-tdep.c      | 4 ++++
>  include/ChangeLog    | 4 ++++
>  include/elf/common.h | 1 +
>  4 files changed, 11 insertions(+)
> 
> diff --git a/gdb/auxv.c b/gdb/auxv.c
> index 2bcf9f452e3..e96b30f00f1 100644
> --- a/gdb/auxv.c
> +++ b/gdb/auxv.c
> @@ -541,6 +541,8 @@ default_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
>         AUXV_FORMAT_HEX);
>        TAG (AT_SUN_CAP_HW2, _("Machine-dependent CPU capability hints 2"),
>         AUXV_FORMAT_HEX);
> +      TAG (AT_SUN_CAP_HW3, _("Machine-dependent CPU capability hints 3"),
> +       AUXV_FORMAT_HEX);
>      }
> 
>    fprint_auxv_entry (file, name, description, format, type, val);
> diff --git a/gdb/sol2-tdep.c b/gdb/sol2-tdep.c
> index 896f2426985..022f7302c7d 100644
> --- a/gdb/sol2-tdep.c
> +++ b/gdb/sol2-tdep.c
> @@ -18,6 +18,7 @@
>     along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> 
>  #include "defs.h"
> +#include "auxv.h"
>  #include "frame.h"
>  #include "symtab.h"
>  #include "inferior.h"
> @@ -114,4 +115,7 @@ sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
> 
>    /* How to print LWP PTIDs from core files.  */
>    set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
> +
> +  /* Solaris uses int type to store auxv type. */
> +  set_gdbarch_auxv_parse (gdbarch, svr4_auxv_parse);
>  }
> diff --git a/include/ChangeLog b/include/ChangeLog
> index 11001a3d1e3..5230eb827d0 100644
> --- a/include/ChangeLog
> +++ b/include/ChangeLog
> @@ -1,3 +1,7 @@
> +2021-07-15 Libor Bukata <libor.bukata@oracle.com>
> +
> +    * elf/common.h (AT_SUN_CAP_HW3): New.
> +
>  2021-07-03  Nick Clifton  <nickc@redhat.com>
> 
>      * 2.37 release branch created.
> diff --git a/include/elf/common.h b/include/elf/common.h
> index 0d381f0d27b..6e6287206ca 100644
> --- a/include/elf/common.h
> +++ b/include/elf/common.h
> @@ -1377,5 +1377,6 @@
>  #define    AT_SUN_BRAND_AUX2 2021
>  #define    AT_SUN_BRAND_AUX3 2022
>  #define    AT_SUN_CAP_HW2    2023    /* Extension of AT_SUN_CAP_HW1.  */
> +#define    AT_SUN_CAP_HW3    2024    /* Extension of AT_SUN_CAP_HW2.  */
> 
>  #endif /* _ELF_COMMON_H */

This is ok from the GDB side, I can merge it once we have approval from
the binutils side.

Simon


More information about the Binutils mailing list