diff --git a/src/ext/x86/x86inc.asm b/src/ext/x86/x86inc.asm index fc490b6f4..e6e6d51c2 100644 --- a/src/ext/x86/x86inc.asm +++ b/src/ext/x86/x86inc.asm @@ -868,6 +868,25 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae, extern %1 %endmacro +; Like `cextern`, but assumes the symbol is hidden data (i.e. `extern:data hidden`). +; Portable across all supported platforms. +; +; This can be life saving in position-independent contexts, where it is very easy to generate +; illegal relocations otherwise. +; +; See for more information. +%macro cextern_hidden_data 1 + %xdefine %1 mangle(private_prefix %+ _ %+ %1) + CAT_XDEFINE cglobaled_, %1, 2 + %if FORMAT_ELF + extern %1:data hidden + %elif FORMAT_MACHO && HAVE_PRIVATE_EXTERN + extern %1:private_extern + %else + extern %1 + %endif +%endmacro + ; Like cextern, but without the prefix. This should be used for symbols from external libraries. %macro cextern_naked 1 %ifdef PREFIX diff --git a/src/x86/filmgrain_common.asm b/src/x86/filmgrain_common.asm index 74f7044e6..f15bf3dc7 100644 --- a/src/x86/filmgrain_common.asm +++ b/src/x86/filmgrain_common.asm @@ -43,4 +43,4 @@ struc FGData .clip_to_restricted_range: resd 1 endstruc -cextern gaussian_sequence +cextern_hidden_data gaussian_sequence diff --git a/src/x86/ipred16_avx2.asm b/src/x86/ipred16_avx2.asm index 7b52abaa1..a11b7f777 100644 --- a/src/x86/ipred16_avx2.asm +++ b/src/x86/ipred16_avx2.asm @@ -129,8 +129,8 @@ JMP_TABLE ipred_cfl_left_16bpc, avx2, h4, h8, h16, h32 JMP_TABLE ipred_cfl_ac_444_16bpc, avx2, w4, w8, w16, w32 JMP_TABLE pal_pred_16bpc, avx2, w4, w8, w16, w32, w64 -cextern dr_intra_derivative -cextern filter_intra_taps +cextern_hidden_data dr_intra_derivative +cextern_hidden_data filter_intra_taps SECTION .text diff --git a/src/x86/ipred16_avx512.asm b/src/x86/ipred16_avx512.asm index 69802614c..18fc0dbe2 100644 --- a/src/x86/ipred16_avx512.asm +++ b/src/x86/ipred16_avx512.asm @@ -121,10 +121,10 @@ JMP_TABLE ipred_z2_16bpc, avx512icl, w4, w8, w16, w32, w64 JMP_TABLE ipred_z3_16bpc, avx512icl, w4, w8, w16, w32, w64 JMP_TABLE pal_pred_16bpc, avx512icl, w4, w8, w16, w32, w64 -cextern smooth_weights_1d_16bpc -cextern smooth_weights_2d_16bpc -cextern dr_intra_derivative -cextern filter_intra_taps +cextern_hidden_data smooth_weights_1d_16bpc +cextern_hidden_data smooth_weights_2d_16bpc +cextern_hidden_data dr_intra_derivative +cextern_hidden_data filter_intra_taps SECTION .text diff --git a/src/x86/ipred16_sse.asm b/src/x86/ipred16_sse.asm index 5a311b144..3416574c0 100644 --- a/src/x86/ipred16_sse.asm +++ b/src/x86/ipred16_sse.asm @@ -99,10 +99,10 @@ JMP_TABLE ipred_cfl_left_16bpc, ssse3, h4, h8, h16, h32 JMP_TABLE ipred_cfl_ac_444_16bpc, ssse3, w4, w8, w16, w32 JMP_TABLE pal_pred_16bpc, ssse3, w4, w8, w16, w32, w64 -cextern smooth_weights_1d_16bpc -cextern smooth_weights_2d_16bpc -cextern dr_intra_derivative -cextern filter_intra_taps +cextern_hidden_data smooth_weights_1d_16bpc +cextern_hidden_data smooth_weights_2d_16bpc +cextern_hidden_data dr_intra_derivative +cextern_hidden_data filter_intra_taps SECTION .text diff --git a/src/x86/ipred_avx2.asm b/src/x86/ipred_avx2.asm index 2956ffaf2..4a5483725 100644 --- a/src/x86/ipred_avx2.asm +++ b/src/x86/ipred_avx2.asm @@ -173,8 +173,8 @@ JMP_TABLE ipred_cfl_ac_422, avx2, w16_pad1, w16_pad2, w16_pad3 JMP_TABLE ipred_cfl_ac_444, avx2, w32_pad1, w32_pad2, w32_pad3, w4, w8, w16, w32 JMP_TABLE pal_pred, avx2, w4, w8, w16, w32, w64 -cextern dr_intra_derivative -cextern filter_intra_taps +cextern_hidden_data dr_intra_derivative +cextern_hidden_data filter_intra_taps SECTION .text diff --git a/src/x86/ipred_avx512.asm b/src/x86/ipred_avx512.asm index de953deba..cdd36c23d 100644 --- a/src/x86/ipred_avx512.asm +++ b/src/x86/ipred_avx512.asm @@ -213,8 +213,8 @@ JMP_TABLE ipred_dc_8bpc, avx512icl, h4, h8, h16, h32, h64, w4, w8, w16, s4-10*4, s8-10*4, s16-10*4, s32-10*4, s64-10*4 JMP_TABLE ipred_dc_left_8bpc, avx512icl, h4, h8, h16, h32, h64 -cextern dr_intra_derivative -cextern pb_0to63 +cextern_hidden_data dr_intra_derivative +cextern_hidden_data pb_0to63 SECTION .text diff --git a/src/x86/ipred_sse.asm b/src/x86/ipred_sse.asm index f6b0cad00..8a1bf08c8 100644 --- a/src/x86/ipred_sse.asm +++ b/src/x86/ipred_sse.asm @@ -141,8 +141,8 @@ JMP_TABLE ipred_cfl, ssse3, h4, h8, h16, h32, w4, w8, w16, w32, \ JMP_TABLE ipred_cfl_left, ssse3, h4, h8, h16, h32 JMP_TABLE ipred_filter, ssse3, w4, w8, w16, w32 -cextern dr_intra_derivative -cextern filter_intra_taps +cextern_hidden_data dr_intra_derivative +cextern_hidden_data filter_intra_taps SECTION .text diff --git a/src/x86/looprestoration16_avx2.asm b/src/x86/looprestoration16_avx2.asm index 4cf8b905c..7f1a45663 100644 --- a/src/x86/looprestoration16_avx2.asm +++ b/src/x86/looprestoration16_avx2.asm @@ -62,8 +62,8 @@ pd_0xf00801c7: dd 0xf00801c7 %define pw_256 sgr_lshuf5 -cextern pb_0to63 -cextern sgr_x_by_x_avx2 +cextern_hidden_data pb_0to63 +cextern_hidden_data sgr_x_by_x_avx2 SECTION .text diff --git a/src/x86/looprestoration16_avx512.asm b/src/x86/looprestoration16_avx512.asm index e560c54a4..2722d0e70 100644 --- a/src/x86/looprestoration16_avx512.asm +++ b/src/x86/looprestoration16_avx512.asm @@ -51,7 +51,7 @@ pd_m9: dd -9 pd_8: dd 8 pd_2147483648: dd 2147483648 -cextern sgr_x_by_x +cextern_hidden_data sgr_x_by_x SECTION .text diff --git a/src/x86/looprestoration16_sse.asm b/src/x86/looprestoration16_sse.asm index 872e50298..05aa9ab24 100644 --- a/src/x86/looprestoration16_sse.asm +++ b/src/x86/looprestoration16_sse.asm @@ -59,7 +59,7 @@ pd_0xfffffff0: times 4 dd 0xfffffff0 wiener_shifts: dw 4, 4, 2048, 2048, 1, 1, 8192, 8192 wiener_round: dd 1049600, 1048832 -cextern sgr_x_by_x +cextern_hidden_data sgr_x_by_x SECTION .text diff --git a/src/x86/looprestoration_avx512.asm b/src/x86/looprestoration_avx512.asm index 1e571774c..3a9294e7c 100644 --- a/src/x86/looprestoration_avx512.asm +++ b/src/x86/looprestoration_avx512.asm @@ -53,7 +53,7 @@ pd_m9: dd -9 pd_34816: dd 34816 pd_8421376: dd 8421376 -cextern sgr_x_by_x +cextern_hidden_data sgr_x_by_x SECTION .text diff --git a/src/x86/looprestoration_sse.asm b/src/x86/looprestoration_sse.asm index b5c73a51d..9538979b2 100644 --- a/src/x86/looprestoration_sse.asm +++ b/src/x86/looprestoration_sse.asm @@ -51,7 +51,7 @@ pd_0xffff: times 4 dd 0xffff pd_0xf00800a4: times 4 dd 0xf00800a4 pd_0xf00801c7: times 4 dd 0xf00801c7 -cextern sgr_x_by_x +cextern_hidden_data sgr_x_by_x SECTION .text diff --git a/src/x86/mc16_avx2.asm b/src/x86/mc16_avx2.asm index 6b4424946..9fae60152 100644 --- a/src/x86/mc16_avx2.asm +++ b/src/x86/mc16_avx2.asm @@ -194,11 +194,11 @@ SCALED_JMP_TABLE prep_8tap_scaled, avx2, 4, 8, 16, 32, 64, 128 %define table_offset(type, fn) type %+ fn %+ SUFFIX %+ _table - type %+ SUFFIX -cextern mc_subpel_filters +cextern_hidden_data mc_subpel_filters %define subpel_filters (mangle(private_prefix %+ _mc_subpel_filters)-8) -cextern mc_warp_filter -cextern resize_filter +cextern_hidden_data mc_warp_filter +cextern_hidden_data resize_filter SECTION .text diff --git a/src/x86/mc16_avx512.asm b/src/x86/mc16_avx512.asm index 27715c166..a6ddbc231 100644 --- a/src/x86/mc16_avx512.asm +++ b/src/x86/mc16_avx512.asm @@ -251,12 +251,12 @@ HV_JMP_TABLE prep, 8tap, avx512icl, 2, 4, 8, 16, 32, 64, 128 %define table_offset(type, fn) type %+ fn %+ SUFFIX %+ _table - type %+ SUFFIX -cextern mc_subpel_filters +cextern_hidden_data mc_subpel_filters %define subpel_filters (mangle(private_prefix %+ _mc_subpel_filters)-8) -cextern mc_warp_filter -cextern obmc_masks_avx2 -cextern resize_filter +cextern_hidden_data mc_warp_filter +cextern_hidden_data obmc_masks_avx2 +cextern_hidden_data resize_filter SECTION .text diff --git a/src/x86/mc16_sse.asm b/src/x86/mc16_sse.asm index b0c42597f..6c066d28d 100644 --- a/src/x86/mc16_sse.asm +++ b/src/x86/mc16_sse.asm @@ -158,11 +158,11 @@ BASE_JMP_TABLE prep, ssse3, 4, 8, 16, 32, 64, 128 SCALED_JMP_TABLE put_8tap_scaled, ssse3, 2, 4, 8, 16, 32, 64, 128 SCALED_JMP_TABLE prep_8tap_scaled, ssse3, 4, 8, 16, 32, 64, 128 -cextern mc_subpel_filters +cextern_hidden_data mc_subpel_filters %define subpel_filters (mangle(private_prefix %+ _mc_subpel_filters)-8) -cextern mc_warp_filter -cextern resize_filter +cextern_hidden_data mc_warp_filter +cextern_hidden_data resize_filter SECTION .text diff --git a/src/x86/mc_avx2.asm b/src/x86/mc_avx2.asm index df8bebb1c..98b435448 100644 --- a/src/x86/mc_avx2.asm +++ b/src/x86/mc_avx2.asm @@ -91,10 +91,10 @@ pd_0x3ff: dd 0x3ff pd_0x4000: dd 0x4000 pq_0x40000000: dq 0x40000000 -cextern mc_subpel_filters -cextern mc_warp_filter2 -cextern resize_filter -cextern z_filter_s +cextern_hidden_data mc_subpel_filters +cextern_hidden_data mc_warp_filter2 +cextern_hidden_data resize_filter +cextern_hidden_data z_filter_s %define subpel_filters (mangle(private_prefix %+ _mc_subpel_filters)-8) diff --git a/src/x86/mc_avx512.asm b/src/x86/mc_avx512.asm index 50e670ec2..d8b86dafc 100644 --- a/src/x86/mc_avx512.asm +++ b/src/x86/mc_avx512.asm @@ -200,10 +200,10 @@ pd_512: dd 512 %define pb_64 (wm_sign+8) %define pd_2 (pd_0to7+8) -cextern mc_subpel_filters +cextern_hidden_data mc_subpel_filters %define subpel_filters (mangle(private_prefix %+ _mc_subpel_filters)-8) -cextern mc_warp_filter -cextern resize_filter +cextern_hidden_data mc_warp_filter +cextern_hidden_data resize_filter %macro BASE_JMP_TABLE 3-* %xdefine %1_%2_table (%%table - %3) diff --git a/src/x86/mc_sse.asm b/src/x86/mc_sse.asm index a447a8016..558145a99 100644 --- a/src/x86/mc_sse.asm +++ b/src/x86/mc_sse.asm @@ -202,7 +202,7 @@ const mc_warp_filter2 ; dav1d_mc_warp_filter[] reordered for pmaddubsw usage pw_258: times 2 dw 258 -cextern mc_subpel_filters +cextern_hidden_data mc_subpel_filters %define subpel_filters (mangle(private_prefix %+ _mc_subpel_filters)-8) %macro BIDIR_JMP_TABLE 2-* @@ -9357,7 +9357,7 @@ cglobal emu_edge_8bpc, 10, 13, 2, bw, bh, iw, ih, x, \ %undef reg_blkm %undef reg_tmp -cextern resize_filter +cextern_hidden_data resize_filter %macro SCRATCH 3 %if ARCH_X86_32