diff --git a/configure.ac b/configure.ac index 4729e4f..4129920 100644 --- a/configure.ac +++ b/configure.ac @@ -6,6 +6,10 @@ AM_INIT_AUTOMAKE([1.11.1 -Wall -Werror dist-bzip2 foreign color-tests parallel-t AC_CONFIG_MACRO_DIR([m4]) AC_CHECK_TOOL([STRIP], [strip]) +# Those are only used in tests, hence we gracefully degrate if they are not found. +AC_CHECK_TOOL([OBJDUMP], [objdump], [objdump]) +AC_CHECK_TOOL([OBJCOPY], [objcopy], [objcopy]) +AC_CHECK_TOOL([READELF], [readelf], [readelf]) AM_PROG_CC_C_O AC_PROG_CXX diff --git a/tests/Makefile.am b/tests/Makefile.am index ba51652..cb80d9a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -52,7 +52,7 @@ TESTS = $(src_TESTS) $(build_TESTS) EXTRA_DIST = no-rpath-prebuild $(src_TESTS) no-rpath-prebuild.sh invalid-elf endianness empty-note -TESTS_ENVIRONMENT = PATCHELF_DEBUG=1 +TESTS_ENVIRONMENT = PATCHELF_DEBUG=1 OBJDUMP=$(OBJDUMP) READELF=$(READELF) $(no_rpath_arch_TESTS): no-rpath-prebuild.sh @ln -s $< $@ diff --git a/tests/add-debug-tag.sh b/tests/add-debug-tag.sh index 203a0bc..4fbbfa4 100755 --- a/tests/add-debug-tag.sh +++ b/tests/add-debug-tag.sh @@ -1,5 +1,6 @@ #! /bin/sh -e SCRATCH=scratch/$(basename $0 .sh) +READELF=${READELF:-readelf} rm -rf ${SCRATCH} mkdir -p ${SCRATCH} @@ -7,7 +8,7 @@ mkdir -p ${SCRATCH} cp libsimple.so ${SCRATCH}/ # check there is no DT_DEBUG tag -debugTag=$(readelf -d ${SCRATCH}/libsimple.so) +debugTag=$($READELF -d ${SCRATCH}/libsimple.so) echo ".dynamic before: $debugTag" if echo "$debugTag" | grep -q DEBUG; then echo "failed --add-debug-tag test. Expected no line with (DEBUG), got: $debugTag" @@ -18,7 +19,7 @@ fi ../src/patchelf --add-debug-tag ${SCRATCH}/libsimple.so # check there is DT_DEBUG tag -debugTag=$(readelf -d ${SCRATCH}/libsimple.so) +debugTag=$($READELF -d ${SCRATCH}/libsimple.so) echo ".dynamic before: $debugTag" if ! echo "$debugTag" | grep -q DEBUG; then echo "failed --add-debug-tag test. Expected line with (DEBUG), got: $debugTag" diff --git a/tests/build-id.sh b/tests/build-id.sh index 81b8f06..94ddc4c 100755 --- a/tests/build-id.sh +++ b/tests/build-id.sh @@ -1,10 +1,6 @@ #! /bin/sh -e SCRATCH=scratch/$(basename $0 .sh) - -if ! command -v readelf >/dev/null; then - echo "No readelf found; skip test" - exit 0 -fi +READELF=${READELF:-readelf} rm -rf "${SCRATCH}" mkdir -p "${SCRATCH}" diff --git a/tests/force-rpath.sh b/tests/force-rpath.sh index 9256905..6b1422a 100755 --- a/tests/force-rpath.sh +++ b/tests/force-rpath.sh @@ -1,5 +1,6 @@ #! /bin/sh -e SCRATCH=scratch/$(basename $0 .sh) +OBJDUMP=${OBJDDUMP:-objdump} rm -rf ${SCRATCH} mkdir -p ${SCRATCH} @@ -13,7 +14,7 @@ doit() { } expect() { - out=$(echo $(objdump -x $SCRATCHFILE | grep PATH)) + out=$(echo $($OBJDUMP -x $SCRATCHFILE | grep PATH)) if [ "$out" != "$*" ]; then echo "Expected '$*' but got '$out'" diff --git a/tests/set-rpath-rel-map.sh b/tests/set-rpath-rel-map.sh index efc0943..48bc361 100755 --- a/tests/set-rpath-rel-map.sh +++ b/tests/set-rpath-rel-map.sh @@ -1,12 +1,14 @@ #! /bin/sh -e -if ! objdump -p main | grep -q MIPS_RLD_MAP_REL; then +SCRATCH=scratch/$(basename $0 .sh) +OBJDUMP=${OBJDUMP:-objdump} +OBJCOPY=${OBJCOPY:-objcopy} + +if ! $OBJDUMP -p main | grep -q MIPS_RLD_MAP_REL; then echo "No MIPS_RLD_MAP_REL dynamic section entry, skipping" exit 0 fi -SCRATCH=scratch/$(basename $0 .sh) - rm -rf ${SCRATCH} mkdir -p ${SCRATCH} mkdir -p ${SCRATCH}/libsA @@ -17,7 +19,7 @@ cp libfoo.so ${SCRATCH}/libsA/ cp libbar.so ${SCRATCH}/libsB/ # break the main executable by removing .rld_map section -objcopy --remove-section .rld_map ${SCRATCH}/main +${OBJCOPY} --remove-section .rld_map ${SCRATCH}/main oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/main) if test -z "$oldRPath"; then oldRPath="/oops"; fi