mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-20 09:30:31 +00:00
Implement tree-shaking for Python sources
This commit is contained in:
parent
81287b7ec0
commit
44c87b83ff
110 changed files with 899 additions and 1922 deletions
|
@ -69,7 +69,7 @@ struct ElfWriterSymRef elfwriter_linksym(struct ElfWriter *, const char *, int,
|
|||
int);
|
||||
struct ElfWriterSymRef elfwriter_appendsym(struct ElfWriter *, const char *,
|
||||
int, int, size_t, size_t);
|
||||
void elfwriter_yoink(struct ElfWriter *, const char *);
|
||||
void elfwriter_yoink(struct ElfWriter *, const char *, int);
|
||||
void elfwriter_setsection(struct ElfWriter *, struct ElfWriterSymRef, uint16_t);
|
||||
void elfwriter_zip(struct ElfWriter *, const char *, const char *, size_t,
|
||||
const void *, size_t, uint32_t, struct timespec,
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "tool/build/lib/elfwriter.h"
|
||||
|
||||
void elfwriter_yoink(struct ElfWriter *elf, const char *symbol) {
|
||||
void elfwriter_yoink(struct ElfWriter *elf, const char *symbol, int stb) {
|
||||
unsigned char *p;
|
||||
struct ElfWriterSymRef sym;
|
||||
const unsigned char kNopl[8] = "\017\037\004\045\000\000\000\000";
|
||||
p = elfwriter_reserve(elf, 8);
|
||||
memcpy(p, kNopl, sizeof(kNopl));
|
||||
sym = elfwriter_linksym(elf, symbol, ELF64_ST_INFO(STB_GLOBAL, STT_OBJECT),
|
||||
sym = elfwriter_linksym(elf, symbol, ELF64_ST_INFO(stb, STT_OBJECT),
|
||||
STV_HIDDEN);
|
||||
elfwriter_appendrela(elf, sizeof(kNopl) - 4, sym, R_X86_64_32, 0);
|
||||
elfwriter_commit(elf, sizeof(kNopl));
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/elf/def.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/check.h"
|
||||
|
@ -141,7 +142,7 @@ void PullEndOfCentralDirectoryIntoLinkage(struct ElfWriter *elf) {
|
|||
elfwriter_align(elf, 1, 0);
|
||||
elfwriter_startsection(elf, ".yoink", SHT_PROGBITS,
|
||||
SHF_ALLOC | SHF_EXECINSTR);
|
||||
elfwriter_yoink(elf, yoink_);
|
||||
elfwriter_yoink(elf, yoink_, STB_GLOBAL);
|
||||
elfwriter_finishsection(elf);
|
||||
}
|
||||
|
||||
|
|
|
@ -1292,6 +1292,7 @@
|
|||
"STATIC_YOINK"
|
||||
"STATIC_YOINK_SOURCE"
|
||||
"PYTHON_YOINK"
|
||||
"PYTHON_PROVIDE"
|
||||
"STRINGIFY"))
|
||||
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue