Text relocation remains against symbol, libx264
May 19th, 2009
Just a very quick post regarding libx264.
If you are getting errors such as:
# gcc -shared -o libx264.so.67 common/mc.o common/predict.o common/pixel.o common/macroblock.o common/frame.o common/dct.o common/cpu.o common/cabac.o common/common.o common/mdate.o common/set.o common/quant.o common/vlc.o encoder/analyse.o encoder/me.o encoder/ratecontrol.o encoder/set.o encoder/macroblock.o encoder/cabac.o encoder/cavlc.o encoder/encoder.o extras/getopt.o -Wl,-h,libx264.so.67 -lm -lpthread -s
Text relocation remains referenced
against symbol offset in file
0x6be common/mc.o
0x6d5 common/mc.o
0xbbe common/mc.o
0xbc5 common/mc.o
...
__udivdi3 0x3809 common/set.o
__udivdi3 0x3875 common/set.o
__udivdi3 0x10cf encoder/macroblock.o
__divdi3 0x17865 encoder/analyse.o
__divdi3 0x1e9 encoder/set.o
ld: fatal: relocations remain against allocatable but non-writable sections
collect2: ld returned 1 exit status
then simply add “-mimpure-text -lrt” to your LDFLAGS.
A quick note to self, “gcc -shared” is better than “gcc -G”. The former tells gcc to build a shared object, which tells the linker (I suppose). The latter just tells the linker. Swapping a -shared for -G can fix the above issue, but creates other issues. Or something along those lines - I’m a bit hazy on this one.
This issue came about because I was getting errors when running a 64bit amd64 ffmpeg linked against libx264:
ld.so.1: ffmpeg: fatal: relocation error: R_AMD64_PC32: file /opt/ec/lib/amd64/libx264.so.67: symbol main: value 0x280018fc805 does not fit
The problem here was that I’d compiled libx264 with gcc -G instead of gcc -shared. However using -shared generated the “Text relocation remains against symbol” errors, which needed the “-mimpure-text -lrt” fix.
Entry Filed under: General

2 Comments Add your own
1. Greg | February 10th, 2010 at 8:27 pm
If you use the -mimpure-text option, your libx264.so.67 gets linked. But, when you link the lib to an executable, and attempt to execute it, the same error is likely to occur agaain:
ld.so.1: : fatal: relocation error: R-AMD64_32: file libx264.so.67: …
2. mismis | October 6th, 2011 at 3:01 pm
it works for me!
I used blastwave csw stuff for compilation:
export LDFLAGS='-L/opt/csw/lib -R/opt/csw/lib'
export CFLAGS='-I/opt/csw/include'
export CC='/opt/csw/gcc4/bin/gcc'
export PKG_CONFIG_PATH='/opt/csw/lib/pkgconfig'
for x264-snapshot-20111004-2245 i did:
./configure --prefix=/opt/csw --enable-shared --enable-pic
then modified config.mak:
LD=/opt/csw/gcc4/bin/gcc -shared -o
LDFLAGS=-L/opt/csw/lib -R/opt/csw/lib -lm -lpthread -mimpure-text -lrt
then shared lib successfully got compiled by issuing /opt/csw/bin/gmake
After this gmake install fails you have to copy manually the compiled objects to the right place:
cp libx264.so.118 /opt/csw/lib
cp libx264.1 /opt/csw/lib
cp x264.h /opt/csw/include
cp x264_config.h /opt/csw/include
cp x264.pc /opt/csw/lib/pkgconfig
also modify /opt/csw/lib/libx264.so symlink to point to the new version!
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed