-
Notifications
You must be signed in to change notification settings - Fork 107
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
neko-booted binaries cannot be processed by install_name_tool on Mac #130
Comments
Look like we have to fix the Mach-O headers in some way. |
Homebrew maintainer here. I know almost nothing about Neko (though I'm curious and interested to learn), but I know a good deal of Mach-O internals. Feel free to ping me if I can be of any help in resolving this issue and making Neko produce valid Mach-O binaries. |
@UniqMartin Your help would be fantastic! The
After all these are written, on Linux, it update the ELF header. Now, on Mac, we have to update the Mach-O header in some way, too. |
I'm afraid this simple approach won't work for Mach-O binaries, at least if your goal is to produce valid Mach-O files that can be safely manipulated by utilities like
Given the above constrains, here's how I think a
Does this make sense? Does this approach meet all the requirements you might have?
How do you ensure that the |
Thanks for the details! @ncannasse I think we need your input here. |
The ELF patching was provided by @kulick, and yes handling other binary formats looks like it will require a specific implementation. |
@UniqMartin Is there any C library that can help us achieve the linking part such that we don't have to depend on a C compiler? |
@andyli If there is, I'm unfortunately not aware of any that could be easily leveraged. We basically only need the linker part (I just used If spawning an external process is acceptable, I think relying on the user's already installed linker or falling back to a |
In a perfect world, In a8c71ad, I've added a new feature, which is I'm leaving this issue open for future contributor to fix the original |
That's quite a big and invasive change. 😉 The end result should be pretty similar to putting the byte code into its own section, teaching the VM how to look up the address of that section, and running it. |
Yes, but at least it is file format independent and less magical (to me). : ) |
Sorry for the slow response. Hi, Andy! :) Yeah, these kinda problems sorta fall out of the current design for making free standing neko bytecode-based executables by just "tacking the bytecode on at the end". That isn't really a safe thing to do with modern OSes and their executable formats/runtime execution loaders. The solution that I built for Linux ELF was complicated and annoying, but I guess better than things not working. I like your solution, Andy, in that it is much more robust and less sensitive to these ABI issues. That said, it is more difficult to use and requires anyone that wants to make a free standing executable from neko bytecode to have a toolchain and a basic understanding of how to use your new output and build it into code. Using it to create the neko build freestanding binaries is a great solution, IMO. Your solution is obviously not mutually exclusive to the strategy that I employed and if someone with more knowledge of the Mac OS X ABI wanted to try to make that neko interpreter smarter, they could. I looked at implementing the Linux ELF solution with libbfd, but I punted on that since that library is significantly larger than the neko interpreter itself. It seemed too painful to drop in a library that would make the interpreter sooo much bigger, so I just hacked up a "light" version of the functionality. :| |
This affects the homebrew package: Homebrew/homebrew-core#982
@kulick: Do you think that's something can be solved by properly handling ELF (or equivalent header thing) on Mac?
The text was updated successfully, but these errors were encountered: