1 /* Functions for x86 GNU property.
2 Copyright (C) 2017-2024 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
22 #include "coretypes.h"
25 #include "linux-common.h"
26 #include "i386-protos.h"
29 emit_gnu_property (unsigned int type
, unsigned int data
)
31 int p2align
= ptr_mode
== SImode
? 2 : 3;
33 switch_to_section (get_section (".note.gnu.property",
34 SECTION_NOTYPE
, NULL
));
36 ASM_OUTPUT_ALIGN (asm_out_file
, p2align
);
38 fprintf (asm_out_file
, ASM_LONG
"1f - 0f\n");
40 fprintf (asm_out_file
, ASM_LONG
"4f - 1f\n");
41 /* note type: NT_GNU_PROPERTY_TYPE_0. */
42 fprintf (asm_out_file
, ASM_LONG
"5\n");
43 fprintf (asm_out_file
, "0:\n");
44 /* vendor name: "GNU". */
45 fprintf (asm_out_file
, STRING_ASM_OP
"\"GNU\"\n");
46 fprintf (asm_out_file
, "1:\n");
47 ASM_OUTPUT_ALIGN (asm_out_file
, p2align
);
49 fprintf (asm_out_file
, ASM_LONG
"0x%x\n", type
);
51 fprintf (asm_out_file
, ASM_LONG
"3f - 2f\n");
52 fprintf (asm_out_file
, "2:\n");
53 fprintf (asm_out_file
, ASM_LONG
"0x%x\n", data
);
54 fprintf (asm_out_file
, "3:\n");
55 ASM_OUTPUT_ALIGN (asm_out_file
, p2align
);
56 fprintf (asm_out_file
, "4:\n");
60 file_end_indicate_exec_stack_and_gnu_property (void)
62 file_end_indicate_exec_stack ();
64 if (flag_cf_protection
== CF_NONE
66 && !ix86_has_no_direct_extern_access
)
69 unsigned int feature_1
= 0;
71 if (flag_cf_protection
& CF_BRANCH
)
72 /* GNU_PROPERTY_X86_FEATURE_1_IBT. */
75 if (flag_cf_protection
& CF_RETURN
)
76 /* GNU_PROPERTY_X86_FEATURE_1_SHSTK. */
79 /* Generate GNU_PROPERTY_X86_FEATURE_1_AND. */
81 emit_gnu_property (0xc0000002, feature_1
);
83 unsigned int isa_1
= 0;
86 /* GNU_PROPERTY_X86_ISA_1_BASELINE. */
95 /* GNU_PROPERTY_X86_ISA_1_V2. */
97 || (TARGET_64BIT
&& TARGET_SAHF
)
105 /* GNU_PROPERTY_X86_ISA_1_V3. */
115 /* GNU_PROPERTY_X86_ISA_1_V4. */
124 /* Generate GNU_PROPERTY_X86_ISA_1_NEEDED. */
126 emit_gnu_property (0xc0008002, isa_1
);
128 if (ix86_has_no_direct_extern_access
)
129 /* Emite a GNU_PROPERTY_1_NEEDED note with
130 GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS. */
131 emit_gnu_property (0xb0008000, (1U << 0));