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

std.zig.system: fix ELF file search #19749

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

BratishkaErik
Copy link
Contributor

@BratishkaErik BratishkaErik commented Apr 23, 2024

  • Adjust buffer length a bit.
  • Fix detecting if file is a script. Logic below was unreachable, because 99% of scripts failed "At least 255 bytes long" check and were detected as ELF files. It should be "At least 4" instead (minimum value of "ELF magic length" and "smallest possible interpreter path length").
  • Fix parsing interpreter path, when text after shebang:
    1. does not have newline,
    2. has leading spaces and tabs,
    3. separates interpreter and arguments by tab or NUL.
  • Remove empty error set from defaultAbiAndDynamicLinker.

Fixes #19712

 * Adjust buffer length a bit.
 * Fix detecting if file is a script. Logic below was unreachable,
 because 99% of scripts failed "At least 255 bytes long" check and were detected as ELF files.
 It should be "At least 4" instead (minimum value of "ELF magic length" and "smallest possible interpreter path length").
 * Fix parsing interpreter path, when text after shebang:
     1. does not have newline,
     2. has leading spaces and tabs,
     3. separates interpreter and arguments by tab or NUL.
 * Remove empty error set from `defaultAbiAndDynamicLinker`.

Signed-off-by: Eric Joldasov <[email protected]>
@BratishkaErik
Copy link
Contributor Author

Also, if it's possible could you add this to 0.12.1 please?

@andrewrk andrewrk merged commit 857c1d4 into ziglang:master Apr 24, 2024
10 checks passed
@andrewrk
Copy link
Member

Thank you. Cherry-picked into 0.12.x in 6de152e.

@BratishkaErik
Copy link
Contributor Author

Thanks!

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

Successfully merging this pull request may close these issues.

bash: /usr/bin/zig: cannot execute: required file not found
2 participants