Fix breakages in Linux-only build modes

- compile.com now polyfills -march=native which gcc/clang removed
- Guarantee zero Windows code is linked into non-Windows binaries
- MODE=tinylinux binaries are now back to being as tiny as ~4kb
- Improve the runtime's stack allocation / alignment hack
- GitHub Actions now tests Linux modes for assurance
This commit is contained in:
Justine Tunney 2023-07-09 19:47:46 -07:00
parent 0e4c828a8e
commit 3dc86ce154
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
32 changed files with 283 additions and 104 deletions

View file

@ -275,6 +275,7 @@ SECTIONS {
}
ape_stack_memsz = DEFINED(ape_stack_memsz) ? ape_stack_memsz : APE_STACKSIZE;
ape_stack_memsz2 = ape_stack_memsz * 2;
_tls_size = _tbss_end - _tdata_start;
_tdata_size = _tdata_end - _tdata_start;
_tbss_size = _tbss_end - _tbss_start;

View file

@ -794,7 +794,7 @@ ape_loader_end:
.stub ape_stack_vaddr,quad // is mmap()'d with MAP_FIXED
.stub ape_stack_paddr,quad // ignored
.stub ape_stack_filesz,quad // ignored
.stub ape_stack_memsz,quad // is mmap(size) argument
.stub ape_stack_memsz2,quad // is mmap(size) argument
.stub ape_stack_align,quad // must be 16+
#if SupportsOpenbsd() || SupportsNetbsd()
@ -1718,7 +1718,7 @@ ape_grub_entry:
αcτµαlly pδrταblε εxεcµταblε § cosmopolitan libc runtime runtime
*/
kernel: movabs $ape_stack_vaddr,%rsp
add $ape_stack_memsz,%rsp
add $ape_stack_memsz2,%rsp
movl $0,0x7b000 // unmap null 2mb
#if USE_SYMBOL_HACK
.byte 0x0f,0x1f,0207 // nop rdi binbase

View file

@ -317,7 +317,6 @@ SECTIONS {
__privileged_start = .;
*(.privileged)
__privileged_end = .;
. += . > 0 ? CODE_GRANULE : 0;
KEEP(*(.ape.pad.text))
. = ALIGN(CONSTANT(COMMONPAGESIZE));
@ -344,9 +343,11 @@ SECTIONS {
/*BEGIN: read-only data that's only needed for initialization */
#if SupportsWindows()
/* Windows DLL Import Directory */
KEEP(*(.idata.ro));
KEEP(*(SORT_BY_NAME(.idata.ro.*)))
#endif
. = ALIGN(__SIZEOF_POINTER__);
__init_array_start = .;
@ -405,7 +406,9 @@ SECTIONS {
.data . : {
/*BEGIN: Read/Write Data */
#if SupportsWindows()
KEEP(*(SORT_BY_NAME(.piro.data.sort.iat.*)))
#endif
/*BEGIN: NT FORK COPYING */
KEEP(*(.dataprologue))
*(.data .data.*)
@ -517,6 +520,11 @@ SECTIONS {
}
/DISCARD/ : {
#if !SupportsWindows()
*(.idata.ro);
*(.idata.ro.*)
*(.piro.data.sort.iat.*)
#endif
*(__patchable_function_entries)
*(__mcount_loc)
*(.discard)
@ -569,6 +577,7 @@ ape_stack_vaddr = DEFINED(ape_stack_vaddr) ? ape_stack_vaddr : 0x700000000000;
ape_stack_paddr = ape_ram_paddr + ape_ram_filesz;
ape_stack_filesz = 0;
ape_stack_memsz = DEFINED(ape_stack_memsz) ? ape_stack_memsz : APE_STACKSIZE;
ape_stack_memsz2 = ape_stack_memsz * 2;
ape_stack_align = 16;
ape_note_offset = ape_cod_offset + (ape_note - ape_cod_vaddr);