]> sourceware.org Git - binutils-gdb.git/commitdiff
[gdb/testsuite] Fix data alignment in gdb.arch/i386-{avx,sse}.exp
authorTom de Vries <tdevries@suse.de>
Mon, 6 Dec 2021 15:01:47 +0000 (16:01 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 6 Dec 2021 15:01:47 +0000 (16:01 +0100)
When running test-case gdb.arch/i386-avx.exp with clang I ran into:
...
(gdb) PASS: gdb.arch/i386-avx.exp: set first breakpoint in main
continue^M
Continuing.^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
0x000000000040052b in main (argc=1, argv=0x7fffffffd3c8) at i386-avx.c:54^M
54        asm ("vmovaps 0(%0), %%ymm0\n\t"^M
(gdb) FAIL: gdb.arch/i386-avx.exp: continue to breakpoint: \
  continue to first breakpoint in main
...

The problem is that the vmovaps insn requires an 256-bit (or 32-byte) aligned
address, and it's only 16-byte aligned:
...
(gdb) p /x $rax
$1 = 0x601030
...

Fix this by using a sufficiently aligned address, using _Alignas.

Compile using -std=gnu11 to support _Alignas.

Likewise in gdb.arch/i386-sse.exp.

Tested on x86_64-linux, with both gcc and clang.

gdb/testsuite/gdb.arch/i386-avx.c
gdb/testsuite/gdb.arch/i386-avx.exp
gdb/testsuite/gdb.arch/i386-sse.c
gdb/testsuite/gdb.arch/i386-sse.exp

index 4e938399a24bcadd67fe7f147e678d8f1e0938fa..765026c83fb07bb7e6839f4efbb23e893769a9b1 100644 (file)
 #include <stdio.h>
 #include "nat/x86-cpuid.h"
 
+/* Align sufficient to be able to use vmovaps.  */
+#define ALIGN 32
+
 typedef struct {
-  float f[8];
+  _Alignas (ALIGN) float f[8];
 } v8sf_t;
 
 
index 1b61a65d605906c832d0453534e0df7aa5c48f5c..d721b8c462492547d29e636a35c71239ed9bda0e 100644 (file)
@@ -35,12 +35,17 @@ if [get_compiler_info] {
     return -1
 }
 
-set additional_flags ""
+set flags { debug }
+
+# C11 for _Alignas, gnu for asm.
+lappend flags additional_flags=-std=gnu11
+
 if { [test_compiler_info gcc*] || [test_compiler_info clang*] } {
-    set additional_flags "additional_flags=-mavx -I${srcdir}/.."
+    lappend flags "additional_flags=-mavx -I${srcdir}/.."
 }
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
+         $flags] != "" } {
     unsupported "compiler does not support AVX"
     return
 }
index a5941a4071e87787fe4b33397e949a7e78fff27f..10bd4b62ff08b88d32a6f61717ceca217d9d5eff 100644 (file)
 #include <stdio.h>
 #include "nat/x86-cpuid.h"
 
+/* Align sufficient to be able to use movaps.  */
+#define ALIGN 16
+
 typedef struct {
-  float f[4];
+  _Alignas (ALIGN) float f[4];
 } v4sf_t;
 
 
index 1ee3a8444b32329558997c3b97f9074367c5c86a..15649e435f74a7de9deddd4ca200a6f29b8d59bf 100644 (file)
@@ -30,12 +30,17 @@ if [get_compiler_info] {
     return -1
 }
 
-set additional_flags ""
+set flags { debug }
+
+# C11 for _Alignas, gnu for asm.
+lappend flags additional_flags=-std=gnu11
+
 if { [test_compiler_info gcc*] || [test_compiler_info clang*] } {
-    set additional_flags "additional_flags=-msse -I${srcdir}/.."
+    lappend flags "additional_flags=-msse -I${srcdir}/.."
 }
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
+         $flags] != "" } {
     unsupported "compiler does not support SSE"
     return
 }
This page took 0.04488 seconds and 5 git commands to generate.