-
-
Notifications
You must be signed in to change notification settings - Fork 490
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for --clear-symbol-version
This test removes the __libc_start_main@GLIBC_2.34 symbol, which should be the only GLIBC_2.34 symbol in 'main' when built with recent (i.e., > 2.34) glibc. Because it is the only symbol, the entry in .gnu.version_r should also be removed. Because this is a symbol version test, it's unlikely to work on musl or anything else which doesn't use glibc symbol versions.
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#! /bin/sh -e | ||
SCRATCH=scratch/$(basename $0 .sh) | ||
|
||
rm -rf ${SCRATCH} | ||
mkdir -p ${SCRATCH} | ||
|
||
cp main ${SCRATCH}/ | ||
RANDOM_PATH=$(pwd)/${SCRATCH}/$RANDOM | ||
|
||
SYMBOL_TO_REMOVE=__libc_start_main | ||
VERSION_TO_REMOVE=GLIBC_2.34 | ||
|
||
readelfData=$(readelf -V ${SCRATCH}/main 2>&1) | ||
|
||
if [ $(echo "$readelfData" | grep --count "$VERSION_TO_REMOVE") < 2 ]; then | ||
# We expect this to appear at least twice: once for the symbol entry, | ||
# and once for verneed entry. | ||
echo "Couldn't find expected versioned symbol. Are you building with glibc?" | ||
exit 1 | ||
fi | ||
|
||
../src/patchelf --clear-symbol-version ${SYMBOL_TO_REMOVE} ${SCRATCH}/main | ||
|
||
readelfData=$(readelf -V ${SCRATCH}/main 2>&1) | ||
|
||
if [ $(echo "$readelfData" | grep --count "$VERSION_TO_REMOVE") != 0 ]; then | ||
# We expect this to appear at least twice: once for the symbol entry, | ||
# and once for verneed entry. | ||
echo "The symbol version ${SYMBOL_TO_REMOVE} remained behind!" | ||
exit 1 | ||
fi |