[FFmpeg-user] relocation R_X86_64_PC32 against symbol `ff_w1111' can not be used when making a shared object; recompile with -fPIC
Gabriel Pettier
gabriel.pettier at gmail.com
Wed Aug 26 12:47:23 CEST 2015
Ok, some followup on this issue
asked on #gcc at freenode.net and got told that this result was wrong
```
1 tangible at holo:~/Dev/ffmpegâ« readelf -r libswscale/libswscale.a | grep R_X86_64_PC32.*ff_w1111
00000000640d 007c00000002 R_X86_64_PC32 0000000000000000 ff_w1111 - 4
007c00000002 R_X86_64_PC32 0000000000000000 ff_w1111 - 4
007c00000002 R_X86_64_PC32 0000000000000000 ff_w1111 - 4
007c00000002 R_X86_64_PC32 0000000000000000 ff_w1111 - 4
0000000069bd 007c00000002 R_X86_64_PC32 0000000000000000 ff_w1111 - 4
000000006aa8 007c00000002 R_X86_64_PC32 0000000000000000 ff_w1111 - 4
000000006b94 007c00000002 R_X86_64_PC32 0000000000000000 ff_w1111 - 4
000000006f3d 007c00000002 R_X86_64_PC32 0000000000000000 ff_w1111 - 4
000000007028 007c00000002 R_X86_64_PC32 0000000000000000 ff_w1111 - 4
000000007114 007c00000002 R_X86_64_PC32 0000000000000000 ff_w1111 - 4
```
meaning that my code wasn't relocatable, ran
make SHELL='bash -x'
to get the actual commands run by make, then grepped for rgb2rgb.o and
libswscale.a in it, and got these results
```
+ printf 'CC\t%s\n' libswscale/rgb2rgb.o
CC libswscale/rgb2rgb.o
+ gcc -I. -I./ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -DZLIB_CONST -DHAVE_AV_CONFIG_H -std=c99 -fomit-frame-pointer -fPIC -pthread -g -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -O3 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat -fdiagnostics-color=auto -Wno-maybe-uninitialized -MMD -MF libswscale/rgb2rgb.d -MT libswscale/rgb2rgb.o -c -o libswscale/rgb2rgb.o libswscale/rgb2rgb.c
+ printf 'CC\t%s\n' libswscale/x86/rgb2rgb.o
CC libswscale/x86/rgb2rgb.o
+ gcc -I. -I./ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -DZLIB_CONST -DHAVE_AV_CONFIG_H -std=c99 -fomit-frame-pointer -fPIC -pthread -g -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -O3 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat -fdiagnostics-color=auto -Wno-maybe-uninitialized -MMD -MF libswscale/x86/rgb2rgb.d -MT libswscale/x86/rgb2rgb.o -c -o libswscale/x86/rgb2rgb.o libswscale/x86/rgb2rgb.c
+ gcc -shared -Wl,-soname,libswscale.so.3 -Wl,-Bsymbolic -Wl,--version-script,libswscale/libswscale.ver -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample -fPIC -Wl,--as-needed -Wl,-z,noexecstack -Wl,--warn-common -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample -o libswscale/libswscale.so.3 libswscale/alphablend.o libswscale/hscale.o libswscale/hscale_fast_bilinear.o libswscale/input.o libswscale/log2_tab.o libswscale/options.o libswscale/output.o libswscale/rgb2rgb.o libswscale/slice.o libswscale/swscale.o libswscale/swscale_unscaled.o libswscale/utils.o libswscale/vscale.o libswscale/x86/hscale_fast_bilinear_simd.o libswscale/x86/input.o libswscale/x86/output.o libswscale/x86/rgb2rgb.o libswscale/x86/scale.o libswscale/x86/swscale.o libswscale/x86/yuv2rgb.o libswscale/yuv2rgb.o -lavutil -lXv -lX11 -lXext -lxcb -lxcb-shm -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lxcb-shape -lxcb -lX11 -lasound -lm -llzma -lz -pthread
+ ar rcD libswscale/libswscale.a libswscale/alphablend.o libswscale/hscale.o libswscale/hscale_fast_bilinear.o libswscale/input.o libswscale/log2_tab.o libswscale/options.o libswscale/output.o libswscale/rgb2rgb.o libswscale/slice.o libswscale/swscale.o libswscale/swscale_unscaled.o libswscale/utils.o libswscale/vscale.o libswscale/x86/hscale_fast_bilinear_simd.o libswscale/x86/input.o libswscale/x86/output.o libswscale/x86/rgb2rgb.o libswscale/x86/scale.o libswscale/x86/swscale.o libswscale/x86/yuv2rgb.o libswscale/yuv2rgb.o
```
(http://paste.ubuntu.com/12198450/)
and
```
+ rm -f libswscale/libswscale.a
+ printf 'AR\t%s\n' libswscale/libswscale.a
AR libswscale/libswscale.a
+ ar rcD libswscale/libswscale.a libswscale/alphablend.o libswscale/hscale.o libswscale/hscale_fast_bilinear.o libswscale/input.o libswscale/log2_tab.o libswscale/options.o libswscale/output.o libswscale/rgb2rgb.o libswscale/slice.o libswscale/swscale.o libswscale/swscale_unscaled.o libswscale/utils.o libswscale/vscale.o libswscale/x86/hscale_fast_bilinear_simd.o libswscale/x86/input.o libswscale/x86/output.o libswscale/x86/rgb2rgb.o libswscale/x86/scale.o libswscale/x86/swscale.o libswscale/x86/yuv2rgb.o libswscale/yuv2rgb.o
+ ranlib -D libswscale/libswscale.a
```
(http://paste.ubuntu.com/12198463/)
so it *seems* things are called correctly with -fPIC and -DPIC and
-shared when needed, but maybe something is escaping me. Got suggested
on #gcc that maybe inline asm caused the issue, but i have no idea about
that.
Any pointer welcome.
On Tue, Aug 25, 2015 at 09:57:24AM +0000, Carl Eugen Hoyos wrote:
>Gabriel Pettier <gabriel.pettier <at> gmail.com> writes:
>
>> I tried a lot of different ones, here are a few (by order)
>
>Did you run "make distclean" after each try?
>What version of FFmpeg is this?
>
>I was unable to reproduce your issue with the following
>command:
>
>$ ./configure && make libswscale/libswscale.a
>$ gcc libswscale/libswscale.a -shared -o out.so
>
>Carl Eugen
>
>_______________________________________________
>ffmpeg-user mailing list
>ffmpeg-user at ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/ffmpeg-user
More information about the ffmpeg-user
mailing list