The C library errno variable is defined in the implicit static data area of the library. This area is identified by __user_libspace(). It occupies part of initial stack space used by the functions that established the runtime stack. The definition of errno is:
(*(volatile int *) __rt_errno_addr())
You can define __rt_errno_addr() if you want to place errno at a user‑defined location instead of the default location identified by __user_libspace(). Also, see The __user_libspace static data area.
The default implementation is a veneer on __user_libspace() that returns the address of the status word. A suitable default definition is given in the C library standard headers.