diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c7ed3372..832b1706 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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: @@ -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 . diff --git a/tests/Makefile.am b/tests/Makefile.am index 0b648f83..0c753513 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 = \ diff --git a/tests/stress.sh b/tests/stress.sh new file mode 100755 index 00000000..c01a6807 --- /dev/null +++ b/tests/stress.sh @@ -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