Static data refers to persistent read/write data that is not
stored on the stack or the heap. This persistent data can be external
or internal in scope, and is:
at a fixed address, when compiled with --apcs
/norwpi
at a fixed address relative to the static base,
register r9, when compiled with --apcs
/rwpi.
Libraries that use static data might be reentrant, but this
depends on their use of the __user_libspace static
data area, and on the build options you choose:
When compiled with --apcs /norwpi, read/write
static data is addressed in a position-dependent fashion. This is
the default. Code from these variants is single-threaded because
it uses read/write static data.
When compiled with --apcs /rwpi,
read/write static data is addressed in a position-independent fashion
using offsets from the static base register sb.
Code from these variants is reentrant and can be multithreaded if
each thread uses a different static base value.
The following describes how the C libraries use static data:
The default floating-point arithmetic libraries fz_* and fj_* do
not use static data and are always reentrant. However, the f_* and g_* libraries
do use static data.
All statically-initialized data in the C libraries
is read-only.
All writable static data is zero initialized.
Most C library functions use no writable static
data and are reentrant whether built with default build options, --apcs
/norwpi or reentrant build options, --apcs /rwpi.
Some functions have static data implicit in their
definitions. You must not use these in a reentrant application unless
you build it with --apcs /rwpi and the callers
use different values in sb.
Note
Exactly which functions use static data in their definitions
might change in future releases.
Callouts from the C library enable access to static data.
C library functions that use static data can be categorized as:
functions that do not use any static data of any
kind, for example fprintf()
functions that manage a static state, such as malloc(), rand(),
and strtok()
functions that do not manage a static state, but
use static data in a way that is specific to the implementation
in the ARM compiler, for example isalpha().
When the C library does something that requires implicit static
data, it uses a callout to a function you can replace. These functions
are shown in Table 1.
They do not use semihosting.
Table 1. C library callouts
Function
Description
__rt_errno_addr()
Called to get the address of the variable errno
__rt_fp_status_addr()
Called by the floating-point support code to
get the address of the floating-point status word
locale functions
The function __user_libspace() creates
a block of private static data for the library
The default implementation of __user_libspace creates
a 96-byte block in the ZI region. Even if your application does
not have a main() function, the __user_libspace() function
does not normally have to be redefined.
Note
Exactly which functions use static data in their definitions
might change in future releases.
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.