Skip to content

Commit 16d2446

Browse files
committed
Mention red zone in APE ABI specification
1 parent 41cc053 commit 16d2446

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ape/specification.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,19 @@ APE binaries use the System V ABI, as defined by:
306306

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

309+
### No Red Zone
310+
311+
Actually Portable Executables that have Windows and/or bare metal in
312+
their support vector MUST be compiled using `-mno-red-zone`. This is
313+
because, on Windows, DLLs and other software lurking in the va-space
314+
might use tricks like SetThreadContext() to take control of a thread
315+
whereas on bare metal, it's also generally accepted that kernel-mode
316+
code cannot assume a red zone either due to hardware interrutps that
317+
pull the exact same kinds of stunts.
318+
319+
APE software that only has truly System V ABI conformant OSes (e.g.
320+
Linux) in their support vector MAY use the red zone optimization.
321+
309322
### Thread Local Storage
310323

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

684+
By convention, Cosmopolitan Libc currently generates ELF headers for
685+
x86-64 that are strictly aligned on a 4096-byte page size. On ARM64
686+
Cosmopolitan is currently implemented to always generate ELF headers
687+
aligned on a 16kb page size.
688+
671689
In addition to being page size agnostic, APE software that cares about
672690
working correctly on Windows needs to be aware of the concept of
673691
allocation granularity. While the page size on Windows is generally 4kb

0 commit comments

Comments
 (0)