Skip to content

Commit

Permalink
Fix replace-add-needed.sh test for musl
Browse files Browse the repository at this point in the history
  • Loading branch information
fzakaria committed Dec 21, 2021
1 parent e589fe3 commit b92a6e8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/replace-add-needed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@ cp simple ${SCRATCH}/
cp libfoo.so ${SCRATCH}/
cp libbar.so ${SCRATCH}/


cd ${SCRATCH}

libcldd=$(ldd ./simple | awk '/ => / { print $3 }' | grep .so | head -n 1)
libcldd=$(ldd ./simple | awk '/ => / { print $3 }' | grep -E "(libc.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) \
Expand All @@ -31,4 +35,4 @@ exitCode=0
if test "$exitCode" != 0; then
ldd ./simple
exit 1
fi
fi

0 comments on commit b92a6e8

Please sign in to comment.