-
Notifications
You must be signed in to change notification settings - Fork 7
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
Initial Linux support #97
Conversation
Thanks. As for Similar problems also occurred when supporting Linux with ELFKit, but it seems that for some header files it is necessary to use |
Since they compile, they can be useful to make a mach-o loader on Linux so I think it's okay to leave them enabled.
Now working on that (I also noticed the use of Apple's Crypto library bumps the requirements from macOS 10.13 to 10.15, is that okay for you?). |
Thanks @Dadoum .
That's true.
I thought the way it was written when using Apple's Crypto library was simpler and better than the current implementation, so the required OS version bump was not a problem for me. |
guard let baseAddress = $0.baseAddress else { | ||
return nil | ||
} | ||
switch hashType { | ||
switch hashType { | ||
case .sha1: | ||
var digest = [UInt8](repeating: 0, count: Int(CC_SHA1_DIGEST_LENGTH)) | ||
CC_SHA1(baseAddress, length, &digest) | ||
return Data(digest) | ||
return Data(Insecure.SHA1.hash(data: data)) | ||
case .sha256, .sha256_truncated: | ||
var digest = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH)) | ||
CC_SHA256(baseAddress, length, &digest) | ||
return Data(digest) | ||
return Data(SHA256.hash(data: data)) | ||
case .sha384: | ||
var digest = [UInt8](repeating: 0, count: Int(CC_SHA384_DIGEST_LENGTH)) | ||
CC_SHA384(baseAddress, length, &digest) | ||
return Data(digest) | ||
return Data(SHA384.hash(data: data)) |
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.
👍
Hello, @Dadoum |
Yes you can. I tried to work with the updated branch but my swift compiler now crashes when trying to compile it (I need to find a fix, or to wait for a swift update for fedora) |
It was not possible to push additional commits to this pull request. In my environment, I was able to build on both MacOS and Ubuntu with the following changes. 0001-Move-c-headers-for-linux-platforms.patch |
I can't test it unfortunately because I can't build PrebuiltLoader.swift unfortunately. I tried on Swift 5 and 6 on my main Fedora machine. Will commit your changes though. For the record, here is a snippet of what outputs Swift 6 experimental dev version from Ubuntu on my computer:
|
It's due to the bitfields used in the structure! |
I also used bit field in dyld_cache_format.h. I am using the following environment and it works.
If you go to the MachOKit directory and then run the following command, the MachOKit-enabled interpreter will start up. swift run -repl The interpreter was then tested by typing: import Foundation
import MachOKit
let machO = MachOFile(url: URL(fileURLWithPath: "Path To mach-o file")) |
Apple just released Swift 6, with a fedora build that does no longer have the issue. |
Co-authored-by: p-x9 <[email protected]>
Hello @Dadoum |
It is not a problem for me, you can merge it. |
OK, Thanks for your much work. |
I just adapted part of XNU headers in the folder. Hopefully I didn't break anything on macOS.
Addresses part of #11