[AArch64] PR target/84748: Mark *compare_cstore<mode>_insn as clobbering CC reg
[official-gcc.git] / libgcc / vtv_start.c
blob4cba1e6fa1d1fc2f46173ce1ab1f53c2a5b318cb
1 /* Copyright (C) 2012-2018 Free Software Foundation, Inc.
3 This file is part of GCC.
5 GCC is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 3, or (at your option) any later
8 version.
10 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 for more details.
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
24 /* This file is part of the vtable verification feature (for a
25 detailed description of the feature, see comments in
26 vtable-verify.c). The vtable verification feature creates
27 certain global symbols that need to be read-write sometimes during
28 program execution, and read-only at others. It uses 'mprotect' to
29 change the memory protections of the pages on which these variables
30 are stored. In order to not affect the protections of other
31 program variables, these variables are put into a special named
32 section, ".vtable_map_vars", which is page-aligned at the start,
33 and which is padded with a page-sized amount of zeros at the end.
34 To make this section page aligned, we create a special symbol,
35 "_vtable_map_vars_start" which we make the very first thing that
36 goes into the section. This file defines that symbol (and only
37 that symbol). GCC compiles this file into vtv_start.o, and
38 inserts vtv_start.o into the link line immediately after
39 crtbegin.o, if the program is compiled with -fvtable.verify.
41 In order to pad the ".vtable_map_vars" section with a page-sized
42 amount of zeros at the end, there is a second symbol,
43 _vtable_map_vars_end, which is defined in another file, vtv_end.c.
44 This second symbol is a page-sized array of chars, zero-filled, and
45 is the very last thing to go into the section. When the GCC driver
46 inserts vtv_start.o into the link line (just after crtbegin.o) it
47 also inserts vtv_end.o into the link line, just before crtend.o.
48 This has the desired effect of making our section page-aligned and
49 page-size paded, ensuring that no other program data lands on our
50 pages. */
52 #include "vtv-change-permission.h"
54 __attribute__ ((constructor(98))) void
55 __VLTunprotect (void)
57 __VLTChangePermission (__VLTP_READ_WRITE);
60 /* Page-aligned symbol to mark beginning of .vtable_map_vars section. */
61 char _vtable_map_vars_start []
62 __attribute__ ((__visibility__ ("protected"), used, aligned(VTV_PAGE_SIZE),
63 section(".vtable_map_vars")))
64 = { };