Add Branch Target Identifiers (BTIs) to all functions defined in AArch64 assembly files. Most of the BTI landing pads are added automatically by the 'function' macro. BTI support is turned on or off at compile time based on the presence of the __ARM_FEATURE_BTI_DEFAULT feature macro. A binary compiled with BTI support can be executed on an Armv8-A processor without BTI support because the instructions are defined in NOP space.
Unified · Split
| @@ -36,6 +36,7 @@ · 35 unmodified lines | |||
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | function fft4_neon | 38 | function fft4_neon |
| 39 | AARCH64_VALID_JUMP_TARGET | ||
| 39 | ld1 {v0.2s,v1.2s,v2.2s,v3.2s}, [x0] | 40 | ld1 {v0.2s,v1.2s,v2.2s,v3.2s}, [x0] |
| 40 | 41 | ||
| 41 | fadd v4.2s, v0.2s, v1.2s // r0+r1,i0+i1 | 42 | fadd v4.2s, v0.2s, v1.2s // r0+r1,i0+i1 |
| @@ -58,6 +59,7 @@ function fft4_neon · 16 unmodified lines | |||
| 58 | endfunc | 59 | endfunc |
| 59 | 60 | ||
| 60 | function fft8_neon | 61 | function fft8_neon |
| 62 | AARCH64_VALID_JUMP_TARGET | ||
| 61 | mov x1, x0 | 63 | mov x1, x0 |
| 62 | ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32 | 64 | ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32 |
| 63 | ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0] | 65 | ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0] |
| @@ -108,6 +110,7 @@ function fft8_neon · 44 unmodified lines | |||
| 108 | endfunc | 110 | endfunc |
| 109 | 111 | ||
| 110 | function fft16_neon | 112 | function fft16_neon |
| 113 | AARCH64_VALID_JUMP_TARGET | ||
| 111 | mov x1, x0 | 114 | mov x1, x0 |
| 112 | ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32 | 115 | ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32 |
| 113 | ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0], #32 | 116 | ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0], #32 |
| @@ -337,6 +340,7 @@ endfunc · 223 unmodified lines | |||
| 337 | 340 | ||
| 338 | .macro def_fft n, n2, n4 | 341 | .macro def_fft n, n2, n4 |
| 339 | function fft\n\()_neon, align=6 | 342 | function fft\n\()_neon, align=6 |
| 343 | AARCH64_VALID_JUMP_TARGET | ||
| 340 | sub sp, sp, #16 | 344 | sub sp, sp, #16 |
| 341 | stp x28, x30, [sp] | 345 | stp x28, x30, [sp] |
| 342 | add x28, x0, #\n4*2*8 | 346 | add x28, x0, #\n4*2*8 |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | |||
| 24 | 24 | ||
| 25 | function ff_h264_idct_add_neon, export=1 | 25 | function ff_h264_idct_add_neon, export=1 |
| 26 | .L_ff_h264_idct_add_neon: | 26 | .L_ff_h264_idct_add_neon: |
| 27 | AARCH64_VALID_CALL_TARGET | ||
| 27 | ld1 {v0.4H, v1.4H, v2.4H, v3.4H}, [x1] | 28 | ld1 {v0.4H, v1.4H, v2.4H, v3.4H}, [x1] |
| 28 | sxtw x2, w2 | 29 | sxtw x2, w2 |
| 29 | movi v30.8H, #0 | 30 | movi v30.8H, #0 |
| @@ -79,6 +80,7 @@ endfunc · 49 unmodified lines | |||
| 79 | 80 | ||
| 80 | function ff_h264_idct_dc_add_neon, export=1 | 81 | function ff_h264_idct_dc_add_neon, export=1 |
| 81 | .L_ff_h264_idct_dc_add_neon: | 82 | .L_ff_h264_idct_dc_add_neon: |
| 83 | AARCH64_VALID_CALL_TARGET | ||
| 82 | sxtw x2, w2 | 84 | sxtw x2, w2 |
| 83 | mov w3, #0 | 85 | mov w3, #0 |
| 84 | ld1r {v2.8H}, [x1] | 86 | ld1r {v2.8H}, [x1] |
| @@ -266,6 +268,7 @@ endfunc · 181 unmodified lines | |||
| 266 | 268 | ||
| 267 | function ff_h264_idct8_add_neon, export=1 | 269 | function ff_h264_idct8_add_neon, export=1 |
| 268 | .L_ff_h264_idct8_add_neon: | 270 | .L_ff_h264_idct8_add_neon: |
| 271 | AARCH64_VALID_CALL_TARGET | ||
| 269 | movi v19.8H, #0 | 272 | movi v19.8H, #0 |
| 270 | sxtw x2, w2 | 273 | sxtw x2, w2 |
| 271 | ld1 {v24.8H, v25.8H}, [x1] | 274 | ld1 {v24.8H, v25.8H}, [x1] |
| @@ -330,6 +333,7 @@ endfunc · 58 unmodified lines | |||
| 330 | 333 | ||
| 331 | function ff_h264_idct8_dc_add_neon, export=1 | 334 | function ff_h264_idct8_dc_add_neon, export=1 |
| 332 | .L_ff_h264_idct8_dc_add_neon: | 335 | .L_ff_h264_idct8_dc_add_neon: |
| 336 | AARCH64_VALID_CALL_TARGET | ||
| 333 | mov w3, #0 | 337 | mov w3, #0 |
| 334 | sxtw x2, w2 | 338 | sxtw x2, w2 |
| 335 | ld1r {v31.8H}, [x1] | 339 | ld1r {v31.8H}, [x1] |
| @@ -36,6 +36,35 @@ · 35 unmodified lines | |||
| 36 | # define __has_feature(x) 0 | 36 | # define __has_feature(x) 0 |
| 37 | #endif | 37 | #endif |
| 38 | 38 | ||
| 39 | /* Support macros for the Armv8.5-A Branch Target Identification feature which | ||
| 40 | * requires emitting a .note.gnu.property section with the appropriate | ||
| 41 | * architecture-dependent feature bits set. | ||
| 42 | * Read more: "ELF for the Arm® 64-bit Architecture" | ||
| 43 | */ | ||
| 44 | #if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1) | ||
| 45 | # define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has BTI | ||
| 46 | # define AARCH64_VALID_CALL_TARGET hint #34 // BTI 'c' | ||
| 47 | # define AARCH64_VALID_JUMP_TARGET hint #38 // BTI 'j' | ||
| 48 | #else | ||
| 49 | # define GNU_PROPERTY_AARCH64_BTI 0 // No BTI | ||
| 50 | # define AARCH64_VALID_CALL_TARGET | ||
| 51 | # define AARCH64_VALID_JUMP_TARGET | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #if (GNU_PROPERTY_AARCH64_BTI != 0) | ||
| 55 | .pushsection .note.gnu.property, "a" | ||
| 56 | .balign 8 | ||
| 57 | .long 4 | ||
| 58 | .long 0x10 | ||
| 59 | .long 0x5 | ||
| 60 | .asciz "GNU" | ||
| 61 | .long 0xc0000000 /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */ | ||
| 62 | .long 4 | ||
| 63 | .long GNU_PROPERTY_AARCH64_BTI | ||
| 64 | .long 0 | ||
| 65 | .popsection | ||
| 66 | #endif | ||
| 67 | |||
| 39 | .macro function name, export=0, align=2 | 68 | .macro function name, export=0, align=2 |
| 40 | .macro endfunc | 69 | .macro endfunc |
| 41 | ELF .size \name, . - \name | 70 | ELF .size \name, . - \name |
| @@ -49,6 +78,7 @@ FUNC .endfunc · 7 unmodified lines | |||
| 49 | ELF .type EXTERN_ASM\name, %function | 78 | ELF .type EXTERN_ASM\name, %function |
| 50 | FUNC .func EXTERN_ASM\name | 79 | FUNC .func EXTERN_ASM\name |
| 51 | EXTERN_ASM\name: | 80 | EXTERN_ASM\name: |
| 81 | AARCH64_VALID_CALL_TARGET | ||
| 52 | .else | 82 | .else |
| 53 | ELF .type \name, %function | 83 | ELF .type \name, %function |
| 54 | FUNC .func \name | 84 | FUNC .func \name |