Skip to content

Commit

Permalink
Mention red zone in APE ABI specification
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed Jul 22, 2024
1 parent 41cc053 commit 16d2446
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ape/specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,19 @@ APE binaries use the System V ABI, as defined by:

There are however a few changes we've had to make.

### No Red Zone

Actually Portable Executables that have Windows and/or bare metal in
their support vector MUST be compiled using `-mno-red-zone`. This is
because, on Windows, DLLs and other software lurking in the va-space
might use tricks like SetThreadContext() to take control of a thread
whereas on bare metal, it's also generally accepted that kernel-mode
code cannot assume a red zone either due to hardware interrutps that
pull the exact same kinds of stunts.

APE software that only has truly System V ABI conformant OSes (e.g.
Linux) in their support vector MAY use the red zone optimization.

### Thread Local Storage

#### aarch64
Expand Down Expand Up @@ -668,6 +681,11 @@ converged on a strong consensus of having a page size that's 4096 bytes.
However this convention was never guaranteed. New computers have become
extremely popular, such as Apple Silicon, that use a 16kb page size.

By convention, Cosmopolitan Libc currently generates ELF headers for
x86-64 that are strictly aligned on a 4096-byte page size. On ARM64
Cosmopolitan is currently implemented to always generate ELF headers
aligned on a 16kb page size.

In addition to being page size agnostic, APE software that cares about
working correctly on Windows needs to be aware of the concept of
allocation granularity. While the page size on Windows is generally 4kb
Expand Down

0 comments on commit 16d2446

Please sign in to comment.