mirror of
https://github.com/NixOS/patchelf.git
synced 2025-10-18 00:12:18 +08:00
Also respect a prefixed nm and strings too
(cherry picked from commit 1ab6930d15
)
This commit is contained in:

committed by
John Ericson

parent
8aa33212d9
commit
8c9182f7ab
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
PATCHELF=$(readlink -f "../src/patchelf")
|
PATCHELF=$(readlink -f "../src/patchelf")
|
||||||
SCRATCH="scratch/$(basename "$0" .sh)"
|
SCRATCH="scratch/$(basename "$0" .sh)"
|
||||||
READELF=${READELF:-readelf}
|
NM=${NM:-nm}
|
||||||
|
STRINGS=${STRINGS:-strings}
|
||||||
|
|
||||||
LIB_NAME="${PWD}/libshared-rpath.so"
|
LIB_NAME="${PWD}/libshared-rpath.so"
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ mkdir -p "${SCRATCH}"
|
|||||||
cd "${SCRATCH}"
|
cd "${SCRATCH}"
|
||||||
|
|
||||||
has_x() {
|
has_x() {
|
||||||
strings "$1" | grep -c "XXXXXXXX"
|
${STRINGS} "$1" | grep -c "XXXXXXXX"
|
||||||
}
|
}
|
||||||
|
|
||||||
nm -D "${LIB_NAME}" | grep a_symbol_name
|
${NM} -D "${LIB_NAME}" | grep a_symbol_name
|
||||||
previous_cnt="$(strings "${LIB_NAME}" | grep -c 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"
|
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}"
|
"${PATCHELF}" --set-rpath a_very_big_rpath_that_is_larger_than_original --output liblarge-rpath.so "${LIB_NAME}"
|
||||||
|
|
||||||
echo "#### Checking symbol is still there"
|
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"
|
echo "#### Checking there are no Xs"
|
||||||
[ "$(has_x liblarge-rpath.so)" -eq 0 ] || exit 1
|
[ "$(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"
|
echo "#### Number of a_symbol_name strings in the modified library: $current_cnt"
|
||||||
[ "$current_cnt" -eq "$previous_cnt" ] || exit 1
|
[ "$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}"
|
"${PATCHELF}" --set-rpath shrt_rpth --output libshort-rpath.so "${LIB_NAME}"
|
||||||
|
|
||||||
echo "#### Checking symbol is still there"
|
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"
|
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
|
[ "$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"
|
echo "#### Now liblarge-rpath.so should have its own rpath, so it should be allowed to taint it"
|
||||||
|
Reference in New Issue
Block a user