Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: c91a767af1eaf77d48cbe02d42464427c79e675963f5f956cd207beecdffb329
Ticket: 113be1991e7262479a1843f3924540d7a08d8a88
zipfs on mac
User & Date: marc_culler on 2021-01-30 17:41:59
Changes

  1. icomment:
    Appending a zip file to a mach-O binary corrupts the mach-O binary.
    This is because a mach-O binary has structure.  It has a header followed
    by a sequence of load commands.  Some load commands define segments,
    such as __TEXT or __DATA. Some load commands define sections within
    those segments.  The load command which defines a segment specifies
    the offset and size of the segment within the file and within the
    virtual image after loading. The last segment is the __LINKEDIT segment,
    which is reserved for use by the dynamic linker. In the binary file this
    segment is required to extend to the end of the file.  This is no longer
    the case after you append data to the end of the binary.
    
    It is possible to adjust the load commands in the binary so that the
    extra data becomes part of the __LINKEDIT segment, and appears to the
    loader as if it were part of the string table in the LC_SYMTAB section
    of the __LINKEDIT segment.  I am attaching a python script which does
    that, using the pypi package macholib. It is named fix_macho.
    
    If you build the hello world example as described in TIP #430 and run
    $ ./fix_macho hello
    you will get a single file executable which runs and which also can be
    processed by install_name_tool with no errors -- the @bll test passes.
    
    NOTE: Building a "single file executable" for macOS using the recipe in
    the TIP is a **truly pointless exercise**.  The executable that you get
    needs to load the shared library /Library/Frameworks/Tcl.framework/Tcl.
    If that shared library exists, then you could simply run the Tcl script
    with tclsh.  If it does not exist then the executable is useless. It
    will crash because it cannot load the shared library that it depends
    upon.
    
  2. login: "marc_culler"
  3. mimetype: "text/plain"
  4. username: "Marc Culler"