summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Benson <gbenson@redhat.com>2020-07-13 14:47:44 +0100
committerGary Benson <gbenson@redhat.com>2020-07-13 14:47:44 +0100
commit2a122642b4e4a7ec0f414b30d6ed7c48bc5c2eeb (patch)
tree33bbc8cf61298451c57238118d44bd92d9d9ba10
parent3f00c730acee9d452ba81a3083f2c02d13c9f312 (diff)
downloadbinutils-gdb-2a122642b4e4a7ec0f414b30d6ed7c48bc5c2eeb.tar.gz
Use volatile pointers when attempting to trigger SIGSEGVs
Clang fails to compile a number of files with the following warning: indirection of non-volatile null pointer will be deleted, not trap [-Wnull-dereference]. This commit qualifies the relevant pointers with 'volatile'. gdb/testsuite/ChangeLog: * gdb.base/bigcore.c (main): Use a volatile pointer when attempting to trigger a SIGSEGV. * gdb.base/gcore-relro-pie.c (break_here): Likewise. * gdb.base/gcore-tls-pie.c (break_here): Likewise. * gdb.base/savedregs.c (thrower): Likewise. * gdb.mi/mi-syn-frame.c (bar): Likewise.
-rw-r--r--gdb/testsuite/ChangeLog9
-rw-r--r--gdb/testsuite/gdb.base/bigcore.c2
-rw-r--r--gdb/testsuite/gdb.base/gcore-relro-pie.c2
-rw-r--r--gdb/testsuite/gdb.base/gcore-tls-pie.c2
-rw-r--r--gdb/testsuite/gdb.base/savedregs.c2
-rw-r--r--gdb/testsuite/gdb.mi/mi-syn-frame.c2
6 files changed, 14 insertions, 5 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 1798f92705b..fc9dcac563a 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,14 @@
2020-07-13 Gary Benson <gbenson@redhat.com>
+ * gdb.base/bigcore.c (main): Use a volatile pointer when
+ attempting to trigger a SIGSEGV.
+ * gdb.base/gcore-relro-pie.c (break_here): Likewise.
+ * gdb.base/gcore-tls-pie.c (break_here): Likewise.
+ * gdb.base/savedregs.c (thrower): Likewise.
+ * gdb.mi/mi-syn-frame.c (bar): Likewise.
+
+2020-07-13 Gary Benson <gbenson@redhat.com>
+
* gdb.base/vla-datatypes.c (vla_factory): Factor out sections
defining and using VLA structure fields into...
* gdb.base/vla-struct-fields.c: New file.
diff --git a/gdb/testsuite/gdb.base/bigcore.c b/gdb/testsuite/gdb.base/bigcore.c
index 174e0f67f00..8be1b154b39 100644
--- a/gdb/testsuite/gdb.base/bigcore.c
+++ b/gdb/testsuite/gdb.base/bigcore.c
@@ -267,5 +267,5 @@ main ()
/* Push everything out to disk. */
print_string ("Dump core ....\n");
- *(char*)0 = 0;
+ *(volatile char*)0 = 0;
}
diff --git a/gdb/testsuite/gdb.base/gcore-relro-pie.c b/gdb/testsuite/gdb.base/gcore-relro-pie.c
index 20cf12c5632..9ae7cb2cb9b 100644
--- a/gdb/testsuite/gdb.base/gcore-relro-pie.c
+++ b/gdb/testsuite/gdb.base/gcore-relro-pie.c
@@ -18,7 +18,7 @@
void
break_here (void)
{
- *(int *) 0 = 0;
+ *(volatile int *) 0 = 0;
}
void
diff --git a/gdb/testsuite/gdb.base/gcore-tls-pie.c b/gdb/testsuite/gdb.base/gcore-tls-pie.c
index 73aec409f1e..18169fcd627 100644
--- a/gdb/testsuite/gdb.base/gcore-tls-pie.c
+++ b/gdb/testsuite/gdb.base/gcore-tls-pie.c
@@ -25,7 +25,7 @@ __thread char i;
void
break_here (void)
{
- *(int *) 0 = 0;
+ *(volatile int *) 0 = 0;
}
void
diff --git a/gdb/testsuite/gdb.base/savedregs.c b/gdb/testsuite/gdb.base/savedregs.c
index d3bcbf7826d..05fba506156 100644
--- a/gdb/testsuite/gdb.base/savedregs.c
+++ b/gdb/testsuite/gdb.base/savedregs.c
@@ -46,7 +46,7 @@ static void
thrower (void)
{
/* Trigger a SIGSEGV. */
- *(char *)0 = 0;
+ *(volatile char *)0 = 0;
/* On MMU-less system, previous memory access to address zero doesn't
trigger a SIGSEGV. Trigger a SIGILL. Each arch should define its
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.c b/gdb/testsuite/gdb.mi/mi-syn-frame.c
index c260112b3fd..b6ab6e8d88a 100644
--- a/gdb/testsuite/gdb.mi/mi-syn-frame.c
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.c
@@ -27,7 +27,7 @@ foo (void)
void
bar (void)
{
- *(char *)0 = 0; /* try to cause a segfault */
+ *(volatile char *)0 = 0; /* try to cause a segfault */
/* On MMU-less system, previous memory access to address zero doesn't
trigger a SIGSEGV. Trigger a SIGILL. Each arch should define its