• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Android bionic status
2
3This document details libc/libm/libdl additions and behavior changes.
4
5See also
6[Android linker changes for NDK developers](../android-changes-for-ndk-developers.md)
7for changes related to native code loading in various Android releases.
8
9## Bionic function availability
10
11### POSIX
12
13You can see the current status with respect to POSIX in the form of tests:
14https://android.googlesource.com/platform/bionic/+/main/tests/headers/posix/
15
16Some POSIX functionality is not supported by the Linux kernel, and
17is guarded with tests for `__linux__`. Other functionality is not
18supported by bionic or glibc, and guarded with tests for `__BIONIC__`
19and `__GLIBC__`. In other cases historical accidents mean 32-bit
20bionic diverged but 64-bit bionic matches POSIX; these are guarded with
21`__LP64__`.
22
23Most bionic-only diversions should be accompanied by an explanatory comment.
24
25Missing functions are either obsolete or explicitly disallowed by SELinux:
26  * `a64l`/`l64a`
27  * `confstr`
28  * `crypt`/`encrypt`/`setkey`
29  * `gethostid`
30  * `shm_open`/`shm_unlink`
31  * `sockatmark`
32  * `ualarm`
33
34Missing functionality:
35  * `<aio.h>`. No particular reason not to have this other than that no-one's
36    needed it yet, and it's relatively complex. If/when llvm-libc adds this,
37    maybe we'll just reuse that.
38  * `<monetary.h>`. See
39    [discussion](https://github.com/android/ndk/issues/1182).
40  * `<wordexp.h>`. Unsafe because it passes user input to the shell (!),
41    and often should just be a call to glob() anyway. See also
42    [OpenBSD's discussion about adding wordexp()](https://www.mail-archive.com/tech@openbsd.org/msg02325.html).
43  * Locales. Although bionic contains the various `_l()` functions, the only
44    locale supported is a UTF-8 C/POSIX locale. Most of the POSIX APIs are
45    insufficient to support the wide range of languages used by Android users,
46    and apps should use icu4c (or do their i18n work in Java) instead.
47  * Robust mutexes. See
48    [discussion](https://github.com/android/ndk/issues/1181).
49  * Thread cancellation (`pthread_cancel`). Unlikely to ever be implemented
50    because of the difficulty and cost of implementing it, and the difficulty
51    of using it correctly. See
52    [This is why we can't have safe cancellation points](https://lwn.net/Articles/683118/)
53    for more about thread cancellation.
54
55Run `./libc/tools/check-symbols-glibc.py` in bionic/ for the current
56list of POSIX functions implemented by glibc but not by bionic.
57
58### libc
59
60Current libc symbols: https://android.googlesource.com/platform/bionic/+/main/libc/libc.map.txt
61
62New libc functions in API level 37:
63  * New system call wrappers: `sched_getattr()`/`sched_setattr()` (`<sched.h>`).
64
65New libc functions in API level 36:
66  * `qsort_r`, `sig2str`/`str2sig` (POSIX Issue 8 additions).
67  * GNU/BSD extension `lchmod`.
68  * GNU extensions `pthread_getaffinity_np`/`pthread_setaffinity_np`.
69  * New system call wrapper: `mseal` (`<sys/mman.h>`).
70
71New libc functions in V (API level 35):
72  * New `android_crash_detail_register`, `android_crash_detail_unregister`,
73    `android_crash_detail_replace_name`, and `android_crash_detail_replace_data`
74    functionality for adding arbitrary data to tombstones
75    (see `<android/crash_detail.h>` for full documentation).
76  * `tcgetwinsize`, `tcsetwinsize`, `_Fork` (POSIX Issue 8 additions).
77  * `timespec_getres` (C23 addition).
78  * `localtime_rz`, `mktime_z`, `tzalloc`, and `tzfree` (NetBSD
79    extensions implemented in tzcode, and the "least non-standard"
80    functions for avoiding $TZ if you need to use multiple timezones in
81    multi-threaded C).
82  * `mbsrtowcs_l` and `wcsrtombs_l` aliases for `mbsrtowcs` and `wcsrtombs`.
83  * GNU extensions `strerrordesc_np` and `strerrorname_np`.
84  * New system call wrappers: `__riscv_flush_icache` (`<sys/cachectl.h>`),
85    `__riscv_hwprobe` (`<sys/hwprobe.h>`), `epoll_pwait2`/`epoll_pwait2_64` (`<sys/epoll.h>`).
86
87New libc behavior in V (API level 35):
88  * Added `LD_SHOW_AUXV` to the dynamic linker to dump the ELF auxiliary
89    vector if the environment variable is set.
90  * The printf family now supports `%#m` to print the name of the errno
91    constant (rather than the description printed by `%m`).
92
93New libc functions in U (API level 34):
94  * `close_range` and `copy_file_range` (Linux-specific GNU extensions).
95  * `memset_explicit` in <string.h> (C23 addition).
96  * `__freadahead` in <stdio_ext.h> (in musl but not glibc).
97  * `posix_spawn_file_actions_addchdir_np` and
98    `posix_spawn_file_actions_addfchdir_np` in <spawn.h> (in musl/glibc
99    and macOS, but not iOS).
100
101New libc behavior in U (API level 34):
102  * Support for `%b` and `%B` in the printf/wprintf family, `%b` in the
103    scanf/wscanf family, and `0b` prefixes with base 0 in the strtol/wcstol
104    family.
105  * Support for `wN` length modifiers in the printf/wprintf family.
106  * tmpfile() now respects $TMPDIR.
107
108New libc functions in T (API level 33):
109  * `backtrace`, `backtrace_symbols`, `backtrace_symbols_fd` (`<execinfo.h>`).
110  * New system call wrappers: `preadv2`, `preadv64v2`, `pwritev2`,
111    `pwritev64v2`.
112
113New libc functions in S (API level 31):
114  * New hooks for sanitizers for TLS access: `__libc_get_static_tls_bounds`,
115    `__libc_register_thread_exit_callback`, `__libc_iterate_dynamic_tls`,
116    `__libc_register_dynamic_tls_listeners`.
117  * New helper to allow the zygote to give each zygote child its own stack
118    cookie (currently unused): `android_reset_stack_guards`.
119  * Non-inline symbols for `ffsl`, `ffsll`.
120  * New system call wrappers: `pidfd_getfd`, `pidfd_open`, `pidfd_send_signal`,
121    `process_madvise`.
122
123New libc functions in R (API level 30):
124  * Full C11 `<threads.h>` (available as inlines for older API levels).
125  * `memfd_create` and `mlock2` (Linux-specific GNU extensions).
126  * `renameat2` and `statx` (Linux-specific GNU extensions).
127  * `pthread_cond_clockwait`/`pthread_mutex_clocklock`/`pthread_rwlock_clockrdlock`/`pthread_rwlock_clockwrlock`/`sem_clockwait`
128
129New libc behavior in R (API level 30):
130  * [fdsan](fdsan.md) now aborts when it detects common file descriptor errors,
131    rather than just logging.
132
133New libc functions in Q (API level 29):
134  * `timespec_get` (C11 `<time.h>` addition)
135  * `reallocarray` (BSD/GNU extension in `<malloc.h>` and `<stdlib.h>`)
136  * `res_randomid` (in `<resolv.h>`)
137  * `pthread_sigqueue` (GNU extension)
138  * `getloadavg` (BSD/GNU extension in <stdlib.h>)
139
140New libc behavior in Q (API level 29):
141  * Support for [ELF TLS](elf-tls.md).
142  * Whole printf family now supports the GNU `%m` extension, rather than a
143    special-case hack in `syslog`.
144  * `popen` now always uses `O_CLOEXEC`, not just with the `e` extension.
145  * Bug fixes to handling of UTF-8 U+fffe/U+ffff and code points above U+10ffff.
146  * `aligned_alloc` correctly verifies that `size` is a multiple of `alignment`.
147  * Using `%n` with the printf family is now reported as a FORTIFY failure.
148    Previous versions of Android would ignore the `%n` but not consume the
149    corresponding pointer argument, leading to obscure errors. The scanf family
150    is unchanged.
151  * Support in strptime for `%F`, `%G`, `%g`, `%P`, `%u`, `%V`, and `%v`.
152    (strftime already supported them all.)
153  * [fdsan](fdsan.md) detects and logs common file descriptor errors at runtime.
154
155New libc functions in P (API level 28):
156  * `aligned_alloc`
157  * `__freading`/`__fwriting` (completing <stdio_ext.h>)
158  * `endhostent`/`endnetent`/`endprotoent`/`getnetent`/`getprotoent`/`sethostent`/`setnetent`/`setprotoent` (completing <netdb.h>)
159  * `fexecve`
160  * `fflush_unlocked`/`fgetc_unlocked`/`fgets_unlocked`/`fputc_unlocked`/`fputs_unlocked`/`fread_unlocked`/`fwrite_unlocked`
161  * `getentropy`/`getrandom` (adding <sys/random.h>)
162  * `getlogin_r`
163  * `glob`/`globfree` (adding <glob.h>)
164  * `hcreate`/`hcreate_r`/`hdestroy`/`hdestroy_r`/`hsearch`/`hsearch_r` (completing <search.h>)
165  * `iconv`/`iconv_close`/`iconv_open` (adding <iconv.h>)
166  * `pthread_attr_getinheritsched`/`pthread_attr_setinheritsched`/`pthread_setschedprio`
167  * `pthread_mutexattr_getprotocol`/`pthread_mutexattr_setprotocol` (mutex priority inheritance)
168  * <signal.h> support for `sigaction64_t` and `sigset64_t` allowing LP32 access to real-time signals
169  * <spawn.h>
170  * `swab`
171  * `syncfs`
172
173New libc behavior in P (API level 28):
174  * `%C` and `%S` support in the printf family (previously only the wprintf family supported these).
175  * `%mc`/`%ms`/`%m[` support in the scanf family.
176  * `%s` support in strptime (strftime already supported it).
177  * Using a `pthread_mutex_t` after it's been destroyed will be detected at
178    runtime and reported as a FORTIFY failure.
179  * Passing a null `FILE*` or `DIR*` to libc is now detected at runtime and
180    reported as a FORTIFY failure.
181
182New libc functions in O (API level 26):
183  * `sendto` FORTIFY support
184  * `__system_property_read_callback`/`__system_property_wait`
185  * legacy `bsd_signal`
186  * `catclose`/`catgets`/`catopen` (adding <nl_types.h>)
187  * `ctermid`
188  * all 6 <grp.h>/<pwd.h> (get|set|end)(gr|pw)ent functions
189  * `futimes`/`futimesat`/`lutimes`
190  * `getdomainname`/`setdomainname`
191  * `getsubopt`
192  * `hasmntopt`
193  * `mallopt`
194  * `mblen`
195  * 4 <sys/msg.h> `msg*` functions
196  * <langinfo.h> `nl_langinfo`/`nl_langinfo_l`
197  * `pthread_getname_np`
198  * 2 new Linux system calls `quotactl` and `sync_file_range`
199  * 4 <sys/sem.h> `sem*` functions
200  * 4 <sys/shm.h> `shm*` functions
201  * 5 legacy <signal.h> functions: `sighold`/`sigignore`/`sigpause`/`sigrelse`/`sigset`
202  * `strtod_l`/`strtof_l`/`strtol_l`/`strtoul_l`
203  * <wctype.h> `towctrans`/`towctrans_l`/`wctrans`/`wctrans_l`
204
205New libc behavior in O (API level 26):
206  * Passing an invalid `pthread_t` to libc is now detected at runtime and
207    reported as a FORTIFY failure. Most commonly this is a result of confusing
208    `pthread_t` and `pid_t`.
209
210New libc functions in N (API level 24):
211  * more FORTIFY support functions (`fread`/`fwrite`/`getcwd`/`pwrite`/`write`)
212  * all remaining `_FILE_OFFSET_BITS=64` functions, completing `_FILE_OFFSET_BITS=64` support in bionic (8)
213  * all 7 `pthread_barrier*` functions
214  * all 5 `pthread_spin*` functions
215  * `lockf`/`preadv`/`pwritev`/`scandirat` and `off64_t` variants
216  * `adjtimex`/`clock_adjtime`
217  * <ifaddrs.h> `getifaddrs`/`freeifaddrs`/`if_freenameindex`/`if_nameindex`
218  * `getgrgid_r`/`getgrnam_r`
219  * GNU extensions `fileno_unlocked`/`strchrnul`
220  * 32-bit `prlimit`
221
222New libc behavior in N (API level 24):
223  * `sem_wait` now returns EINTR when interrupted by a signal.
224
225New libc functions in M (API level 23):
226  * <dirent.h> `telldir`, `seekdir`.
227  * <malloc.h> `malloc_info`.
228  * <netdb.h> `gethostbyaddr_r`, `gethostbyname2_r`.
229  * <pthread.h> `pthread_rwlockattr_getkind_np`/`pthread_rwlockattr_setkind_np`.
230  * <pty.h> `forkpty`, `openpty`.
231  * <signal.h> `sigqueue`, `sigtimedwait`, `sigwaitinfo`.
232  * <stdio.h> `fmemopen`, `open_memstream`, `feof_unlocked`, `ferror_unlocked`, `clearerr_unlocked`.
233  * <stdio_ext.h> `__flbf`, `__freadable`, `__fsetlocking`, `__fwritable`, `__fbufsize`, `__fpending`, `_flushlbf`, `__fpurge`.
234  * <stdlib.h> `mkostemp`/`mkostemps`, `lcong48`.
235  * <string.h> `basename`, `strerror_l`, `strerror_r`, `mempcpy`.
236  * <sys/sysinfo.h> `get_nprocs_conf`/`get_nprocs`, `get_phys_pages`, `get_avphys_pages`.
237  * <sys/uio.h> `process_vm_readv`/`process_vm_writev`.
238  * `clock_getcpuclockid`, `login_tty`, `mkfifoat`, `posix_madvise`, `sethostname`, `strcasecmp_l`/`strncasecmp_l`.
239  * <wchar.h> `open_wmemstream`, `wcscasecmp_l`/`wcsncasecmp_l`, `wmempcpy`.
240  * all of <error.h>.
241  * re-introduced various <resolv.h> functions: `ns_format_ttl`, `ns_get16`, `ns_get32`, `ns_initparse`, `ns_makecanon`, `ns_msg_getflag`, `ns_name_compress`, `ns_name_ntol`, `ns_name_ntop`, `ns_name_pack`, `ns_name_pton`, `ns_name_rollback`, `ns_name_skip`, `ns_name_uncompress`, `ns_name_unpack`, `ns_parserr`, `ns_put16`, `ns_put32`, `ns_samename`, `ns_skiprr`, `ns_sprintrr`, and `ns_sprintrrf`.
242
243New libc functions in L (API level 21):
244  * <android/dlext.h>.
245  * <android/set_abort_message.h>.
246  * <arpa/inet.h> `inet_lnaof`, `inet_netof`, `inet_network`, `inet_makeaddr`.
247  * <wctype.h> `iswblank`.
248  * <ctype.h> `isalnum_l`, `isalpha_l`, `isblank_l`, `icntrl_l`, `isdigit_l`, `isgraph_l`, `islower_l`, `isprint_l`, `ispunct_l`, `isspace_l`, `isupper_l`, `isxdigit_l`, `_tolower`, `tolower_l`, `_toupper`, `toupper_l`.
249  * <fcntl.h> `fallocate`, `posix_fadvise`, `posix_fallocate`, `splice`, `tee`, `vmsplice`.
250  * <inttypes.h> `wcstoimax`, `wcstoumax`.
251  * <link.h> `dl_iterate_phdr`.
252  * <mntent.h> `setmntent`, `endmntent`, `getmntent_r`.
253  * <poll.h> `ppoll`.
254  * <pthread.h> `pthread_condattr_getclock`, `pthread_condattr_setclock`, `pthread_mutex_timedlock`, `pthread_gettid_np`.
255  * <sched.h> `setns`.
256  * <search.h> `insque`, `remque`, `lfind`, `lsearch`, `twalk`.
257  * <stdio.h> `dprintf`, `vdprintf`.
258  * <stdlib.h> `initstate`, `setstate`, `getprogname`/`setprogname`, `atof`/`strtof`, `at_quick_exit`/`_Exit`/`quick_exit`, `grantpt`, `mbtowc`/`wctomb`, `posix_openpt`, `rand_r`/`rand`/`random`/`srand`/`srandom`, `strtold_l`/`strtoll_l`/`strtoull_l`.
259  * <string.h> `strcoll_l`/`strxfrm_l`, `stpcpy`/`stpncpy`.
260  * <sys/resource.h> `prlimit`.
261  * <sys/socket.h> `accept4`, `sendmmsg`.
262  * <sys/stat.h> `mkfifo`/`mknodat`.
263  * <time.h> `strftime_l`.
264  * <unistd.h> `dup3`, `execvpe`, `getpagesize`, `linkat`/`symlinkat`/`readlinkat`, `truncate`.
265  * <wchar.h> `wcstof`, `vfwscanf`/`vswscanf`/`vwscanf`, `wcstold_l`/`wcstoll`/`wcstoll_l`/`wcstoull`/`wcstoull_l`, `mbsnrtowcs`/`wcsnrtombs`, `wcscoll_l`/`wcsxfrm_l`.
266  * <wctype.h> `iswalnum_l`/`iswalpha_l`/`iswblank_l`/`iswcntrl_l`/`iswctype_l`/`iswdigit_l`/`iswgraph_l`/`iswlower_l`/`iswprint_l`/`iswpunct_l`/`iswspace_l`/`iswupper_l`/`iswxdigit_l`, `wctype_l`, `towlower_l`/`towupper_l`.
267  * all of <fts.h>.
268  * all of <locale.h>.
269  * all of <sys/epoll.h>.
270  * all of <sys/fsuid.h>.
271  * all of <sys/inotify.h>.
272  * all of <uchar.h>.
273
274New libc functions in K (API level 19):
275  * <inttypes.h> `imaxabs`, `imaxdiv`.
276  * <stdlib.h> `abs`, `labs`, `llabs`.
277  * <sys/stat.h> `futimens`.
278  * all of <sys/statvfs.h>.
279  * all of <sys/swap.h>.
280  * all of <sys/timerfd.h>.
281
282New libc functions in J-MR2 (API level 18):
283  * <stdio.h> `getdelim` and `getline`.
284  * <sys/auxv.h> `getauxval`.
285  * <sys/signalfd.h> `signalfd`.
286
287New libc functions in J-MR1 (API level 17):
288  * <ftw.h>.
289  * <signal.h> `psiginfo` and `psignal`.
290  * `getsid`, `malloc_usable_size`, `mlockall`/`munlockall`, `posix_memalign`, `unshare`.
291
292New libc functions in J (API level 16):
293  * the <search.h> tree functions `tdelete`, `tdestroy`, `tfind`, and `tsearch`.
294  * `faccessat`, `readahead`, `tgkill`.
295  * all of <sys/xattr.h>.
296
297libc function count over time:
298
299| API level | Function count |
300|-----------|----------------|
301| 16        | 842            |
302| 17        | 870            |
303| 18        | 878            |
304| 19        | 893            |
305| 21        | 1016           |
306| 22        | 1038           |
307| 23        | 1103           |
308| 24        | 1147           |
309| 25        | 1147           |
310| 26        | 1199           |
311| 27        | 1199           |
312| 28        | 1298           |
313| 29        | 1312           |
314| 30        | 1368           |
315| 31        | 1379           |
316| 32        | 1379           |
317| 33        | 1386           |
318| 34        | 1392           |
319
320Data collected by:
321```
322ndk-r26c$ for i in `ls -1v toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/*/libc.so` ; \
323  do echo $i; nm $i | grep -w T | wc -l ; done
324```
325
326### libm
327
328Current libm symbols: https://android.googlesource.com/platform/bionic/+/main/libm/libm.map.txt
329
3300 remaining missing C11/POSIX libm functions.
331
332New libm functions in O (API level 26):
333  * <complex.h> `clog`/`clogf`, `cpow`/`cpowf` functions.
334
335New libm functions in M (API level 23):
336  * <complex.h> `cabs`, `carg`, `cimag`, `cacos`, `cacosh`, `casin`, `casinh`, `catan`, `catanh`, `ccos`, `ccosh`, `cexp`, `conj`, `cproj`, `csin`, `csinh`, `csqrt`, `ctan`, `ctanh`, `creal`, `cabsf`, `cargf`, `cimagf`, `cacosf`, `cacoshf`, `casinf`, `casinhf`, `catanf`, `catanhf`, `ccosf`, `ccoshf`, `cexpf`, `conjf`, `cprojf`, `csinf`, `csinhf`, `csqrtf`, `ctanf`, `ctanhf`, `crealf`, `cabsl`, `cprojl`, `csqrtl`.
337  * <math.h> `lgammal_r`.
338
339New libm functions in L (API level 21):
340  * <complex.h> `cabsl`, `cprojl`, `csqrtl`.
341  * <math.h> `isinf`, `significandl`.
342
343New libm functions in J-MR2 (API level 18):
344  * <math.h> `log2`, `log2f`.
345
346
347## Target API level behavioral differences
348
349Most bionic bug fixes and improvements have been made without checks for
350the app's `targetSdkVersion`. There are a handful of exceptions. (If in
351doubt, search the source for `android_get_application_target_sdk_version()`.)
352
353### Destroyed mutex checking (targetSdkVersion >= 28)
354
355If a destroyed `pthread_mutex_t` is passed to any of the mutex functions, apps
356targeting API level 28 or higher will see a
357"<function> called on a destroyed mutex" fortify failure. Apps targeting older
358API levels will just have the function fail with EBUSY (matching the likely
359behavior before we added the check).
360
361### Invalid `pthread_t` handling (targetSdkVersion >= 26)
362
363As part of a long-term goal to remove the global thread list,
364and in an attempt to flush out racy code, we changed how an invalid
365`pthread_t` is handled. For `pthread_detach`, `pthread_getcpuclockid`,
366`pthread_getschedparam`/`pthread_setschedparam`, `pthread_join`, and
367`pthread_kill`, instead of returning ESRCH when passed an invalid
368`pthread_t`, if you're targeting API level 26 or above, they'll abort with the
369message "attempt to use invalid pthread\_t".
370
371Note that this doesn't change behavior as much as you might think: the
372old lookup only held the global thread list lock for the duration of
373the lookup, so there was still a race between that and the dereference
374in the caller, given that callers actually need the tid to pass to some
375syscall or other, and sometimes update fields in the `pthread_internal_t`
376struct too.
377
378We can't check a thread's tid against 0 to see whether a `pthread_t`
379is still valid because a dead thread gets its thread struct unmapped
380along with its stack, so the dereference isn't safe.
381
382To fix your code, taking the affected functions one by one:
383
384  * `pthread_getcpuclockid` and `pthread_getschedparam`/`pthread_setschedparam`
385    should be fine. Unsafe calls to those seem highly unlikely.
386
387  * Unsafe `pthread_detach` callers probably want to switch to
388    `pthread_attr_setdetachstate` instead, or use
389    `pthread_detach(pthread_self());` from the new thread's start routine
390    rather than calling detach in the parent.
391
392  * `pthread_join` calls should be safe anyway, because a joinable thread
393    won't actually exit and unmap until it's joined. If you're joining an
394    unjoinable thread, the fix is to stop marking it detached. If you're
395    joining an already-joined thread, you need to rethink your design!
396
397  * Unsafe `pthread_kill` calls aren't portably fixable. (And are obviously
398    inherently non-portable as-is.) The best alternative on Android is to
399    use `pthread_gettid_np` at some point that you know the thread to be
400    alive, and then call `kill`/`tgkill` with signal 0 (which checks
401    whether a process exists rather than actually sending a
402    signal). That's still not completely safe because if you're too late
403    the tid may have been reused, but your code is inherently unsafe without
404    a redesign anyway.
405
406### Interruptable `sem_wait` (targetSdkVersion >= 24)
407
408POSIX says that `sem_wait` can be interrupted by delivery of a
409signal. This wasn't historically true in Android, and when we fixed this
410bug we found that existing code relied on the old behavior. To preserve
411compatibility, `sem_wait` can only return EINTR on Android if the app
412targets API level 24 or later.
413
414
415## FORTIFY
416
417The `_FORTIFY_SOURCE` macro can be used to enable extra
418automatic bounds checking for common libc functions. If a buffer
419overrun is detected, the program is safely aborted as in this
420[example](https://source.android.com/devices/tech/debug/native-crash#fortify).
421
422Note that Android's FORTIFY has been extended to cover other issues. It can
423detect, for example, passing `O_CREAT` to open(2) without specifying a mode. It
424also performs some checking regardless of whether the caller was built with
425FORTIFY enabled. From API level 28, for example, calling a `pthread_mutex_`
426function on a destroyed mutex, calling a `<dirent.h>` function on a null
427pointer, using `%n` with the printf(3) family, or using the scanf(3) `m`
428modifier incorrectly will all result in FORTIFY failures even for code not built
429with FORTIFY.
430
431More background information is available in our
432[FORTIFY in Android](https://android-developers.googleblog.com/2017/04/fortify-in-android.html)
433blog post, and there's more detail about the implementation in
434[The Anatomy of Clang FORTIFY](clang_fortify_anatomy.md).
435
436The Android platform is built with `-D_FORTIFY_SOURCE=2`. Users of ndk-build
437or the NDK's CMake toolchain file also get this by default with NDK r21 or
438newer. Users of other build systems
439need to manually enable FORTIFY by setting `_FORTIFY_SOURCE` themselves in
440whatever build system they're using. The exact subset of FORTIFY available to
441NDK users will depend on their target ABI level, because when a FORTIFY
442check can't be guaranteed at compile-time, a call to a run-time `_chk`
443function is added.
444