Mac: Kernel rejects the execution of compiled binaries on arm64 #6
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	
	No description provided.
		
		Delete branch "%!s()"
	 
	Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Everything works on Intel macs, but the arm64 binaries don't run on Apple Silicon, exiting with
signal: killed (9).The arm64 assembly instructions analyzed with
objdumpare equal betweenas/ldandqproduced binaries.The most likely cause is incorrect Mach-O headers for this platform.
Relevant changes that had no success so far:
cli/q@6e7b60f7bfcli/q@9a3e14bacbcli/q@d657ef04dfIdemailly on GitHub has posted more testing insights:
https://github.com/ldemailly/q/issues/1
Recent changes:
Now this comes up as an error:
Relevant file:
SegCount uint32Documentation on fixups:
https://wwdcnotes.com/documentation/wwdcnotes/wwdc22-110362-link-fast-improve-build-and-launch-times/#Fixups
I suppose the number of segments there must be equal to the total number of segments in the binary.
cli/q@4370ba885ddoes this.Now we're getting:
Update: Fixed dyld_info complaints
Little update: Changed the code signature SHA256 hashing. Previously got 83... as a hash, now the hello world hash is e7... different. I removed the padding for the last memory page because I saw that Go doesn't do it in their source.
Hash can be checked with
codesign -dv --verbose=4on an executable.More information:
Latest commit implements a strict flag that KILLs the process on invalid signatures even on x86-64 macs.
I needed to enable this strictness because arm macs have it by default, but it's disabled on x86-64.
So I needed it to be reproducible on my machine.
Did it work?
Tried old signature algorithm: Sigkill (9)
Tried new signature algorithm: Runs normally.
I've also completely reimplemented the signature algorithm and at least x86-64 is happy with them.
My only worry is that I might have to set the page size to a static 4k because some docs mention that.
Right now the page size for the signature is dynamic, so it will be 16k on an arm Mac - but that might be wrong behavior.
Go uses 4k. I'm willing to test 16k, and if that fails, go to a static 4k.
Fixed after
cli/q@7155c7bfd1.Thank you so much to all these wonderful people who helped debug this problem:
@ed wrote in #6 (comment):
Glad to help! The addition of two characters fixed it, typical 💯