Cannot codesign on macOS: save-lisp-and-die produces non-conforming MachO binaries
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
New
|
Undecided
|
Unassigned |
Bug Description
1. The binaries produced by SAVE-LISP-AND-DIE do not conform strictly to the MachO format, and as such they cannot be code-signed on macOS.
2.1 Produce a binary:
$ sbcl --eval "(defun hi () (print 'hi))" --eval "(sb-ext:
This is SBCL 2.0.0, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
WARNING: System definition file #P"/Users/
To load "cl-ppcre":
Load 1 ASDF system:
cl-ppcre
; Loading "cl-ppcre"
..
[undoing binding stack and other enclosing state... done]
[performing final GC... done]
[defragmenting immobile space... (fin,inst,
[saving current Lisp image into hi:
writing 0 bytes from the read-only space at 0x20000000
writing 384 bytes from the static space at 0x20100000
writing 31031296 bytes from the dynamic space at 0x1000000000
writing 2080768 bytes from the immobile space at 0x20300000
writing 12668928 bytes from the immobile space at 0x21b00000
done]
$ ./hi
HI %
2.2 Try to codesign it:
$ codesign --no-strict -s "YOUR-SIGNING-ID" ./hi
/Applications/
3. sbcl --version
SBCL 2.0.0
4. uname -a
Darwin skilbecklaptop.
You would have to remove ':executable t' from the save-lisp-and-die to produce a conforming binary. /bugs.launchpad .net/sbcl/ +bug/310108
Basically we cheat by assuming that copying arbitrary bytes to the end of an executable file just works. There is other tooling that doesn't like it either, e.g. 'strip'.
See https:/