67 lines · c
1/*===------ cet.h -Control-flow Enforcement Technology feature ------------===2 * Add x86 feature with IBT and/or SHSTK bits to ELF program property if they3 * are enabled. Otherwise, contents in this header file are unused. This file4 * is mainly design for assembly source code which want to enable CET.5 *6 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.7 * See https://llvm.org/LICENSE.txt for license information.8 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception9 *10 *===-----------------------------------------------------------------------===11 */12#ifndef __CET_H13#define __CET_H14 15#ifdef __ASSEMBLER__16 17#ifndef __CET__18# define _CET_ENDBR19#endif20 21#ifdef __CET__22 23# ifdef __LP64__24# if __CET__ & 0x125# define _CET_ENDBR endbr6426# else27# define _CET_ENDBR28# endif29# else30# if __CET__ & 0x131# define _CET_ENDBR endbr3232# else33# define _CET_ENDBR34# endif35# endif36 37 38# ifdef __LP64__39# define __PROPERTY_ALIGN 340# else41# define __PROPERTY_ALIGN 242# endif43 44 .pushsection ".note.gnu.property", "a"45 .p2align __PROPERTY_ALIGN46 .long 1f - 0f /* name length. */47 .long 4f - 1f /* data length. */48 /* NT_GNU_PROPERTY_TYPE_0. */49 .long 5 /* note type. */500:51 .asciz "GNU" /* vendor name. */521:53 .p2align __PROPERTY_ALIGN54 /* GNU_PROPERTY_X86_FEATURE_1_AND. */55 .long 0xc0000002 /* pr_type. */56 .long 3f - 2f /* pr_datasz. */572:58 /* GNU_PROPERTY_X86_FEATURE_1_XXX. */59 .long __CET__603:61 .p2align __PROPERTY_ALIGN624:63 .popsection64#endif65#endif66#endif67