summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-04-25 10:16:35 +0000
committerGitHub <noreply@github.com>2023-04-25 10:16:35 +0000
commit008a582741617e2d7d5aa4aab1e8ddfdec0067d9 (patch)
tree77109775d02a2e141ac2ee49dd1d7d4d0b7a2764
parent99c24238981b7b1084313aca8f5c493bb46f302c (diff)
parent1ab6930d154b4bd6cee8f2751dd4429d92a4a67d (diff)
downloadpatchelf-master.tar.gz
493: Respect prefixed tools used with the tests when cross-compiling r=Mic92 a=heirecka Co-authored-by: Heiko Becker <heirecka@exherbo.org>
-rw-r--r--configure.ac2
-rw-r--r--tests/Makefile.am2
-rwxr-xr-xtests/repeated-updates.sh5
-rwxr-xr-xtests/shared-rpath.sh17
4 files changed, 15 insertions, 11 deletions
diff --git a/configure.ac b/configure.ac
index 4129920..fee6302 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,9 +7,11 @@ 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([NM], [nm], [nm])
AC_CHECK_TOOL([OBJDUMP], [objdump], [objdump])
AC_CHECK_TOOL([OBJCOPY], [objcopy], [objcopy])
AC_CHECK_TOOL([READELF], [readelf], [readelf])
+AC_CHECK_TOOL([STRINGS], [strings], [strings])
AM_PROG_CC_C_O
AC_PROG_CXX
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a68d2e2..8bbded7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -61,7 +61,7 @@ TESTS = $(src_TESTS) $(build_TESTS)
EXTRA_DIST = no-rpath-prebuild $(src_TESTS) no-rpath-prebuild.sh invalid-elf endianness empty-note \
overlapping-segments-after-rounding short-first-segment.gz
-TESTS_ENVIRONMENT = PATCHELF_DEBUG=1 STRIP=$(STRIP) OBJDUMP=$(OBJDUMP) READELF=$(READELF) OBJCOPY=$(OBJCOPY)
+TESTS_ENVIRONMENT = PATCHELF_DEBUG=1 STRIP=$(STRIP) NM=$(NM) OBJDUMP=$(OBJDUMP) READELF=$(READELF) OBJCOPY=$(OBJCOPY) STRINGS=$(STRINGS)
$(no_rpath_arch_TESTS): no-rpath-prebuild.sh
@ln -s $< $@
diff --git a/tests/repeated-updates.sh b/tests/repeated-updates.sh
index 669b11d..da7715a 100755
--- a/tests/repeated-updates.sh
+++ b/tests/repeated-updates.sh
@@ -2,6 +2,7 @@
SCRATCH=scratch/$(basename "$0" .sh)
PATCHELF=$(readlink -f "../src/patchelf")
+READELF=${READELF:-readelf}
rm -rf "${SCRATCH}"
mkdir -p "${SCRATCH}"
@@ -18,7 +19,7 @@ ${PATCHELF} --add-needed ./libbar.so simple
# Test that repeatedly modifying a string inside a shared library does not
# corrupt it due to the addition of multiple PT_LOAD entries
###############################################################################
-load_segments_before=$(readelf -W -l libbar.so | grep -c LOAD)
+load_segments_before=$(${READELF} -W -l libbar.so | grep -c LOAD)
for _ in $(seq 1 100)
do
@@ -27,7 +28,7 @@ do
./simple || exit 1
done
-load_segments_after=$(readelf -W -l libbar.so | grep -c LOAD)
+load_segments_after=$(${READELF} -W -l libbar.so | grep -c LOAD)
###############################################################################
# To be even more strict, check that we don't add too many extra LOAD entries
diff --git a/tests/shared-rpath.sh b/tests/shared-rpath.sh
index 8e6e26f..1fa46b9 100755
--- a/tests/shared-rpath.sh
+++ b/tests/shared-rpath.sh
@@ -2,7 +2,8 @@
PATCHELF=$(readlink -f "../src/patchelf")
SCRATCH="scratch/$(basename "$0" .sh)"
-READELF=${READELF:-readelf}
+NM=${NM:-nm}
+STRINGS=${STRINGS:-strings}
LIB_NAME="${PWD}/libshared-rpath.so"
@@ -11,11 +12,11 @@ mkdir -p "${SCRATCH}"
cd "${SCRATCH}"
has_x() {
- strings "$1" | grep -c "XXXXXXXX"
+ ${STRINGS} "$1" | grep -c "XXXXXXXX"
}
-nm -D "${LIB_NAME}" | grep a_symbol_name
-previous_cnt="$(strings "${LIB_NAME}" | grep -c a_symbol_name)"
+${NM} -D "${LIB_NAME}" | grep a_symbol_name
+previous_cnt="$(${STRINGS} "${LIB_NAME}" | grep -c a_symbol_name)"
echo "#### Number of a_symbol_name strings in the library: $previous_cnt"
@@ -25,12 +26,12 @@ echo "#### Rename the rpath to something larger than the original"
"${PATCHELF}" --set-rpath a_very_big_rpath_that_is_larger_than_original --output liblarge-rpath.so "${LIB_NAME}"
echo "#### Checking symbol is still there"
-nm -D liblarge-rpath.so | grep a_symbol_name
+${NM} -D liblarge-rpath.so | grep a_symbol_name
echo "#### Checking there are no Xs"
[ "$(has_x liblarge-rpath.so)" -eq 0 ] || exit 1
-current_cnt="$(strings liblarge-rpath.so | grep -c a_symbol_name)"
+current_cnt="$(${STRINGS} liblarge-rpath.so | grep -c a_symbol_name)"
echo "#### Number of a_symbol_name strings in the modified library: $current_cnt"
[ "$current_cnt" -eq "$previous_cnt" ] || exit 1
@@ -40,10 +41,10 @@ echo "#### Rename the rpath to something shorter than the original"
"${PATCHELF}" --set-rpath shrt_rpth --output libshort-rpath.so "${LIB_NAME}"
echo "#### Checking symbol is still there"
-nm -D libshort-rpath.so | grep a_symbol_name
+${NM} -D libshort-rpath.so | grep a_symbol_name
echo "#### Number of a_symbol_name strings in the modified library: $current_cnt"
-current_cnt="$(strings libshort-rpath.so | grep -c a_symbol_name)"
+current_cnt="$(${STRINGS} libshort-rpath.so | grep -c a_symbol_name)"
[ "$current_cnt" -eq "$previous_cnt" ] || exit 1
echo "#### Now liblarge-rpath.so should have its own rpath, so it should be allowed to taint it"