-
-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #361 from fzakaria/faridzakaria/fix-add-replace-fo…
…r-real Allow multiple modifications in same call
- Loading branch information
Showing
4 changed files
with
53 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,4 @@ Makefile | |
.direnv/ | ||
.vscode/ | ||
.idea/ | ||
result |
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
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,38 @@ | ||
#! /bin/sh -e | ||
SCRATCH=scratch/$(basename $0 .sh) | ||
PATCHELF=$(readlink -f "../src/patchelf") | ||
|
||
rm -rf ${SCRATCH} | ||
mkdir -p ${SCRATCH} | ||
|
||
cp simple ${SCRATCH}/ | ||
cp libfoo.so ${SCRATCH}/ | ||
cp libbar.so ${SCRATCH}/ | ||
|
||
cd ${SCRATCH} | ||
|
||
libcldd=$(ldd ./simple | awk '/ => / { print $3 }' | grep -E "(libc.so|ld-musl)") | ||
|
||
# We have to set the soname on these libraries | ||
${PATCHELF} --set-soname libbar.so ./libbar.so | ||
|
||
# Add a libbar.so so we can rewrite it later | ||
${PATCHELF} --add-needed libbar.so ./simple | ||
|
||
# Make the NEEDED in libfoo the same as simple | ||
# This is a current "bug" in musl | ||
# https://www.openwall.com/lists/musl/2021/12/21/1 | ||
${PATCHELF} --replace-needed libbar.so $(readlink -f ./libbar.so) ./libfoo.so | ||
|
||
${PATCHELF} --replace-needed libc.so.6 ${libcldd} \ | ||
--replace-needed libbar.so $(readlink -f ./libbar.so) \ | ||
--add-needed $(readlink -f ./libfoo.so) \ | ||
./simple | ||
|
||
exitCode=0 | ||
./simple || exitCode=$? | ||
|
||
if test "$exitCode" != 0; then | ||
ldd ./simple | ||
exit 1 | ||
fi |