1 // copy_test_relro.cc -- test copy relocs against read-only and relro symbols.
3 // Copyright (C) 2016-2020 Free Software Foundation, Inc.
4 // Written by Cary Coutant <ccoutant@gmail.com>.
6 // This file is part of gold.
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
30 extern const int* const q
;
34 extern const int* const cp
__attribute__ ((section (".rodata"))) = &c
;
35 extern const int* const* const qp
__attribute__ ((section (".rodata"))) = &q
;
37 volatile int segfaults
= 0;
56 act
.sa_handler
= segv
;
57 sigemptyset(&act
.sa_mask
);
59 sigaction(SIGSEGV
, &act
, 0);
61 assert(segfaults
== 0);
62 if (sigsetjmp(jmp
, 1) == 0)
63 *const_cast<const int **>(&p
) = &c
;
64 assert(segfaults
== 1);
65 if (sigsetjmp(jmp
, 1) == 0)
66 *const_cast<int *>(b
) = 99;
67 assert(segfaults
== 2);
68 if (sigsetjmp(jmp
, 1) == 0)
69 *const_cast<int *>(cp
) = c
- 1;
70 assert(segfaults
== 3);
71 if (sigsetjmp(jmp
, 1) == 0)
72 *const_cast<int **>(qp
) = &a
;
73 assert(segfaults
== 4);
This page took 0.034834 seconds and 4 git commands to generate.