[FFmpeg-devel] Suggested fix for: Linker error when using libavcodec.a within shared library on ARM plattform

Andreas Haupt anhaupt at yahoo.com
Thu Feb 12 11:56:58 CET 2015


I found an issue when linking against the ffmpeg libavcodec.a static libary on armhf which can probably consider to be a bug.

Summary of the bug:
When I try to build a shared library in which I include libavcodec.a I receive the following linker error (on ARM plattform - banana pi board).
Affected versions of ffmpeg are at least 2.5.3 and git-master, affected plattform is armhf (linux).

Error message from linker:

/home/hpt/ffmpeg/arm_gcc/2.5.3/lib/static/libavcodec.a(videodsp_armv5te.o): In function `ff_prefetch_arm':
/root/build_ffmpeg/ffmpeg/libavcodec/arm/videodsp_armv5te.S:29:(.text+0x8): relocation truncated to fit: R_ARM_THM_JUMP19 against symbol `ff_prefetch_arm' defined in .text section in /home/hpt/ffmpeg/arm_gcc/2.5.3/lib/static/libavcodec.a(videodsp_armv5te.o)
collect2: ld returned 1 exit status

How to reproduce:
Use the attached cpp file to build a shared object library on arm.

When I try to create the shared object library I get the linker error from above. I used the following command to create the shared object library:

% g++ -shared -D__STDC_CONSTANT_MACROS -o test.so -I/home/hpt/ffmpeg/arm_gcc/2.5.3/include/ sample_cpp_file_for_bug_reproduction.cpp /home/hpt/ffmpeg/arm_gcc/2.5.3/lib/static/libavcodec.a

There seems to be some problem in the libavcodec/arm/videodsp_armv5te.S assembler file. In that file the label 'ff_prefetch_arm' (line 25) is exported and further down used by a conditional near jump (line 29). The near jump cannot be done if the label is exported within a shared object library. That's at least the explanation I found for myself.

I used the attached (untested) patch to fix the linker error from above. As far as I can see this patch should fix the problem without any side effects. At least it fixes the  linker error I get.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: sample_cpp_file_for_bug_reproduction.cpp
Type: text/x-c++src
Size: 119 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150212/4e7e3e98/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fixes-the-linker-error-produced-when-using-libavcode.patch
Type: text/x-patch
Size: 866 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150212/4e7e3e98/attachment-0001.bin>

More information about the ffmpeg-devel mailing list