Skip to content
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

Use SONAME to determine interpreter flavor on Linux #24

Open
deciduously opened this issue Mar 25, 2024 · 0 comments
Open

Use SONAME to determine interpreter flavor on Linux #24

deciduously opened this issue Mar 25, 2024 · 0 comments
Assignees

Comments

@deciduously
Copy link
Member

Currently, a std employs imperfect strategies to differentiate between ld-musl and ld-linux interpreters:

  • Check the file name for the string ld-musl or ld-linux. This strategy is Incorrect when the interpreter file is referred to by ID, we don't have this string.
  • Execute the interpreter with the --help argument and search for the string musl in the resulting stderr. This is always correct, but incurs a wasteful amount of overhead.

Instead, we can parse the ELF header and search for the SONAME field. In the case of glibc, this field will always be set and include the full ld-linux name. For musl, the toolchains we produce will contain ld-musl interpreters which are just symlinks to libc.so. This file does not have SONAME set, and therefore cannot be an ld-linux interpreter. This strategy can be implemented in both std.wrap and the ld proxy.

On Fedora, installing musl via the package manager does produce an actual ELF file with a SONAME containing ld-musl, instead of a symlink. We could consider producing our musl toolchains in this manner as well, but the bootstrap toolchain we obtain from musl.cc will still only contain the symlink, so we will need to handle this case as well.

@deciduously deciduously self-assigned this Mar 25, 2024
deciduously added a commit that referenced this issue Mar 27, 2024
* concatenate blobs in Manifest.write() - closes #16
* remove byteorder, omit itertools from wrapper (minor progress on #13)
* use SONAME to differentiate ld-linux and ld-musl interpreters in ld_proxy (half of #24)
* adopt rust 1.77 features: drop async-recursion, use c-string literal
* add better workspace cargo metadata
* re-enable commented-out test assertions in testMuslWrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant