Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 $< $@
Expand Down
5 changes: 3 additions & 2 deletions tests/add-debug-tag.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#! /bin/sh -e
SCRATCH=scratch/$(basename $0 .sh)
READELF=${READELF:-readelf}

rm -rf ${SCRATCH}
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"
Expand All @@ -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"
Expand Down
6 changes: 1 addition & 5 deletions tests/build-id.sh
Original file line number Diff line number Diff line change
@@ -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}"
Expand Down
3 changes: 2 additions & 1 deletion tests/force-rpath.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /bin/sh -e
SCRATCH=scratch/$(basename $0 .sh)
OBJDUMP=${OBJDDUMP:-objdump}

rm -rf ${SCRATCH}
mkdir -p ${SCRATCH}
Expand All @@ -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'"
Expand Down
10 changes: 6 additions & 4 deletions tests/set-rpath-rel-map.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down