patchelf version: Built from 27ffe8a
In our build process, we try to remove all version numbers from the shared objects names of our various dependencies. We use patchelf to fix the referenced sonames everywhere. This seems to work well for the most part, but we noticed one particular example where it corrupts the executable.
In the first case, there were no version numbers in the sonames, so the rewriting is redundant (i.e. we can avoid it). Download the binary here
$ patchelf --print-needed ./ffmpeg
libavfilter.so
libavformat.so
libavcodec.so
libswresample.so
libswscale.so
libavutil.so
libm.so
libc.so
$ patchelf --replace-needed 'libavfilter.so' 'libavfilter.so' --replace-needed 'libavformat.so' 'libavformat.so' --replace-needed 'libavcodec.so' 'libavcodec.so' --replace-needed 'libswresample.so' 'libswresample.so' --replace-needed 'libswscale.so' 'libswscale.so' --replace-needed 'libavutil.so' 'libavutil.so' ./ffmpeg
$ patchelf --print-needed ./ffmpeg
libavutil.so
bavcodec.so
avformat.so
libswresample.so
bswscale.so
bavfilter.so
libm.so
libc.so
Notice how libavcodec.so became bavcodec.so etc.
In the second case, there are numbers to strip. Download the binary here
$ patchelf --print-needed ./ffmpeg2
libavfilter.so.7
libavformat.so.58
libavcodec.so.58
libswresample.so.3
libswscale.so.5
libavutil.so.56
libm.so.6
libpthread.so.0
libc.so.6
$ patchelf --replace-needed 'libavfilter.so.7' 'libavfilter.so' --replace-needed 'libavformat.so.58' 'libavformat.so' --replace-needed 'libavcodec.so.58' 'libavcodec.so' --replace-needed 'libswresample.so.3' 'libswresample.so' --replace-needed 'libavutil.so.56' 'libavutil.so' --replace-needed 'libm.so.6' 'libm.so' --replace-needed 'libpthread.so.0' 'libpthread.so' --replace-needed 'libc.so.6' 'libc.so' ./ffmpeg2
$ patchelf --print-needed ./ffmpeg2
libavfilter.so
libpthread.so
ibavcodec.so
ibswresample.so
libswscale.so.5
ibc.so
til.so
ibm.so
rmat.so
As you can see, the replacements are all over the place in this case. The issue is 100% reproducible with the binaries I posted. Let me know if I can provide more information.
patchelf version: Built from 27ffe8a
In our build process, we try to remove all version numbers from the shared objects names of our various dependencies. We use patchelf to fix the referenced sonames everywhere. This seems to work well for the most part, but we noticed one particular example where it corrupts the executable.
In the first case, there were no version numbers in the sonames, so the rewriting is redundant (i.e. we can avoid it). Download the binary here
Notice how
libavcodec.sobecamebavcodec.soetc.In the second case, there are numbers to strip. Download the binary here
As you can see, the replacements are all over the place in this case. The issue is 100% reproducible with the binaries I posted. Let me know if I can provide more information.