|
| 1 | +# `fixed-x18` |
| 2 | + |
| 3 | +This option prevents the compiler from using the x18 register. It is only |
| 4 | +supported on aarch64. |
| 5 | + |
| 6 | +From the [ABI spec][arm-abi]: |
| 7 | + |
| 8 | +> X18 is the platform register and is reserved for the use of platform ABIs. |
| 9 | +> This is an additional temporary register on platforms that don't assign a |
| 10 | +> special meaning to it. |
| 11 | +
|
| 12 | +This flag only has an effect when the x18 register would otherwise be considered |
| 13 | +a temporary register. When the flag is applied, x18 is always a reserved |
| 14 | +register. |
| 15 | + |
| 16 | +This flag is intended for use with the shadow call stack sanitizer. Generally, |
| 17 | +when that sanitizer is enabled, the x18 register is used to store a pointer to |
| 18 | +the shadow stack. Enabling this flag prevents the compiler from overwriting the |
| 19 | +shadow stack pointer with temporary data, which is necessary for the sanitizer |
| 20 | +to work correctly. |
| 21 | + |
| 22 | +Currently, the `-Zsanitizer=shadow-call-stack` flag is only supported on |
| 23 | +platforms that always treat x18 as a reserved register, and the `-Zfixed-x18` |
| 24 | +flag is not required to use the sanitizer on such platforms. However, the |
| 25 | +sanitizer may be supported on targets where this is not the case in the future. |
| 26 | + |
| 27 | +It is undefined behavior for `-Zsanitizer=shadow-call-stack` code to call into |
| 28 | +code where x18 is a temporary register. On the other hand, when you are *not* |
| 29 | +using the shadow call stack sanitizer, compilation units compiled with and |
| 30 | +without the `-Zfixed-x18` flag are compatible with each other. |
| 31 | + |
| 32 | +[arm-abi]: https://developer.arm.com/documentation/den0024/a/The-ABI-for-ARM-64-bit-Architecture/Register-use-in-the-AArch64-Procedure-Call-Standard/Parameters-in-general-purpose-registers |
0 commit comments