cosmopolitan/ape
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
..
etc Initial import 2020-06-15 07:18:57 -07:00
lib Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
ape.lds Add APE support for 32-bit programs 2021-02-20 15:58:48 -08:00
ape.mk Improve build system 2021-02-19 23:03:34 -08:00
ape.S Add APE support for 32-bit programs 2021-02-20 15:58:48 -08:00
config.h Auto-generate some documentation 2020-12-26 02:09:07 -08:00
idata.internal.h Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
macros.internal.h Get codebase completely working with LLVM 2021-02-09 02:57:32 -08:00
mz.ansi Initial import 2020-06-15 07:18:57 -07:00
notice.inc Initial import 2020-06-15 07:18:57 -07:00
relocations.h Auto-generate some documentation 2020-12-26 02:09:07 -08:00