This makes all the tests pass on an amd64 machine with PKU. The trick is to put the dispatch tables in .data.rel.ro. That means we can have relocations there but that the tables become read-only after the relocations have been processed. Since the table now contains the actual addresses of the functions the extra PIC code isn't needed anymore. Bumped REVISION to make sure folks get an updated version.
According to robert@ it builds on i386, but the tests fail because the -Wl,-znotext isn't passed down to the tests for some reason. But that isn't a new problem as far as I can tell. Upstream probably cares about platforms without relro (which is fairly specific to ELF), so this is probably not upstreamable without some further abstractions/changes. ok? Index: graphics/ffmpeg/Makefile =================================================================== RCS file: /cvs/ports/graphics/ffmpeg/Makefile,v retrieving revision 1.230 diff -u -p -r1.230 Makefile --- graphics/ffmpeg/Makefile 24 Jan 2023 12:08:40 -0000 1.230 +++ graphics/ffmpeg/Makefile 24 Jan 2023 13:27:45 -0000 @@ -2,7 +2,7 @@ COMMENT= audio/video converter and strea V= 4.4.3 DISTNAME= ffmpeg-${V} -REVISION= 2 +REVISION= 3 EPOCH= 1 CATEGORIES= graphics multimedia MASTER_SITES= https://ffmpeg.org/releases/ Index: graphics/ffmpeg/patches/patch-libavcodec_x86_fft_asm =================================================================== RCS file: graphics/ffmpeg/patches/patch-libavcodec_x86_fft_asm diff -N graphics/ffmpeg/patches/patch-libavcodec_x86_fft_asm --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ graphics/ffmpeg/patches/patch-libavcodec_x86_fft_asm 24 Jan 2023 13:27:45 -0000 @@ -0,0 +1,37 @@ +Index: libavcodec/x86/fft.asm +--- libavcodec/x86/fft.asm.orig ++++ libavcodec/x86/fft.asm +@@ -548,10 +548,6 @@ DEFINE_ARGS zc, w, n, o1, o3 + %macro FFT_DISPATCH 2; clobbers 5 GPRs, 8 XMMs + lea r2, [dispatch_tab%1] + mov r2, [r2 + (%2q-2)*gprsize] +-%ifdef PIC +- lea r3, [$$] +- add r2, r3 +-%endif + call r2 + %endmacro ; FFT_DISPATCH + +@@ -731,11 +727,7 @@ DECL_PASS pass_interleave_3dnow, PASS_BIG 0 + %define pass_interleave_3dnowext pass_interleave_3dnow + %endif + +-%ifdef PIC +-%define SECTION_REL - $$ +-%else + %define SECTION_REL +-%endif + + %macro DECL_FFT 1-2 ; nbits, suffix + %ifidn %0, 1 +@@ -773,8 +765,10 @@ fft %+ n %+ fullsuffix: + %endrep + %undef n + ++[SECTION .data.rel.ro write] + align 8 + dispatch_tab %+ fullsuffix: pointer list_of_fft ++__?SECT?__ + %endmacro ; DECL_FFT + + %if HAVE_AVX_EXTERNAL