Skip to content

Commit 07bbf47

Browse files
authored
Merge pull request #437 from NixOS/ci
make objdump/objcopy/readelf configurable and respect cross-compiling…
2 parents 053c2eb + b0599fe commit 07bbf47

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
lines changed

configure.ac

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ AM_INIT_AUTOMAKE([1.11.1 -Wall -Werror dist-bzip2 foreign color-tests parallel-t
66
AC_CONFIG_MACRO_DIR([m4])
77

88
AC_CHECK_TOOL([STRIP], [strip])
9+
# Those are only used in tests, hence we gracefully degrate if they are not found.
10+
AC_CHECK_TOOL([OBJDUMP], [objdump], [objdump])
11+
AC_CHECK_TOOL([OBJCOPY], [objcopy], [objcopy])
12+
AC_CHECK_TOOL([READELF], [readelf], [readelf])
913

1014
AM_PROG_CC_C_O
1115
AC_PROG_CXX

tests/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ TESTS = $(src_TESTS) $(build_TESTS)
5252

5353
EXTRA_DIST = no-rpath-prebuild $(src_TESTS) no-rpath-prebuild.sh invalid-elf endianness empty-note
5454

55-
TESTS_ENVIRONMENT = PATCHELF_DEBUG=1
55+
TESTS_ENVIRONMENT = PATCHELF_DEBUG=1 OBJDUMP=$(OBJDUMP) READELF=$(READELF)
5656

5757
$(no_rpath_arch_TESTS): no-rpath-prebuild.sh
5858
@ln -s $< $@

tests/add-debug-tag.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#! /bin/sh -e
22
SCRATCH=scratch/$(basename $0 .sh)
3+
READELF=${READELF:-readelf}
34

45
rm -rf ${SCRATCH}
56
mkdir -p ${SCRATCH}
67

78
cp libsimple.so ${SCRATCH}/
89

910
# check there is no DT_DEBUG tag
10-
debugTag=$(readelf -d ${SCRATCH}/libsimple.so)
11+
debugTag=$($READELF -d ${SCRATCH}/libsimple.so)
1112
echo ".dynamic before: $debugTag"
1213
if echo "$debugTag" | grep -q DEBUG; then
1314
echo "failed --add-debug-tag test. Expected no line with (DEBUG), got: $debugTag"
@@ -18,7 +19,7 @@ fi
1819
../src/patchelf --add-debug-tag ${SCRATCH}/libsimple.so
1920

2021
# check there is DT_DEBUG tag
21-
debugTag=$(readelf -d ${SCRATCH}/libsimple.so)
22+
debugTag=$($READELF -d ${SCRATCH}/libsimple.so)
2223
echo ".dynamic before: $debugTag"
2324
if ! echo "$debugTag" | grep -q DEBUG; then
2425
echo "failed --add-debug-tag test. Expected line with (DEBUG), got: $debugTag"

tests/build-id.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#! /bin/sh -e
22
SCRATCH=scratch/$(basename $0 .sh)
3-
4-
if ! command -v readelf >/dev/null; then
5-
echo "No readelf found; skip test"
6-
exit 0
7-
fi
3+
READELF=${READELF:-readelf}
84

95
rm -rf "${SCRATCH}"
106
mkdir -p "${SCRATCH}"

tests/force-rpath.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#! /bin/sh -e
22
SCRATCH=scratch/$(basename $0 .sh)
3+
OBJDUMP=${OBJDDUMP:-objdump}
34

45
rm -rf ${SCRATCH}
56
mkdir -p ${SCRATCH}
@@ -13,7 +14,7 @@ doit() {
1314
}
1415

1516
expect() {
16-
out=$(echo $(objdump -x $SCRATCHFILE | grep PATH))
17+
out=$(echo $($OBJDUMP -x $SCRATCHFILE | grep PATH))
1718

1819
if [ "$out" != "$*" ]; then
1920
echo "Expected '$*' but got '$out'"

tests/set-rpath-rel-map.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#! /bin/sh -e
22

3-
if ! objdump -p main | grep -q MIPS_RLD_MAP_REL; then
3+
SCRATCH=scratch/$(basename $0 .sh)
4+
OBJDUMP=${OBJDUMP:-objdump}
5+
OBJCOPY=${OBJCOPY:-objcopy}
6+
7+
if ! $OBJDUMP -p main | grep -q MIPS_RLD_MAP_REL; then
48
echo "No MIPS_RLD_MAP_REL dynamic section entry, skipping"
59
exit 0
610
fi
711

8-
SCRATCH=scratch/$(basename $0 .sh)
9-
1012
rm -rf ${SCRATCH}
1113
mkdir -p ${SCRATCH}
1214
mkdir -p ${SCRATCH}/libsA
@@ -17,7 +19,7 @@ cp libfoo.so ${SCRATCH}/libsA/
1719
cp libbar.so ${SCRATCH}/libsB/
1820

1921
# break the main executable by removing .rld_map section
20-
objcopy --remove-section .rld_map ${SCRATCH}/main
22+
${OBJCOPY} --remove-section .rld_map ${SCRATCH}/main
2123

2224
oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/main)
2325
if test -z "$oldRPath"; then oldRPath="/oops"; fi

0 commit comments

Comments
 (0)