-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] autoPatchelfHook: search a valid interpreter, or fail #66620
Changes from all commits
aa7c214
9d1f085
b837c7f
b73d431
d2e0625
6ff9b14
254214e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,7 +1,14 @@ | ||||||
declare -a autoPatchelfLibs | ||||||
declare -a autoPatchelfLinkers | ||||||
|
||||||
gatherLibraries() { | ||||||
autoPatchelfLibs+=("$1/lib") | ||||||
if [ -f "$1/nix-support/dynamic-linker" ]; then | ||||||
autoPatchelfLinkers+=("$1/nix-support/dynamic-linker") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
fi | ||||||
if [ -f "$1/nix-support/dynamic-linker-m32" ]; then | ||||||
autoPatchelfLinkers+=("$1/nix-support/dynamic-linker-m32") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
fi | ||||||
} | ||||||
|
||||||
addEnvHooks "$targetOffset" gatherLibraries | ||||||
|
@@ -98,12 +105,38 @@ findDependency() { | |||||
return 1 | ||||||
} | ||||||
|
||||||
patchElfInterpreter() { | ||||||
local toPatch=$1 | ||||||
local linkers=( \ | ||||||
"$NIX_CC/nix-support/dynamic-linker" \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to use backslashes for continuations here, besides, why have |
||||||
"$NIX_CC/nix-support/dynamic-linker-m32" \ | ||||||
"${autoPatchelfLinkers[@]}" \ | ||||||
) | ||||||
|
||||||
echo "searching an '$(getSoArch "$toPatch")' interpreter for $toPatch" >&2 | ||||||
for f in "${linkers[@]}"; do | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
[ -f "$f" -a -r "$f" ] || continue | ||||||
local interpreter=$(< "$f") | ||||||
|
||||||
[ -n "$interpreter" -a -f "$interpreter" ] || continue | ||||||
[ "$(getSoArch "$toPatch")" = $(getSoArch "$interpreter") ] || continue | ||||||
|
||||||
echo "found an '$(getSoArch "$toPatch")' interpreter at '$interpreter'" >&2 | ||||||
patchelf --set-interpreter "$interpreter" "$toPatch" | ||||||
return | ||||||
done | ||||||
|
||||||
echo "error: no '$(getSoArch "$toPatch")' interpreter found but one is required for '$toPatch'" >&2 | ||||||
false | ||||||
} | ||||||
|
||||||
autoPatchelfFile() { | ||||||
local dep rpath="" toPatch="$1" | ||||||
|
||||||
local interpreter="$(< "$NIX_CC/nix-support/dynamic-linker")" | ||||||
if isExecutable "$toPatch"; then | ||||||
patchelf --set-interpreter "$interpreter" "$toPatch" | ||||||
# Find a suitable interpreter | ||||||
patchElfInterpreter "$toPatch" | ||||||
|
||||||
if [ -n "$runtimeDependencies" ]; then | ||||||
for dep in $runtimeDependencies; do | ||||||
rpath="$rpath${rpath:+:}$dep/lib" | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ deployAndroidPackage { | |
lib.optional (os == "linux") [ pkgs.glibc pkgs.zlib pkgs.ncurses5 pkgs_i686.glibc pkgs_i686.zlib pkgs_i686.ncurses5 ]; | ||
patchInstructions = '' | ||
${lib.optionalString (os == "linux") '' | ||
rm -r $packageBaseDir/{i686,aarch64,mipsel,arm}-linux* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cc: @svanderburg |
||
|
||
addAutoPatchelfSearchPath $packageBaseDir/lib | ||
addAutoPatchelfSearchPath $packageBaseDir/lib64 | ||
autoPatchelf --no-recurse $packageBaseDir/lib64 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't they be correctly
autoPatchelfHook
ed?