diff options
Diffstat (limited to 'tests/phdr-corruption.sh')
-rwxr-xr-x | tests/phdr-corruption.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/phdr-corruption.sh b/tests/phdr-corruption.sh new file mode 100755 index 0000000..0a36882 --- /dev/null +++ b/tests/phdr-corruption.sh @@ -0,0 +1,21 @@ +#! /bin/sh -e + +PATCHELF="../src/patchelf" +SONAME="phdr-corruption.so" +SCRATCH="scratch/$(basename $0 .sh)" +SCRATCH_SO="${SCRATCH}/${SONAME}" + +rm -rf "${SCRATCH}" +mkdir -p "${SCRATCH}" +cp "${SONAME}" "${SCRATCH}" + +"${PATCHELF}" --set-rpath "$(pwd)" "${SCRATCH_SO}" + +# Check for PT_PHDR entry VirtAddr corruption +readelfData=$(readelf -l "${SCRATCH_SO}" 2>&1) + +if [ $(echo "$readelfData" | grep --count "PHDR") != 1 ]; then + # Triggered if PHDR errors appear on stderr + echo "ERROR: Unexpected number of occurences of PHDR in readelf results!" + exit 1 +fi |