1 /* 2 * Copyright (c) 2008-2013 Travis Geiselbrecht 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files 6 * (the "Software"), to deal in the Software without restriction, 7 * including without limitation the rights to use, copy, modify, merge, 8 * publish, distribute, sublicense, and/or sell copies of the Software, 9 * and to permit persons to whom the Software is furnished to do so, 10 * subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23 #pragma once 24 25 #define GNU_NOTE_FEATURE_AARCH64_BTI 0x1 26 27 #ifdef BTI_ENABLED 28 29 /* Assembly function definitions with bti call landing pads */ 30 #define WEAK_FUNCTION(x) .weak x; LOCAL_FUNCTION(x) bti c; 31 #define FUNCTION(x) .global x; LOCAL_FUNCTION(x) bti c; 32 33 /* Macro to add a note section to an object file to indicate BTI can be used. 34 * Note: If not all objects contain the BTI feature, the final ELF will not 35 * be marked as supporting BTI during link. 36 */ 37 #define SECTION_GNU_NOTE_PROPERTY_AARCH64_FEATURES(features) \ 38 .pushsection ".note.gnu.property","",@note; \ 39 .balign 8; \ 40 .word 4; /* n_namsz */ \ 41 .word 16; /* n_descsz */ \ 42 .word 5; /* n_type = NT_GNU_PROPERTY_TYPE_0 */ \ 43 .asciz "GNU"; /* n_name */ \ 44 .word 0xc0000000; /* pr_type = GNU_PROPERTY_AARCH64_FEATURE_1_AND */ \ 45 .word 4; /* pr_datasz */ \ 46 .word features; /* pr_data = features */ \ 47 .word 0; /* pr_padding */ \ 48 .popsection 49 50 #else 51 52 #define SECTION_GNU_NOTE_PROPERTY_AARCH64_FEATURES(features) 53 54 #endif /* BTI_ENABLED */ 55 56