tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

pixman-arm-asm.h (3740B)


      1 /*
      2 * Copyright © 2008 Mozilla Corporation
      3 * Copyright © 2010 Nokia Corporation
      4 *
      5 * Permission to use, copy, modify, distribute, and sell this software and its
      6 * documentation for any purpose is hereby granted without fee, provided that
      7 * the above copyright notice appear in all copies and that both that
      8 * copyright notice and this permission notice appear in supporting
      9 * documentation, and that the name of Mozilla Corporation not be used in
     10 * advertising or publicity pertaining to distribution of the software without
     11 * specific, written prior permission.  Mozilla Corporation makes no
     12 * representations about the suitability of this software for any purpose.  It
     13 * is provided "as is" without express or implied warranty.
     14 *
     15 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
     16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
     17 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
     18 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
     20 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
     21 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
     22 * SOFTWARE.
     23 *
     24 * Author:  Jeff Muizelaar (jeff@infidigm.net)
     25 *
     26 */
     27 
     28 #ifndef PIXMAN_ARM_ASM_H
     29 #define PIXMAN_ARM_ASM_H
     30 
     31 #ifdef HAVE_CONFIG_H
     32 #include "pixman-config.h"
     33 #endif
     34 
     35 /*
     36 * References:
     37 *  - https://developer.arm.com/documentation/101028/0012/5--Feature-test-macros
     38 *  - https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst
     39 */
     40 #if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
     41  #define BTI_C hint 34  /* bti c: for calls, IE bl instructions */
     42  #define GNU_PROPERTY_AARCH64_BTI 1 /* bit 0 GNU Notes is for BTI support */
     43 #else
     44  #define BTI_C
     45  #define GNU_PROPERTY_AARCH64_BTI 0
     46 #endif
     47 
     48 #if defined(__ARM_FEATURE_PAC_DEFAULT)
     49  #if __ARM_FEATURE_PAC_DEFAULT & 1
     50    #define SIGN_LR hint 25 /* paciasp: sign with the A key */
     51    #define VERIFY_LR hint 29 /* autiasp: verify with the b key */
     52  #elif __ARM_FEATURE_PAC_DEFAULT & 2
     53    #define SIGN_LR hint 27 /* pacibsp: sign with the b key */
     54    #define VERIFY_LR hint 31 /* autibsp: verify with the b key */
     55  #endif
     56  #define GNU_PROPERTY_AARCH64_POINTER_AUTH 2 /* bit 1 GNU Notes is for PAC support */
     57 #else
     58  #define SIGN_LR BTI_C
     59  #define VERIFY_LR
     60  #define GNU_PROPERTY_AARCH64_POINTER_AUTH 0
     61 #endif
     62 
     63 /* Add the BTI support to GNU Notes section for ASM files */
     64 #if GNU_PROPERTY_AARCH64_BTI != 0 || GNU_PROPERTY_AARCH64_POINTER_AUTH != 0
     65    .pushsection .note.gnu.property, "a"; /* Start a new allocatable section */
     66    .balign 8; /* align it on a byte boundry */
     67    .long 4; /* size of "GNU\0" */
     68    .long 0x10; /* size of descriptor */
     69    .long 0x5; /* NT_GNU_PROPERTY_TYPE_0 */
     70    .asciz "GNU";
     71    .long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
     72    .long 4; /* Four bytes of data */
     73    .long (GNU_PROPERTY_AARCH64_BTI|GNU_PROPERTY_AARCH64_POINTER_AUTH); /* BTI or PAC is enabled */
     74    .long 0; /* padding for 8 byte alignment */
     75    .popsection; /* end the section */
     76 #endif
     77 
     78 /* Supplementary macro for setting function attributes */
     79 .macro pixman_asm_function_impl fname
     80 #ifdef ASM_HAVE_FUNC_DIRECTIVE
     81 .func \fname
     82 #endif
     83 .global \fname
     84 #ifdef __ELF__
     85 .hidden \fname
     86 .type \fname, %function
     87 #endif
     88 \fname:
     89 SIGN_LR
     90 .endm
     91 
     92 .macro pixman_asm_function fname
     93 #ifdef ASM_LEADING_UNDERSCORE
     94 pixman_asm_function_impl _\fname
     95 #else
     96 pixman_asm_function_impl \fname
     97 #endif
     98 .endm
     99 
    100 .macro pixman_syntax_unified
    101 #ifdef ASM_HAVE_SYNTAX_UNIFIED
    102 .syntax unified
    103 #endif
    104 .endm
    105 
    106 .macro pixman_end_asm_function
    107 #ifdef ASM_HAVE_FUNC_DIRECTIVE
    108 .endfunc
    109 #endif
    110 .endm
    111 
    112 #endif /* PIXMAN_ARM_ASM_H */