From 0d46a5454b04d233281f4771e2f63b9f238ce5a0 Mon Sep 17 00:00:00 2001 From: Ananya Sharma Date: Mon, 9 Mar 2026 08:55:27 +0000 Subject: [PATCH 1/2] Fix CL for failing targets in git_main-throttled-haiku This change adds the 'no_bti' default to xaac_dec_fuzzer as it statically links against libraries lacking BTI support. This is done to fix the linker errors raised in haiku_fuzz_shiba-trunk_staging-userdebug and haiku_fuzzcoverage_shiba-trunk_staging-userdebug targets. Bug: 491119982 Flag: EXEMPT BUGFIX Test: CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS='*' m haiku dist && m haiku dist Change-Id: If807527210dd4602c2897e3976cde925cf52e735 --- fuzzer/Android.bp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fuzzer/Android.bp b/fuzzer/Android.bp index 56ea46b2..4867ec76 100644 --- a/fuzzer/Android.bp +++ b/fuzzer/Android.bp @@ -9,6 +9,9 @@ package { cc_fuzz { name: "xaac_dec_fuzzer", + defaults: [ + "no_bti", + ], host_supported: true, srcs: [ "xaac_dec_fuzzer.cpp", From 38d70030034c8200ac08e8a7b79b5d31eb0b6521 Mon Sep 17 00:00:00 2001 From: Vivek R Jadhav Date: Thu, 23 Apr 2026 05:24:22 +0000 Subject: [PATCH 2/2] libxaac: Add BTI and PAC support Bug: 485868924 Test: readelf -nw libxaacenc.a Test: readelf -nW libxaacdec.a Test: ./xaacdec Test: ./xaac_enc_fuzzer Test: ./xaac_dec_fuzzer Change-Id: I603bfbef153b64562aec6cd9bcdeb188c069e7e3 --- CMakeLists.txt | 2 + decoder/armv8/ixheaacd_apply_scale_factors.s | 6 ++- decoder/armv8/ixheaacd_calcmaxspectralline.s | 4 +- decoder/armv8/ixheaacd_cos_sin_mod_loop1.s | 5 +- decoder/armv8/ixheaacd_cos_sin_mod_loop2.s | 5 +- decoder/armv8/ixheaacd_fft32x32_ld2_armv8.s | 5 +- decoder/armv8/ixheaacd_imdct_using_fft.s | 6 ++- decoder/armv8/ixheaacd_inv_dit_fft_8pt.s | 4 +- decoder/armv8/ixheaacd_neon_macros.s | 48 +++++++++++++++++++ decoder/armv8/ixheaacd_no_lap1.s | 5 +- decoder/armv8/ixheaacd_overlap_add1.s | 4 +- decoder/armv8/ixheaacd_overlap_add2.s | 5 +- decoder/armv8/ixheaacd_post_twiddle.s | 5 +- decoder/armv8/ixheaacd_post_twiddle_overlap.s | 5 +- decoder/armv8/ixheaacd_postradixcompute4.s | 5 +- decoder/armv8/ixheaacd_pre_twiddle.s | 5 +- decoder/armv8/ixheaacd_sbr_imdct_using_fft.s | 6 ++- .../armv8/ixheaacd_sbr_qmf_analysis32_neon.s | 5 +- decoder/armv8/ixheaacd_sbr_qmfsyn64_winadd.s | 5 +- .../armv8/ixheaacd_shiftrountine_with_round.s | 5 +- .../ixheaacd_shiftrountine_with_round_eld.s | 5 +- fuzzer/Android.bp | 3 -- 22 files changed, 115 insertions(+), 33 deletions(-) create mode 100644 decoder/armv8/ixheaacd_neon_macros.s diff --git a/CMakeLists.txt b/CMakeLists.txt index 82539b79..8d3ab98e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.5.1) project(libxaac C CXX) enable_language(ASM) +set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/decoder/armv8") + option(BUILD64 "Build for 64 bit" OFF) set(XAAC_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") set(XAAC_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/decoder/armv8/ixheaacd_apply_scale_factors.s b/decoder/armv8/ixheaacd_apply_scale_factors.s index 82c0c977..d32fe4d6 100644 --- a/decoder/armv8/ixheaacd_apply_scale_factors.s +++ b/decoder/armv8/ixheaacd_apply_scale_factors.s @@ -20,11 +20,11 @@ ldp X8, X9, [sp], #16 .endm +.include "ixheaacd_neon_macros.s" .text -.p2align 2 .global ixheaacd_scale_factor_process_armv8 -ixheaacd_scale_factor_process_armv8: +ENTRY ixheaacd_scale_factor_process_armv8 push_v_regs @@ -37,6 +37,7 @@ ixheaacd_scale_factor_process_armv8: BGT lbl17 pop_v_regs + EXIT_FUNC ret lbl17: MOV x10, #0 @@ -163,4 +164,5 @@ OFFSET_ZERO: BGT TBANDS_LOOP pop_v_regs + EXIT_FUNC ret diff --git a/decoder/armv8/ixheaacd_calcmaxspectralline.s b/decoder/armv8/ixheaacd_calcmaxspectralline.s index b9a13d55..abe4f065 100644 --- a/decoder/armv8/ixheaacd_calcmaxspectralline.s +++ b/decoder/armv8/ixheaacd_calcmaxspectralline.s @@ -19,9 +19,10 @@ //*/ +.include "ixheaacd_neon_macros.s" .text .global ixheaacd_calc_max_spectral_line_armv8 -ixheaacd_calc_max_spectral_line_armv8: +ENTRY ixheaacd_calc_max_spectral_line_armv8 LSR W4, W1, #3 LSL W6, W4, #3 @@ -75,6 +76,7 @@ END_FUNC: CLZ W0, W0 SUB W0, W0, #1 + EXIT_FUNC RET diff --git a/decoder/armv8/ixheaacd_cos_sin_mod_loop1.s b/decoder/armv8/ixheaacd_cos_sin_mod_loop1.s index 4a0d2351..7ef1e0be 100644 --- a/decoder/armv8/ixheaacd_cos_sin_mod_loop1.s +++ b/decoder/armv8/ixheaacd_cos_sin_mod_loop1.s @@ -28,11 +28,11 @@ ldp q8, q9, [sp], #32 .endm +.include "ixheaacd_neon_macros.s" .text -.p2align 2 .global ixheaacd_cos_sin_mod_loop1 -ixheaacd_cos_sin_mod_loop1: +ENTRY ixheaacd_cos_sin_mod_loop1 // STMFD sp!, {x4-x12, x14} push_v_regs @@ -202,6 +202,7 @@ LOOP1: // LDMFD sp!, {x4-x12, x15} //ldp x19, x20,[sp],#16 pop_v_regs + EXIT_FUNC ret diff --git a/decoder/armv8/ixheaacd_cos_sin_mod_loop2.s b/decoder/armv8/ixheaacd_cos_sin_mod_loop2.s index e51cd58c..ccc35b32 100644 --- a/decoder/armv8/ixheaacd_cos_sin_mod_loop2.s +++ b/decoder/armv8/ixheaacd_cos_sin_mod_loop2.s @@ -28,11 +28,11 @@ ldp q8, q9, [sp], #32 .endm +.include "ixheaacd_neon_macros.s" .text -.p2align 2 .global ixheaacd_cos_sin_mod_loop2 -ixheaacd_cos_sin_mod_loop2: +ENTRY ixheaacd_cos_sin_mod_loop2 // STMFD sp!, {x4-x12, x14} push_v_regs @@ -210,4 +210,5 @@ LOOP1: // LDMFD sp!, {x4-x12, x15} //ldp x19, x20,[sp],#16 pop_v_regs + EXIT_FUNC ret diff --git a/decoder/armv8/ixheaacd_fft32x32_ld2_armv8.s b/decoder/armv8/ixheaacd_fft32x32_ld2_armv8.s index 280164ba..0f9cacbd 100644 --- a/decoder/armv8/ixheaacd_fft32x32_ld2_armv8.s +++ b/decoder/armv8/ixheaacd_fft32x32_ld2_armv8.s @@ -23,11 +23,11 @@ .endm +.include "ixheaacd_neon_macros.s" .text -.p2align 2 .global ixheaacd_fft32x32_ld2_armv8 -ixheaacd_fft32x32_ld2_armv8: +ENTRY ixheaacd_fft32x32_ld2_armv8 // STMFD sp!, {x4-x12,x14} push_v_regs @@ -551,5 +551,6 @@ ixheaacd_fft32x32_ld2_armv8: // LDMFD sp!, {x4-x12,x15} ldp x19, x20, [sp], #16 pop_v_regs + EXIT_FUNC ret diff --git a/decoder/armv8/ixheaacd_imdct_using_fft.s b/decoder/armv8/ixheaacd_imdct_using_fft.s index 8f8916ae..4a7c5d48 100644 --- a/decoder/armv8/ixheaacd_imdct_using_fft.s +++ b/decoder/armv8/ixheaacd_imdct_using_fft.s @@ -49,10 +49,11 @@ MOv \reg1, \reg2 MOv \reg2, x16 .endm + +.include "ixheaacd_neon_macros.s" .text -.p2align 2 .global ixheaacd_imdct_using_fft_armv8 -ixheaacd_imdct_using_fft_armv8: +ENTRY ixheaacd_imdct_using_fft_armv8 push_v_regs MOV X29, #11600 @@ -813,6 +814,7 @@ BYPASS_IF: BNE OUTER_LOOP_R4 END_LOOPS: pop_v_regs + EXIT_FUNC RET diff --git a/decoder/armv8/ixheaacd_inv_dit_fft_8pt.s b/decoder/armv8/ixheaacd_inv_dit_fft_8pt.s index 197a8257..8425010d 100644 --- a/decoder/armv8/ixheaacd_inv_dit_fft_8pt.s +++ b/decoder/armv8/ixheaacd_inv_dit_fft_8pt.s @@ -16,9 +16,10 @@ .endm +.include "ixheaacd_neon_macros.s" .text .global ixheaacd_inv_dit_fft_8pt_armv8 -ixheaacd_inv_dit_fft_8pt_armv8: +ENTRY ixheaacd_inv_dit_fft_8pt_armv8 push_v_regs MOV w3, #0x5A820000 DUP v0.2s, w3 @@ -164,6 +165,7 @@ ixheaacd_inv_dit_fft_8pt_armv8: //ST2 {v12.s,v13.s}[0],[x1] //ST2 {v12.s,v13.s}[1],[x2] pop_v_regs + EXIT_FUNC ret diff --git a/decoder/armv8/ixheaacd_neon_macros.s b/decoder/armv8/ixheaacd_neon_macros.s new file mode 100644 index 00000000..e127af16 --- /dev/null +++ b/decoder/armv8/ixheaacd_neon_macros.s @@ -0,0 +1,48 @@ +// decoder/armv8/ixheaacd_armv8_macros.s + +// --- Internal Security Dispatchers --- +.macro BTI_ENABLE +#if defined(__ARM_FEATURE_BTI_DEFAULT) + bti c +#endif +.endm + +.macro PAC_ENTRY +#if defined(__ARM_FEATURE_PAC_DEFAULT) + paciasp +#endif +.endm + +.macro PAC_EXIT +#if defined(__ARM_FEATURE_PAC_DEFAULT) + autiasp +#endif +.endm + +// --- Main ENTRY and EXIT Macros --- +.macro ENTRY name + .p2align 2 +\name: + BTI_ENABLE + PAC_ENTRY +.endm + +.macro EXIT_FUNC + PAC_EXIT +.endm + +// --- GNU Property Note --- +// Signals BTI and PAC support to the Android linker. +#if defined(__linux__) && defined(__aarch64__) + .pushsection .note.gnu.property, "a" // Switch to Note section + .p2align 3 + .word 4 // Name size + .word 16 // Data size + .word 5 // NT_GNU_PROPERTY_TYPE_0 + .asciz "GNU" // Owner + .word 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND + .word 4 // Data size + .word 3 // Value: BTI (Bit 0) | PAC (Bit 1) + .word 0 // Padding + .popsection // Switch back to previous section +#endif diff --git a/decoder/armv8/ixheaacd_no_lap1.s b/decoder/armv8/ixheaacd_no_lap1.s index 1c71f42b..5e22f528 100644 --- a/decoder/armv8/ixheaacd_no_lap1.s +++ b/decoder/armv8/ixheaacd_no_lap1.s @@ -43,9 +43,11 @@ ldp q10, q11, [sp], #32 ldp q8, q9, [sp], #32 .endm + +.include "ixheaacd_neon_macros.s" .text .global ixheaacd_neg_shift_spec_armv8 -ixheaacd_neg_shift_spec_armv8: +ENTRY ixheaacd_neg_shift_spec_armv8 push_v_regs MOV X5, #448 SUB X6, X5, #1 @@ -109,4 +111,5 @@ LOOP_1: ST1 {V22.S}[0], [X1], X7 ST1 {V22.S}[1], [X1], X7 pop_v_regs + EXIT_FUNC RET diff --git a/decoder/armv8/ixheaacd_overlap_add1.s b/decoder/armv8/ixheaacd_overlap_add1.s index 844effc2..e9ced85f 100644 --- a/decoder/armv8/ixheaacd_overlap_add1.s +++ b/decoder/armv8/ixheaacd_overlap_add1.s @@ -43,9 +43,10 @@ ldp q8, q9, [sp], #32 .endm +.include "ixheaacd_neon_macros.s" .text .global ixheaacd_over_lap_add1_armv8 -ixheaacd_over_lap_add1_armv8: +ENTRY ixheaacd_over_lap_add1_armv8 push_v_regs LSL X6 , X6 , #1 LSL X10, X5, #1 @@ -294,6 +295,7 @@ LOOP_1: ST1 {V9.S}[2], [X6], X9 ST1 {V9.S}[3], [X6], X9 pop_v_regs + EXIT_FUNC RET diff --git a/decoder/armv8/ixheaacd_overlap_add2.s b/decoder/armv8/ixheaacd_overlap_add2.s index db365e7d..b7c09563 100644 --- a/decoder/armv8/ixheaacd_overlap_add2.s +++ b/decoder/armv8/ixheaacd_overlap_add2.s @@ -43,11 +43,13 @@ ldp q10, q11, [sp], #32 ldp q8, q9, [sp], #32 .endm + +.include "ixheaacd_neon_macros.s" .text .global ixheaacd_over_lap_add2_armv8 -ixheaacd_over_lap_add2_armv8: +ENTRY ixheaacd_over_lap_add2_armv8 push_v_regs MOV X8, X5 SUB X12, X5, #1 @@ -302,4 +304,5 @@ LOOP_2: ST1 {V16.S}[3], [X7], X8 pop_v_regs + EXIT_FUNC RET diff --git a/decoder/armv8/ixheaacd_post_twiddle.s b/decoder/armv8/ixheaacd_post_twiddle.s index c28b9da8..19e59f54 100644 --- a/decoder/armv8/ixheaacd_post_twiddle.s +++ b/decoder/armv8/ixheaacd_post_twiddle.s @@ -40,9 +40,11 @@ MOV \reg1, \reg2 MOV \reg2, x16 .endm + +.include "ixheaacd_neon_macros.s" .text .global ixheaacd_post_twiddle_armv8 -ixheaacd_post_twiddle_armv8: +ENTRY ixheaacd_post_twiddle_armv8 push_v_regs @@ -698,6 +700,7 @@ NEON_EPILOGUE: pop_v_regs + EXIT_FUNC ret diff --git a/decoder/armv8/ixheaacd_post_twiddle_overlap.s b/decoder/armv8/ixheaacd_post_twiddle_overlap.s index f05e6e4b..9dc845dd 100644 --- a/decoder/armv8/ixheaacd_post_twiddle_overlap.s +++ b/decoder/armv8/ixheaacd_post_twiddle_overlap.s @@ -41,11 +41,11 @@ .endm +.include "ixheaacd_neon_macros.s" .text -.p2align 2 .global ixheaacd_post_twid_overlap_add_armv8 -ixheaacd_post_twid_overlap_add_armv8: +ENTRY ixheaacd_post_twid_overlap_add_armv8 // STMFD sp!, {x4-x12} push_v_regs @@ -1873,6 +1873,7 @@ ARM_LOOP: ADD x5, x5, x10 pop_v_regs + EXIT_FUNC ret diff --git a/decoder/armv8/ixheaacd_postradixcompute4.s b/decoder/armv8/ixheaacd_postradixcompute4.s index ddd60f1b..b5c4129a 100644 --- a/decoder/armv8/ixheaacd_postradixcompute4.s +++ b/decoder/armv8/ixheaacd_postradixcompute4.s @@ -14,12 +14,12 @@ ldp X8, X9, [sp], #16 .endm +.include "ixheaacd_neon_macros.s" .text -.p2align 2 .global ixheaacd_postradixcompute4 -ixheaacd_postradixcompute4: +ENTRY ixheaacd_postradixcompute4 // STMFD sp!, {x4-x12, x14} push_v_regs @@ -143,6 +143,7 @@ POSTRADIX4_START: // LDMFD sp!, {x4-x12, x15} pop_v_regs + EXIT_FUNC ret diff --git a/decoder/armv8/ixheaacd_pre_twiddle.s b/decoder/armv8/ixheaacd_pre_twiddle.s index 7c02ba55..d1486289 100644 --- a/decoder/armv8/ixheaacd_pre_twiddle.s +++ b/decoder/armv8/ixheaacd_pre_twiddle.s @@ -49,10 +49,12 @@ MOV \reg1, \reg2 MOV \reg2, x16 .endm + +.include "ixheaacd_neon_macros.s" .text .global ixheaacd_pretwiddle_compute_armv8 -ixheaacd_pretwiddle_compute_armv8: +ENTRY ixheaacd_pretwiddle_compute_armv8 push_v_regs @@ -506,6 +508,7 @@ RESIDUE_NEON: END1: pop_v_regs + EXIT_FUNC ret diff --git a/decoder/armv8/ixheaacd_sbr_imdct_using_fft.s b/decoder/armv8/ixheaacd_sbr_imdct_using_fft.s index baa14de3..d23881bc 100644 --- a/decoder/armv8/ixheaacd_sbr_imdct_using_fft.s +++ b/decoder/armv8/ixheaacd_sbr_imdct_using_fft.s @@ -49,10 +49,11 @@ MOV \reg1, \reg2 MOV \reg2, x16 .endm + +.include "ixheaacd_neon_macros.s" .text -.p2align 2 .global ixheaacd_sbr_imdct_using_fft -ixheaacd_sbr_imdct_using_fft: +ENTRY ixheaacd_sbr_imdct_using_fft push_v_regs @@ -774,4 +775,5 @@ BYPASS_IF: BNE OUTER_LOOP_R4 END_LOOPS: pop_v_regs + EXIT_FUNC RET diff --git a/decoder/armv8/ixheaacd_sbr_qmf_analysis32_neon.s b/decoder/armv8/ixheaacd_sbr_qmf_analysis32_neon.s index 146f0287..2557c350 100644 --- a/decoder/armv8/ixheaacd_sbr_qmf_analysis32_neon.s +++ b/decoder/armv8/ixheaacd_sbr_qmf_analysis32_neon.s @@ -23,11 +23,11 @@ ldp d8, d9, [sp], #16 .endm +.include "ixheaacd_neon_macros.s" .text -.p2align 2 .global ixheaacd_sbr_qmfanal32_winadds -ixheaacd_sbr_qmfanal32_winadds: // PROC +ENTRY ixheaacd_sbr_qmfanal32_winadds // PROC // STMFD sp!, {x4-x12, x14} push_v_regs @@ -337,5 +337,6 @@ LOOP_1: // LDMFD sp!, {x4-x12, x15} ldp x19, x20, [sp], #16 pop_v_regs + EXIT_FUNC ret // ENDP diff --git a/decoder/armv8/ixheaacd_sbr_qmfsyn64_winadd.s b/decoder/armv8/ixheaacd_sbr_qmfsyn64_winadd.s index 6e2c7eb8..0b1beb57 100644 --- a/decoder/armv8/ixheaacd_sbr_qmfsyn64_winadd.s +++ b/decoder/armv8/ixheaacd_sbr_qmfsyn64_winadd.s @@ -41,10 +41,12 @@ MOV \reg1, \reg2 MOV \reg2, x16 .endm + +.include "ixheaacd_neon_macros.s" .text .global ixheaacd_sbr_qmfsyn64_winadd -ixheaacd_sbr_qmfsyn64_winadd: +ENTRY ixheaacd_sbr_qmfsyn64_winadd push_v_regs @@ -399,5 +401,6 @@ LOOP_1: pop_v_regs + EXIT_FUNC ret diff --git a/decoder/armv8/ixheaacd_shiftrountine_with_round.s b/decoder/armv8/ixheaacd_shiftrountine_with_round.s index e6a160da..135b0c94 100644 --- a/decoder/armv8/ixheaacd_shiftrountine_with_round.s +++ b/decoder/armv8/ixheaacd_shiftrountine_with_round.s @@ -21,10 +21,10 @@ ldp X8, X9, [sp], #16 .endm +.include "ixheaacd_neon_macros.s" .text -.p2align 2 .global ixheaacd_shiftrountine_with_rnd -ixheaacd_shiftrountine_with_rnd: +ENTRY ixheaacd_shiftrountine_with_rnd push_v_regs ADD x12, x2, x3, LSL #1 @@ -70,4 +70,5 @@ S_WITH_R_L5: BGE S_WITH_R_L5 S_WITH_R_L6: pop_v_regs + EXIT_FUNC ret diff --git a/decoder/armv8/ixheaacd_shiftrountine_with_round_eld.s b/decoder/armv8/ixheaacd_shiftrountine_with_round_eld.s index ef5313be..2c353816 100644 --- a/decoder/armv8/ixheaacd_shiftrountine_with_round_eld.s +++ b/decoder/armv8/ixheaacd_shiftrountine_with_round_eld.s @@ -21,10 +21,10 @@ ldp X8, X9, [sp], #16 .endm +.include "ixheaacd_neon_macros.s" .text -.p2align 2 .global ixheaacd_shiftrountine_with_rnd_eld -ixheaacd_shiftrountine_with_rnd_eld: +ENTRY ixheaacd_shiftrountine_with_rnd_eld push_v_regs ADD x12, x2, x3, LSL #1 @@ -76,4 +76,5 @@ S_WITH_R_L5: BGE S_WITH_R_L5 S_WITH_R_L6: pop_v_regs + EXIT_FUNC ret diff --git a/fuzzer/Android.bp b/fuzzer/Android.bp index 4867ec76..56ea46b2 100644 --- a/fuzzer/Android.bp +++ b/fuzzer/Android.bp @@ -9,9 +9,6 @@ package { cc_fuzz { name: "xaac_dec_fuzzer", - defaults: [ - "no_bti", - ], host_supported: true, srcs: [ "xaac_dec_fuzzer.cpp",