Files
patchelf/tests/replace-add-needed.sh
Robert Scheck f7053d0237 Handle glibc-hwcaps on ppc64le on CentOS/RHEL/Rocky 8 for tests/replace-add-needed.sh (fixes #406)
ldd(1) usually returns for ELF binaries output like this:

	libc.so.6 => /lib64/libc.so.6 (0x00007fbacd6ca000)

But with glibc-hwcaps, the output could also be like this:

	libc.so.6 => /lib64/glibc-hwcaps/power9/libc-2.28.so (0x00007fffb5800000)

See also: https://sourceware.org/pipermail/libc-alpha/2020-June/115250.html
2022-09-27 00:41:51 +02:00

38 lines
1002 B
Bash
Executable File

#! /bin/sh -e
SCRATCH=scratch/$(basename $0 .sh)
PATCHELF=$(readlink -f "../src/patchelf")
rm -rf ${SCRATCH}
mkdir -p ${SCRATCH}
cp simple ${SCRATCH}/
cp libfoo.so ${SCRATCH}/
cp libbar.so ${SCRATCH}/
cd ${SCRATCH}
libcldd=$(ldd ./simple | awk '/ => / { print $3 }' | grep -E "(libc(-[0-9.]*)*.so|ld-musl)")
# We have to set the soname on these libraries
${PATCHELF} --set-soname libbar.so ./libbar.so
# Add a libbar.so so we can rewrite it later
${PATCHELF} --add-needed libbar.so ./simple
# Make the NEEDED in libfoo the same as simple
# This is a current "bug" in musl
# https://www.openwall.com/lists/musl/2021/12/21/1
${PATCHELF} --replace-needed libbar.so $(readlink -f ./libbar.so) ./libfoo.so
${PATCHELF} --replace-needed libc.so.6 ${libcldd} \
--replace-needed libbar.so $(readlink -f ./libbar.so) \
--add-needed $(readlink -f ./libfoo.so) \
./simple
exitCode=0
./simple || exitCode=$?
if test "$exitCode" != 0; then
ldd ./simple
exit 1
fi