[FFmpeg-devel] [PATCH] fft_tab_neon is not PIC enough

John Reiser jreiser at bitwagon.com
Sat Jul 14 17:24:30 CEST 2012

fft_tab_neon has addresses in .rodata, which is bad for shared libraries.

Table fft_tab_neon, function ff_fft_calc_neon, in libavcodec/arm/fft_neon.S
contains addresses but resides in read-only section .rodata.
The addresses must be relocated whenever the runtime location
differs from the one that was assumed during static linking.
This creates a problem for using the code in a shared library.

The attached patch provides the additional relocation by changing
the table to an array of branch instructions.  The patch also
checks the bounds of the index.  In Thumb mode the 11-bit displacement
field of a short unconditional branch can span +/- 1024 words
which is +/- 2048 bytes.  By moving the routine to near the middle,
then the other code could double in size before exceeding
the limit on span.

There is a delay of 3 cycles after "add to pc" and 2 cycles
after the taken 'b'.  The total time is similar to previous code,
which had two pointer fetches, two explicit adds [one missing],
and a 'bx'.  In Thumb mode the array of short branch instructions
is 30 bytes smaller than the table of addresses.

The same problem occurs with ff_fft_fixed_calc_neon;
this patch fixes that problem, too.  A similar problem afflicts
but I have not found those sources.  Where are they?

John Reiser
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fft_tab_neon-is-not-PIC-enough.patch
Type: text/x-patch
Size: 4780 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120714/ccb84473/attachment.bin>

More information about the ffmpeg-devel mailing list