| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Unison.Runtime.Bundle
Description
program (unisonrt/README.md, Bundles). ucm's bundle command and
`unisonrt bundle` write them; unisonrt, finding a program in its own
executable, runs it.
The program goes where the executable's format allows:
- Mach-O (macOS): in the section
UNISON,uc, inside the image, so that the code signature covers it (Unison.Runtime.Bundle.MachO). The section holdsbundleMagic, the program's length (8 bytes, little-endian) and the program; in a plain unisonrt it holds 16 zero bytes (unisonrt/bundle-section). - Anything else (ELF, PE): after the end of the executable, followed by a
16-byte trailer, the program's offset (8 bytes, little-endian) and
bundleMagic. The loaders ignore bytes after the end of the file's contents.
unisonrt's main.c tells a bundle apart the same way, to pass every argument to the program.
Synopsis
- readBundle :: FilePath -> IO (Maybe ByteString)
- bundledProgram :: ByteString -> Maybe ByteString
- writeBundle :: FilePath -> ByteString -> FilePath -> IO (Either String FilePath)
- signExecutable :: FilePath -> IO (Either String ())
- makeExecutable :: FilePath -> IO ()
Documentation
readBundle :: FilePath -> IO (Maybe ByteString) Source #
The program this running executable carries, if it is a bundle. On macOS the section is in memory already (cbits/bundle.c); elsewhere only the trailer and the program are read from the file at this path.
bundledProgram :: ByteString -> Maybe ByteString Source #
The program in the bytes of an executable, if it is a bundle
writeBundle :: FilePath -> ByteString -> FilePath -> IO (Either String FilePath) Source #
Writes a bundle of the program, from the file of a unisonrt (a bundle
or not), as an executable that anyone can run, and says where it wrote
it: on Windows a name without an extension gets .exe.
signExecutable :: FilePath -> IO (Either String ()) Source #
Signs a rewritten executable again, ad hoc: macOS on arm64 runs nothing whose signature doesn't match it. It can be signed again with a real identity afterwards. Elsewhere there is no signature.
makeExecutable :: FilePath -> IO () Source #
Lets everyone run it, as the linker leaves an executable