Skip to content

Commit 5bd7b7a

Browse files
committed
Add stress test to patch all binaries in the machine
1 parent 27cbc89 commit 5bd7b7a

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

.github/workflows/publish.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
name: Publish
22
on:
3+
workflow_dispatch:
4+
inputs:
5+
enable_stress_test:
6+
description: "Run pachelf on all binaries in the image"
7+
type: boolean
8+
default: false
39
pull_request:
410
push:
511
branches:
@@ -89,7 +95,7 @@ jobs:
8995
rm -f dist/*
9096
cd patchelf-*
9197
./configure --prefix /patchelf
92-
make check || (cat tests/test-suite.log; exit 1)
98+
make check STRESS=${{ inputs.enable_stress_test }} || (cat tests/test-suite.log; exit 1)
9399
make install-strip
94100
cd -
95101
tar -czf ./dist/patchelf-\$(cat patchelf-*/version)-\$(uname -m).tar.gz -C /patchelf .

tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ src_TESTS = \
4949
modify-execstack.sh \
5050
rename-dynamic-symbols.sh \
5151
overlapping-segments-after-rounding.sh \
52+
stress.sh \
5253
empty-note.sh
5354

5455
build_TESTS = \

tests/stress.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#! /bin/sh -e
2+
3+
[ "$STRESS" = "1" ] || exit 0
4+
5+
SCRATCH=scratch/$(basename "$0" .sh)
6+
PATCHELF=$(readlink -f "../src/patchelf")
7+
8+
rm -rf "${SCRATCH}"
9+
mkdir -p "${SCRATCH}"
10+
cd "${SCRATCH}"
11+
12+
for lib in /usr/lib*/*.so* /usr/bin/* /usr/libexec/*
13+
do
14+
if file "$lib" | grep -q -e "ELF.*dynamically"
15+
then
16+
echo "==============================================================="
17+
echo "#### Copying"
18+
echo "$lib"
19+
echo "$(file $lib)"
20+
blib="$(basename "$lib")"
21+
cp "$lib" "$blib"
22+
echo "#### chmod"
23+
chmod +w "$blib"
24+
25+
echo "#### readelf before"
26+
readelf -L "$blib" > /dev/null 2> re_before || echo
27+
echo "#### ldd before"
28+
ldd "$blib" | sed 's/0x.*//g' > ldd_before
29+
30+
echo "#### get rpath"
31+
new_rpath="$(${PATCHELF} --print-rpath "$blib"):XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
32+
echo "#### new rpath: $new_rpath"
33+
${PATCHELF} --force-rpath --set-rpath "$new_rpath" "$blib"
34+
35+
echo "#### readelf after"
36+
readelf -L "$blib" > /dev/null 2> re_after || echo
37+
echo "#### ldd after"
38+
ldd "$blib" | sed 's/0x.*//g' > ldd_after
39+
40+
diff re_before re_after
41+
diff ldd_before ldd_after
42+
43+
rm "$blib"
44+
fi
45+
done

0 commit comments

Comments
 (0)