mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +00:00
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:
parent
f6407d5f7c
commit
8ff48201ca
125 changed files with 1056 additions and 928 deletions
2
third_party/python/launch.c
vendored
2
third_party/python/launch.c
vendored
|
@ -41,7 +41,7 @@
|
|||
|
||||
#define USE_COSMO_CRASH MODE_DBG + 0
|
||||
|
||||
STATIC_YOINK("zip_uri_support");
|
||||
STATIC_YOINK("zipos");
|
||||
PYTHON_YOINK("_bootlocale");
|
||||
PYTHON_YOINK("_locale");
|
||||
PYTHON_YOINK("encodings.aliases");
|
||||
|
|
17
third_party/python/pyobj.c
vendored
17
third_party/python/pyobj.c
vendored
|
@ -234,7 +234,6 @@ static bool nocompress;
|
|||
static bool isunittest;
|
||||
static bool insertrunner;
|
||||
static bool insertlauncher;
|
||||
static uint64_t image_base;
|
||||
static int strip_components;
|
||||
static struct ElfWriter *elf;
|
||||
static const char *path_prefix;
|
||||
|
@ -246,7 +245,6 @@ static void
|
|||
GetOpts(int argc, char *argv[])
|
||||
{
|
||||
int opt;
|
||||
image_base = IMAGE_BASE_VIRTUAL;
|
||||
path_prefix = ".python";
|
||||
while ((opt = getopt(argc, argv, "hnmtr0Bb:O:o:C:P:Y:")) != -1) {
|
||||
switch (opt) {
|
||||
|
@ -279,9 +277,6 @@ GetOpts(int argc, char *argv[])
|
|||
case 'C':
|
||||
strip_components = atoi(optarg);
|
||||
break;
|
||||
case 'b':
|
||||
image_base = strtoul(optarg, NULL, 0);
|
||||
break;
|
||||
case 'Y':
|
||||
yoinks.p = realloc(yoinks.p, ++yoinks.n * sizeof(*yoinks.p));
|
||||
yoinks.p[yoinks.n - 1] = xstrdup(optarg);
|
||||
|
@ -656,22 +651,18 @@ Objectify(void)
|
|||
if (ispkg) {
|
||||
elfwriter_zip(elf, zipdir, zipdir, strlen(zipdir),
|
||||
pydata, 0, 040755, timestamp, timestamp,
|
||||
timestamp, nocompress, image_base,
|
||||
kZipCdirHdrLinkableSize);
|
||||
timestamp, nocompress);
|
||||
}
|
||||
if (!binonly) {
|
||||
elfwriter_zip(elf, gc(xstrcat("py:", modname)), zipfile,
|
||||
strlen(zipfile), pydata, pysize, st.st_mode, timestamp,
|
||||
timestamp, timestamp, nocompress, image_base,
|
||||
kZipCdirHdrLinkableSize);
|
||||
timestamp, timestamp, nocompress);
|
||||
}
|
||||
elfwriter_zip(elf, gc(xstrcat("pyc:", modname)), gc(xstrcat(zipfile, 'c')),
|
||||
strlen(zipfile) + 1, pycdata, pycsize, st.st_mode, timestamp,
|
||||
timestamp, timestamp, nocompress, image_base,
|
||||
kZipCdirHdrLinkableSize);
|
||||
timestamp, timestamp, nocompress);
|
||||
elfwriter_align(elf, 1, 0);
|
||||
elfwriter_startsection(elf, ".yoink", SHT_PROGBITS,
|
||||
SHF_ALLOC | SHF_EXECINSTR);
|
||||
elfwriter_startsection(elf, ".yoink", SHT_PROGBITS, 0);
|
||||
if (!(rc = AnalyzeModule(modname))) {
|
||||
if (*path_prefix && !IsDot()) {
|
||||
elfwriter_yoink(elf, gc(xstrcat(path_prefix, "/")), STB_GLOBAL);
|
||||
|
|
2
third_party/python/python.mk
vendored
2
third_party/python/python.mk
vendored
|
@ -4194,7 +4194,7 @@ $(THIRD_PARTY_PYTHON_HELLO_OBJS): private PYFLAGS += -C2 -m
|
|||
# this directory entry is at the tip of the tree
|
||||
# therefore building it requires special care
|
||||
o/$(MODE)/third_party/python/Lib/.zip.o: third_party/python/.python
|
||||
@$(COMPILE) -wAZIPOBJ $(ZIPOBJ) -b$(IMAGE_BASE_VIRTUAL) -C2 $(OUTPUT_OPTION) third_party/python/.python
|
||||
@$(COMPILE) -wAZIPOBJ $(ZIPOBJ) -C2 $(OUTPUT_OPTION) third_party/python/.python
|
||||
|
||||
# these need to be explictly defined because landlock make won't sandbox
|
||||
# prerequisites with a trailing slash.
|
||||
|
|
2
third_party/python/runpythonmodule.c
vendored
2
third_party/python/runpythonmodule.c
vendored
|
@ -55,7 +55,7 @@
|
|||
STATIC_STACK_SIZE(0x100000);
|
||||
|
||||
STATIC_YOINK("__die");
|
||||
STATIC_YOINK("zip_uri_support");
|
||||
STATIC_YOINK("zipos");
|
||||
|
||||
PYTHON_YOINK("cosmo");
|
||||
PYTHON_YOINK("_locale");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue