1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 1996-2019 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 code_entry_point
, code_descriptor
, data_read
, data_write
27 static volatile enum tests test
;
29 /* Some basic types and zero buffers. */
32 typedef long code_t (void);
33 data_t
*volatile data
;
34 code_t
*volatile code
;
35 /* "desc" is intentionally initialized to a data object. This is
36 needed to test function descriptors on arches like ia64. */
38 code_t
*volatile desc
= (code_t
*) (void *) zero
;
54 /* Try to read address zero. */
57 /* Try to write (the assignment) to address zero. */
59 case code_entry_point
:
60 /* For typical architectures, call a function at address
64 /* For atypical architectures that use function descriptors,
65 call a function descriptor, the code field of which is zero
66 (which has the effect of jumping to address zero). */
74 static volatile int i
;
77 memset (&act
, 0, sizeof act
);
78 act
.sa_handler
= keeper
;
79 sigaction (SIGSEGV
, &act
, NULL
);
80 sigaction (SIGBUS
, &act
, NULL
);
82 for (i
= 0; i
< 10; i
++)