Rewrite .zip.o file linker

This change takes an entirely new approach to the incremental linking of
pkzip executables. The assets created by zipobj.com are now treated like
debug data. After a .com.dbg is compiled, fixupobj.com should be run, so
it can apply fixups to the offsets and move the zip directory to the end
of the file. Since debug data doesn't get objcopy'd, a new tool has been
introduced called zipcopy.com which should be run after objcopy whenever
a .com file is created. This is all automated by the `cosmocc` toolchain
which is rapidly becoming the new recommended approach.

This change also introduces the new C23 checked arithmetic macros.
This commit is contained in:
Justine Tunney 2023-06-10 09:15:19 -07:00
parent f6407d5f7c
commit 8ff48201ca
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
125 changed files with 1056 additions and 928 deletions

View file

@ -19,31 +19,28 @@
#include "libc/macros.internal.h"
#include "ape/relocations.h"
#include "libc/zip.internal.h"
.section .zip.eocd,"",@progbits
// ZIP Central Directory.
.section .zip.3,"",@progbits
.hidden __zip_start
// ZIP End Of Central Directory (EOCD) record.
.globl __zip_start
.type __zip_start,@object
__zip_start:
.previous/*
...
decentralized content
...
*/.section .zip.5,"",@progbits
__zip_end:
.long kZipCdirHdrMagic // magic
__zip_eocd: // let symbol be discarded
.long kZipCdirHdrMagicTodo // magic (scan backwards for this)
.short 0 // disk
.short 0 // starting disk
.short v_zip_records // number of records on disk
.short v_zip_records // records
.long v_zip_cdirsize // size of central directory
.long v_zip_cdoffset // central directory offset
.short v_zip_commentsize // comment size
.endobj __zip_end,globl,hidden
.previous
.short 0 // number of records on disk
.short 0 // records
.endobj __zip_eocd,globl
.weak v_zip_records
.weak v_zip_cdirsize
.weak v_zip_cdoffset
.weak v_zip_commentsize
__zip_eocd.size:
.weak __zip_cdir_size
.long __zip_cdir_size
.endobj __zip_eocd.size
__zip_eocd.offset:
.long 0
.endobj __zip_eocd.offset
__zip_eocd.commentsize:
.short 0
.endobj __zip_eocd.commentsize