Skip to content

Commit 8c9182f

Browse files
heireckaEricson2314
authored andcommitted
Also respect a prefixed nm and strings too
(cherry picked from commit 1ab6930)
1 parent 8aa3321 commit 8c9182f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

tests/shared-rpath.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
PATCHELF=$(readlink -f "../src/patchelf")
44
SCRATCH="scratch/$(basename "$0" .sh)"
5-
READELF=${READELF:-readelf}
5+
NM=${NM:-nm}
6+
STRINGS=${STRINGS:-strings}
67

78
LIB_NAME="${PWD}/libshared-rpath.so"
89

@@ -11,11 +12,11 @@ mkdir -p "${SCRATCH}"
1112
cd "${SCRATCH}"
1213

1314
has_x() {
14-
strings "$1" | grep -c "XXXXXXXX"
15+
${STRINGS} "$1" | grep -c "XXXXXXXX"
1516
}
1617

17-
nm -D "${LIB_NAME}" | grep a_symbol_name
18-
previous_cnt="$(strings "${LIB_NAME}" | grep -c a_symbol_name)"
18+
${NM} -D "${LIB_NAME}" | grep a_symbol_name
19+
previous_cnt="$(${STRINGS} "${LIB_NAME}" | grep -c a_symbol_name)"
1920

2021
echo "#### Number of a_symbol_name strings in the library: $previous_cnt"
2122

@@ -25,12 +26,12 @@ echo "#### Rename the rpath to something larger than the original"
2526
"${PATCHELF}" --set-rpath a_very_big_rpath_that_is_larger_than_original --output liblarge-rpath.so "${LIB_NAME}"
2627

2728
echo "#### Checking symbol is still there"
28-
nm -D liblarge-rpath.so | grep a_symbol_name
29+
${NM} -D liblarge-rpath.so | grep a_symbol_name
2930

3031
echo "#### Checking there are no Xs"
3132
[ "$(has_x liblarge-rpath.so)" -eq 0 ] || exit 1
3233

33-
current_cnt="$(strings liblarge-rpath.so | grep -c a_symbol_name)"
34+
current_cnt="$(${STRINGS} liblarge-rpath.so | grep -c a_symbol_name)"
3435
echo "#### Number of a_symbol_name strings in the modified library: $current_cnt"
3536
[ "$current_cnt" -eq "$previous_cnt" ] || exit 1
3637

@@ -40,10 +41,10 @@ echo "#### Rename the rpath to something shorter than the original"
4041
"${PATCHELF}" --set-rpath shrt_rpth --output libshort-rpath.so "${LIB_NAME}"
4142

4243
echo "#### Checking symbol is still there"
43-
nm -D libshort-rpath.so | grep a_symbol_name
44+
${NM} -D libshort-rpath.so | grep a_symbol_name
4445

4546
echo "#### Number of a_symbol_name strings in the modified library: $current_cnt"
46-
current_cnt="$(strings libshort-rpath.so | grep -c a_symbol_name)"
47+
current_cnt="$(${STRINGS} libshort-rpath.so | grep -c a_symbol_name)"
4748
[ "$current_cnt" -eq "$previous_cnt" ] || exit 1
4849

4950
echo "#### Now liblarge-rpath.so should have its own rpath, so it should be allowed to taint it"

0 commit comments

Comments
 (0)