Skip to content

Commit

Permalink
fix some tests when running under QEMU
Browse files Browse the repository at this point in the history
In some cases, ldd can fail on the original binary. In that case it is also observed that running with an explicit interpreter will fail.

https://gitlab.com/qemu-project/qemu/-/issues/1763
  • Loading branch information
mayeut committed Dec 3, 2024
1 parent 7deb203 commit 7a9feaf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion tests/replace-add-needed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ cp libbar.so "${SCRATCH}"/

cd "${SCRATCH}"

libcldd=$(ldd ./simple | awk '/ => / { print $3 }' | grep -E "(libc(-[0-9.]*)*.so|ld-musl)")
# QEMU & ldd are not playing well together in certain cases
if ldd ./simple >/dev/null 2>&1; then
libcldd=$(ldd ./simple | awk '/ => / { print $3 }' | grep -E "(libc(-[0-9.]*)*.so|ld-musl)")
elif [ -f /lib64/libc.so.6 ]; then
libcldd=/lib64/libc.so.6
else
echo "ldd ./simple failed"
exit 1
fi

# We have to set the soname on these libraries
${PATCHELF} --set-soname libbar.so ./libbar.so
Expand Down
5 changes: 3 additions & 2 deletions tests/set-interpreter-long.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ SCRATCH=scratch/$(basename "$0" .sh)
oldInterpreter=$(../src/patchelf --print-interpreter ./simple)
echo "current interpreter is $oldInterpreter"

if test "$(uname)" = Linux; then
# QEMU & ldd/ld.so are not playing well together in certain cases
if test "$(uname)" = Linux && ldd ./simple >/dev/null 2>&1; then
echo "running with explicit interpreter..."
"$oldInterpreter" ./simple
fi
Expand All @@ -28,7 +29,7 @@ echo "running with new interpreter..."
ln -s "$oldInterpreter" "$newInterpreter"
"${SCRATCH}"/simple

if test "$(uname)" = Linux; then
if test "$(uname)" = Linux && ldd ./simple >/dev/null 2>&1; then
echo "running with explicit interpreter..."
"$oldInterpreter" "${SCRATCH}/simple"
fi

0 comments on commit 7a9feaf

Please sign in to comment.