[racket] Adding OS X linker options using raco exe

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Oct 22 09:45:14 EDT 2010

`raco exe' doesn't use the system linker (in the sense of `ld') at all.
It clones an existing binary and then adds an extra load command by
manipulating the Mach-O format directly. Flags added by `++exf',
meanwhile, are flags to the embedded `racket' or `gracket' in the
executable.

I'm not sure how you'd add a section to an already-linked executable.
Maybe `libtool' can do that. It's possible that you could adapt the
code in "collects/compiler/private/mach-o.rkt" to add a section, but
I'm not sure how difficult it is to add a section as opposed to a load
command.

It may be easiest to change the linker command in the Makefile when
building racket or gracket to add the `-sectcreate' flag. Then, when
`raco exe' clones the binary, your extra section would be there.

At Thu, 21 Oct 2010 14:58:13 +0100, Norman Gray wrote:
> 
> Greetings.
> 
> I'm trying to code-sign a Racket standalone server on OS X.  I've got a bit 
> stuck.
> 
> I'm following the instructions at 
> <http://developer.apple.com/library/mac/#documentation/Security/Conceptual/Code
> SigningGuide/Procedures/Procedures.html%23//apple_ref/doc/uid/TP40005929-CH4-SW
> 2>.  These include the instruction to create a suitable section in an output 
> binary by adding arguments to the linker options:
> 
>     -sectcreate __TEXT __info_plist Info.plist_path
> 
> (my understanding is that this extra section is examined later by the actual 
> code-signing utility).
> 
> I tried doing that using the ++exf options to raco exe:
> 
> % "/Data/LocalApplications/Racket/Racket v5.0.1/bin/raco" exe -v -o 
> build/simbad-lod ++exf -sectcreate ++exf __TEXT ++exf __info_plist ++exf 
> /Data/tools/simbad-lod/share/Info.plist --exf-show server.ss
> Flags to embed: ("-U" "--" "-sectcreate" "__TEXT" "__info_plist" 
> "/Data/tools/simbad-lod/share/Info.plist")
> create-embedding-executable: command line too long: '("-U" "--" "-sectcreate" 
> "__TEXT" "__info_plist" "/Data/tools/simbad-lod/share/Info.plist")
> 
>  === context ===
> /Data/LocalApplications/Racket/Racket 
> v5.0.1/collects/compiler/embed-unit.rkt:1019:4: core
> /Data/LocalApplications/Racket/Racket 
> v5.0.1/collects/compiler/commands/exe.rkt: [running body]
> /Data/LocalApplications/Racket/Racket v5.0.1/collects/raco/raco.rkt: [running 
> body]
> /Data/LocalApplications/Racket/Racket v5.0.1/collects/raco/main.rkt: [running 
> body]
> 
> %
> 
> ...without success.  The only place that ++exf is obviously documented is in 
> 'raco help exe', so I'm not sure I'm doing this correctly, and the error 
> message 'command line too long' is a little opaque.
> 
> Can anyone point me in the right direction?
> 
> Best wishes,
> 
> Norman
> 
> 
> -- 
> Norman Gray  :  http://nxg.me.uk
> 
> _________________________________________________
>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/users


Posted on the users mailing list.