From d99607f422597837b9e0ca62795f9d4fac4d5f05 Mon Sep 17 00:00:00 2001 From: Perry Kivolowitz Date: Tue, 7 Feb 2023 10:06:12 -0600 Subject: [PATCH 1/2] added comment about errno in apple silicon --- more/apple_silicon/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/more/apple_silicon/README.md b/more/apple_silicon/README.md index d44469e..bfdd254 100644 --- a/more/apple_silicon/README.md +++ b/more/apple_silicon/README.md @@ -62,6 +62,13 @@ file ends in .S* ## Differences between Apple and Linux +### Getting the address of `errno` + +`errno` is an externally defined `int32_t` used by many "system" +provided APIs to report error conditions back to calling programs. The +macro `ERRNO_ADDR` can be used to converge how Linux and Apple get the +address of the variable (which is left in `x0`). + ### Variadic functions *This is important! Understand this section in order to be able to use From 73b38079cc7e41bed7bc3ecf17cc94edf0393d60 Mon Sep 17 00:00:00 2001 From: Perry Kivolowitz Date: Tue, 7 Feb 2023 10:08:02 -0600 Subject: [PATCH 2/2] making markdownlint happy --- more/apple_silicon/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/more/apple_silicon/README.md b/more/apple_silicon/README.md index bfdd254..d8dc3e7 100644 --- a/more/apple_silicon/README.md +++ b/more/apple_silicon/README.md @@ -2,7 +2,7 @@ This book is written to the Linux calling convention as stated early on. Unfortunately, this means that even if you own an Apple Silicon machine, -which is AARCH64, you'd still need a Linux virtual machine. +which is AARCH64, you'd still need a Linux virtual machine. This didn't sit well with some on reddit and rightfully so. We undertook to develop a way of writing assembly code once and having it work on @@ -149,7 +149,7 @@ stack pointer. This is faster as the addition makes no reference to RAM Apple requires that `x29` be kept as a valid stack frame pointer. The frame pointer should always start out as equal to the stack pointer. However, within the function, the stack pointer is free to change. The -frame pointer must remain fixed so that debuggers always know how to +frame pointer must remain fixed so that debuggers always know how to find the initial stack *frame*. To be Apple compatible, in addition to backing up `x30` also back up