Here's why we got those `Killed: 11` failures on MacOS after modifying the contentns of the redbean.com executable. If you were inserting a small file, such as a HelloWorld.html file, then InfoZIP might have decreased the size of the executable to less than what the Mach-O section had been expecting. That's because when zipobj.com put things like time zone data in the executable, it aligned each zip file entry on a 64-byte boundary, simply for the sake of readability in binary dumps. But when InfoZIP edited the file it would rewrite every entry using ZIP's usual 2-byte alignment. Thus causing shrinkage. The solution was to reconfigure the linker script so that zip file bits that get put into the executable at link-time, such as timezone data, aren't officially part of the executable image, i.e. we don't want the operating system to load that part. The original decision to put the linked zip files into the .data section was mostly made so that when the executable was run in its .com.dbg form it would still have the zip entries be accessible, even though there was tons of GNU debug data following the central directory. We're not going to be able to do that. The .com executable should be the canonical executable. We have really good tools for automatically attaching and configuring GDB correctly with debug symbols even when the .com is run. We'll have to rely on those in cases where zip embedding is used. See #53 See #54 See #68
50 lines
2.5 KiB
ArmAsm
50 lines
2.5 KiB
ArmAsm
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
|
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
|
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
|
│ │
|
|
│ Permission to use, copy, modify, and/or distribute this software for │
|
|
│ any purpose with or without fee is hereby granted, provided that the │
|
|
│ above copyright notice and this permission notice appear in all copies. │
|
|
│ │
|
|
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
|
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
|
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
|
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
|
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
|
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
|
#include "libc/macros.h"
|
|
#include "ape/relocations.h"
|
|
#include "libc/zip.h"
|
|
|
|
// ZIP Central Directory.
|
|
.section .zip.3,"",@progbits
|
|
.hidden __zip_start
|
|
.globl __zip_start
|
|
.type __zip_start,@object
|
|
.align kZipCdirAlign
|
|
__zip_start:
|
|
.previous/*
|
|
...
|
|
decentralized content
|
|
...
|
|
*/.section .zip.5,"",@progbits
|
|
.align kZipCdirAlign
|
|
__zip_end:
|
|
.long kZipCdirHdrMagic # magic
|
|
.short 0 # disk
|
|
.short 0 # starting disk
|
|
.short v_zip_records # records on disk
|
|
.short v_zip_records # records
|
|
.long v_zip_cdirsize # size of central directory
|
|
.long RVA(__zip_start) # central directory offset
|
|
.short v_zip_commentsize # comment size
|
|
.endobj __zip_end,globl,hidden
|
|
.weak v_zip_records
|
|
.weak v_zip_cdirsize
|
|
.weak v_zip_commentsize
|
|
.previous
|