22
33PATCHELF=$( readlink -f " ../src/patchelf" )
44SCRATCH=" scratch/$( basename " $0 " .sh) "
5- READELF=${READELF:- readelf}
5+ NM=${NM:- nm}
6+ STRINGS=${STRINGS:- strings}
67
78LIB_NAME=" ${PWD} /libshared-rpath.so"
89
@@ -11,11 +12,11 @@ mkdir -p "${SCRATCH}"
1112cd " ${SCRATCH} "
1213
1314has_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
2021echo " #### 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
2728echo " #### 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
3031echo " #### 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) "
3435echo " #### 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
4243echo " #### 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
4546echo " #### 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
4950echo " #### Now liblarge-rpath.so should have its own rpath, so it should be allowed to taint it"
0 commit comments