Selects one of the security hardened libraries with varying levels of protection, which include branch protection and memory tagging.
The default is
protection specifies the level of protection in the library.
- Selects the
v8.3alibrary, which provides branch protection using Branch Target Identification and Pointer Authentication on function returns.
- v8.5a [ALPHA]
- Selects the
v8.5alibrary, which provides memory tagging protection of the stack used by the library code. This library also includes all the protection in the
v8.3alibrary. Use of the
v8.5alibrary is an [ALPHA] feature.
- Selects the standard C library that does not provide protection using Branch Target Identification and Pointer Authentication, and does not provide memory tagging stack protection.
- The linker automatically selects either the standard C library, or
v8.3a, or the
v8.5alibrary. If at least one input object file has been compiled with
-mmemtag-stackand at least one input object file has return address signing with pointer authentication, then the linker selects the
v8.5alibrary. Otherwise, if at least one input object file has been compiled for Arm®v8.3-A or later, and has return address signing with pointer authentication, then the linker selects the
v8.3alibrary. Otherwise, the behavior is the same as
- The presence of BTI instructions in the compiled objects does not affect automatic library selection.
- The presence of memory tagging instructions in the compiled objects does not affect automatic library selection.
--library_security to override the
automatic selection of protected libraries for branch protection and memory tagging stack
protection (stack tagging).
Branch protection protects your code from Return Oriented Programming (ROP) and Jump Oriented Programming (JOP) attacks. Branch protection using pointer authentication and branch target identification are only available in AArch64 state.
Memory tagging stack protection protects accesses to variables on the stack whose addresses are taken. Memory tagging protection is available for the AArch64 state for architectures with the memory tagging extension.
- Selecting the
v8.5alibrary does not automatically imply memory tagging protection of the heap. To enable memory tagging protection of the heap, you must define the symbol
__use_memtag_heap. You can define this symbol irrespective of the level of
protectionyou use for
--library_security=. For more information, see Choosing a heap implementation for memory allocation functions.
- Code compiled with stack tagging can be safely
linked together with code compiled without stack tagging. However, if any
object file is compiled with
-mmemtag-stack, and if
longjmp, or C++ exceptions are present anywhere in the image, then you must use the
v8.5alibrary to avoid stack tagging related memory fault at runtime.
This uses the
v8.3a library with branch protection using Branch Target Identification and Pointer Authentication:
armlink --cpu=8.3-A.64 --library_security=v8.3a foo.o
This uses the standard C library without any branch protection using Branch Target Identification and Pointer Authentication:
armlink --cpu=8.3-A.64 --library_security=none foo.o
This uses the
v8.5a library with memory
tagging stack protection, and branch protection using Branch Target Identification and
armlink --library_security=v8.5a foo.o