cosmopolitan/libc/runtime
Justine Tunney face6b61d5 Add APE support for 32-bit programs
This is an experimental proof of concept demo:

    make -j8 o//examples/i386.i386.com
    o//examples/i386.i386.com --32
    echo $?  # <-- prints main32's argc parameter

Please note there's no libc support at the moment. This change is just
for fun and shouldn't be interpreted as intent to support. Having this
project on the whole support i386 would be tough because the calling
conventions are so different. There really isn't much in the way of low
hanging fruit opportunities to do something like NOP out REX prefixes
and call it a day. It'd likely need disjoint builds or possibly better
yet really cleverly crafted code generation in //third_party/chibicc!

Another challenge is is that Linux changed its SYSCALL ordinals when it
migrated from i386 to x86_64. Linux used to use the same magic numbers
as everyone else for functions like exit/write/read/etc. BSDs on the
other hand didn't pointlessly renumber things. So we'd need to find a
way to define the ordinals in libc/sysv/syscalls.sh twice for Linux. The
same goes for other ISAs too. Especially MIPS. For the Linux Kernel
alone, syscall magic numbers and data structure layouts are totally
different, and that's likely the case for other ISAs on other operating
systems too. Probably because ISA code historically got contributed to
open source by the companies that made the chips. Ulrich Drepper wrote
an amusing essay on the subject some years back.
2021-02-20 15:58:48 -08:00
..
abort-nt.c Remove dollars from system call support symbols 2021-02-03 19:35:29 -08:00
abort.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
arch_prctl.c Elevate .text.syscall to .privileged 2021-02-06 04:49:22 -08:00
arememoryintervalsok.c Eliminate some flakes 2021-02-03 06:25:27 -08:00
assertfail.c Elevate .text.syscall to .privileged 2021-02-06 04:49:22 -08:00
atexit.c Change license 2020-12-27 17:18:44 -08:00
brk.c Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
buffer.h Initial import 2020-06-15 07:18:57 -07:00
carsort.h Add x86_64-linux-gnu emulator 2020-08-25 04:43:42 -07:00
carsort100.c Change license 2020-12-27 17:18:44 -08:00
carsort1000.c Change license 2020-12-27 17:18:44 -08:00
clearenv.c Change license 2020-12-27 17:18:44 -08:00
close_s.c Change license 2020-12-27 17:18:44 -08:00
closesymboltable.c Change license 2020-12-27 17:18:44 -08:00
construct.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
cosmo.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
crt32.S Add APE support for 32-bit programs 2021-02-20 15:58:48 -08:00
cxaatexit.c Eliminate some flakes 2021-02-03 06:25:27 -08:00
describeos.c Change license 2020-12-27 17:18:44 -08:00
directmap.c Apply some touchups 2021-02-07 07:02:46 -08:00
directmap.h Write more memory mapping tests 2021-02-04 18:24:33 -08:00
directmapnt.c Write more memory mapping tests 2021-02-04 18:24:33 -08:00
dsohandle.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
exit.c Fix some more build issues (#43) 2021-02-20 12:39:39 -08:00
exit2.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
exit3.S Trim down executable sizes 2021-02-11 08:37:18 -08:00
ezmap.c Change license 2020-12-27 17:18:44 -08:00
ezmap.internal.h Improve documentation 2020-12-27 07:02:35 -08:00
findcombinary.c Change license 2020-12-27 17:18:44 -08:00
finddebugbinary.c Fix some more build issues (#43) 2021-02-20 12:39:39 -08:00
findmemoryinterval.c Eliminate some flakes 2021-02-03 06:25:27 -08:00
fork-nt.c Write more memory mapping tests 2021-02-04 18:24:33 -08:00
fork.c Apply some touchups 2021-02-07 07:02:46 -08:00
fpreset.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
free_s.c Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
ftrace-hook.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
ftrace.c Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
g_argc.S Change license 2020-12-27 17:18:44 -08:00
gc.h wip vscode intellisense support 2021-02-02 07:29:00 -05:00
getdosargv.c Eliminate some flakes 2021-02-03 06:25:27 -08:00
getdosenviron.c Eliminate some flakes 2021-02-03 06:25:27 -08:00
getpagesize.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
grow.c Change license 2020-12-27 17:18:44 -08:00
hook.greg.c Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
init.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
internal.h Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
interruptiblecall.c Improve dead code elimination 2021-02-08 04:04:42 -08:00
interruptiblecall.h Initial import 2020-06-15 07:18:57 -07:00
isheap.c Change license 2020-12-27 17:18:44 -08:00
issetugid.c Change license 2020-12-27 17:18:44 -08:00
jmpstack.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
ldso.c Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
mapanon.c Change license 2020-12-27 17:18:44 -08:00
mapelfread.c Change license 2020-12-27 17:18:44 -08:00
memtrack.c Eliminate some flakes 2021-02-03 06:25:27 -08:00
memtrack.h Make Cosmopolitan ANSI C89 compatible 2021-02-03 17:48:59 -08:00
memtracknt.c Eliminate some flakes 2021-02-03 06:25:27 -08:00
mmap.c Make mmap() work better 2021-02-03 00:10:12 -08:00
mmi.c Change license 2020-12-27 17:18:44 -08:00
mremap.c Change license 2020-12-27 17:18:44 -08:00
msync-nt.c Remove dollars from system call support symbols 2021-02-03 19:35:29 -08:00
msync.c Remove dollars from system call support symbols 2021-02-03 19:35:29 -08:00
munmap.c Remove dollars from system call support symbols 2021-02-03 19:35:29 -08:00
opensymboltable.c Change license 2020-12-27 17:18:44 -08:00
peekall.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
print.greg.c Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
printmemoryintervals.c Change license 2020-12-27 17:18:44 -08:00
progname.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
program_invocation_short_name.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
pthread.c Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
runtime.h Improve dead code elimination 2021-02-08 04:04:42 -08:00
runtime.mk Apply some touchups 2021-02-07 07:02:46 -08:00
setstack.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
stackchkfail.c Elevate .text.syscall to .privileged 2021-02-06 04:49:22 -08:00
stackchkfaillocal.c Change license 2020-12-27 17:18:44 -08:00
symbolic.h wip on intellisense (again) 2021-02-02 11:14:45 -05:00
symbols.internal.h Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
sysconf.c Change license 2020-12-27 17:18:44 -08:00
sysconf.h Add x86_64-linux-gnu emulator 2020-08-25 04:43:42 -07:00
untrackmemoryintervals.c Improve dead code elimination 2021-02-08 04:04:42 -08:00
valist.c Change license 2020-12-27 17:18:44 -08:00
valist.h Further refine documentation 2020-12-27 17:05:03 -08:00
vfork.S Trim down executable sizes 2021-02-11 08:37:18 -08:00
weakfree.S Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
winmain.greg.c Trim down executable sizes 2021-02-11 08:37:18 -08:00