Conversation
At ELF files interpreter and libc have to be compatible. This is achieved by either calling `relocate-sdk.sh`, which sets the interpreter, using the host interpreter and libc or wrapping all executables so that the interpreter from the SDK is used. This wraps the executables so that the SDK is usable without extra setup steps.
There was a problem hiding this comment.
Pull request overview
Adds a new helper script to make extracted SDK trees usable “as-is” (without running relocate-sdk.sh) by wrapping SDK-provided host executables with a shell launcher that invokes the SDK’s dynamic loader with an explicit --library-path.
Changes:
- Introduces
scripts/make-self-contained.shto rename ELF host executables to*.realand replace them with loader-based wrappers. - Scans the same SDK executable directories as the existing relocation tooling to decide what to wrap.
Suppressed comments (1)
scripts/make-self-contained.sh:86
- The wrapper currently hard-codes the loader path (
$sdk/usr/lib/.../ld-linux-x86-64.so.2) instead of using the loader that was validated earlier. If the loader is found in a different location (e.g.,/lib64/...), the script may pass the initial check but produce wrappers that fail at runtime. Embed the validated loader path (relative to sdk_root) into the wrapper.
here=\$(dirname "\$(readlink -f "\$0")")
sdk=\$here/$rel_to_root
exec "\$sdk/usr/lib/$arch-linux-gnu/ld-linux-x86-64.so.2" \\
--argv0 "\$0" \\
--library-path "\$sdk/usr/lib/$arch-linux-gnu:\$sdk/lib/$arch-linux-gnu" \\
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+37
to
+42
| search_dirs=() | ||
| for pattern in "$sdk_root"/usr/bin "$sdk_root"/usr/sbin \ | ||
| "$sdk_root"/usr/lib/gcc* "$sdk_root"/usr/libexec/gcc* \ | ||
| "$sdk_root"/usr/lib/llvm*/bin; do | ||
| [ -d "$pattern" ] && search_dirs+=("$pattern") | ||
| done |
Comment on lines
+27
to
+33
| arch=$(uname -m) | ||
|
|
||
| loader="$sdk_root/usr/lib/$arch-linux-gnu/ld-linux-x86-64.so.2" | ||
| if [ ! -x "$loader" ]; then | ||
| echo "error: SDK loader not found at $loader" >&2 | ||
| exit 1 | ||
| fi |
| # Snapshot the file list up front: renaming files while `find` is still | ||
| # walking the tree would let it re-discover freshly created "*.real" files | ||
| # as if they were new binaries, and wrap them a second time. | ||
| mapfile -d '' -t binaries < <(find "${search_dirs[@]}" -type f -perm -u+x -print0 2>/dev/null) |
Author
|
Further testing in S-CORE reference_integration revealed that this broke the Rust build. Since patching |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
At ELF files interpreter and libc have to be compatible. This is achieved by either calling
relocate-sdk.sh, which sets the interpreter, using the host interpreter and libc or wrapping all executables so that the interpreter from the SDK is used.This wraps the executables so that the SDK is usable without extra setup steps.