Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stress test to patch all binaries in the machine #479

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: Publish
on:
workflow_dispatch:
inputs:
enable_stress_test:
description: "Run pachelf on all binaries in the image"
type: boolean
default: false
pull_request:
push:
branches:
Expand Down Expand Up @@ -89,7 +95,7 @@ jobs:
rm -f dist/*
cd patchelf-*
./configure --prefix /patchelf
make check || (cat tests/test-suite.log; exit 1)
make check STRESS=${{ inputs.enable_stress_test }} || (cat tests/test-suite.log; exit 1)
make install-strip
cd -
tar -czf ./dist/patchelf-\$(cat patchelf-*/version)-\$(uname -m).tar.gz -C /patchelf .
Expand Down
1 change: 1 addition & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ src_TESTS = \
modify-execstack.sh \
rename-dynamic-symbols.sh \
overlapping-segments-after-rounding.sh \
stress.sh \
empty-note.sh

build_TESTS = \
Expand Down
45 changes: 45 additions & 0 deletions tests/stress.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#! /bin/sh -e

[ "$STRESS" = "1" ] || exit 0

SCRATCH=scratch/$(basename "$0" .sh)
PATCHELF=$(readlink -f "../src/patchelf")

rm -rf "${SCRATCH}"
mkdir -p "${SCRATCH}"
cd "${SCRATCH}"

for lib in /usr/lib*/*.so* /usr/bin/* /usr/libexec/*
do
if file "$lib" | grep -q -e "ELF.*dynamically"
then
echo "==============================================================="
echo "#### Copying"
echo "$lib"
echo "$(file $lib)"
blib="$(basename "$lib")"
cp "$lib" "$blib"
echo "#### chmod"
chmod +w "$blib"

echo "#### readelf before"
readelf -L "$blib" > /dev/null 2> re_before || echo
echo "#### ldd before"
ldd "$blib" | sed 's/0x.*//g' > ldd_before

echo "#### get rpath"
new_rpath="$(${PATCHELF} --print-rpath "$blib"):XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
echo "#### new rpath: $new_rpath"
${PATCHELF} --force-rpath --set-rpath "$new_rpath" "$blib"

echo "#### readelf after"
readelf -L "$blib" > /dev/null 2> re_after || echo
echo "#### ldd after"
ldd "$blib" | sed 's/0x.*//g' > ldd_after

diff re_before re_after
diff ldd_before ldd_after

rm "$blib"
fi
done