Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux/x64: Fix SIMD routines not linking due to illegal relocations #1367

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/ext/x86/x86inc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/rerun-io/re_rav1d/pull/3> 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
Expand Down
2 changes: 1 addition & 1 deletion src/x86/filmgrain_common.asm
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ struc FGData
.clip_to_restricted_range: resd 1
endstruc

cextern gaussian_sequence
cextern_hidden_data gaussian_sequence
4 changes: 2 additions & 2 deletions src/x86/ipred16_avx2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/x86/ipred16_avx512.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/x86/ipred16_sse.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/x86/ipred_avx2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/x86/ipred_avx512.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/x86/ipred_sse.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/x86/looprestoration16_avx2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/x86/looprestoration16_avx512.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/x86/looprestoration16_sse.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/x86/looprestoration_avx512.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/x86/looprestoration_sse.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/x86/mc16_avx2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/x86/mc16_avx512.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/x86/mc16_sse.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/x86/mc_avx2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions src/x86/mc_avx512.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/x86/mc_sse.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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-*
Expand Down Expand Up @@ -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
Expand Down
Loading