blob: 5ed809395d2222a41aa06c6ccddf9aaa14a644a6 [file] [log] [blame]
Joakim Bech8e5c5b32018-10-25 08:18:32 +02001.. _libraries:
2
3#########
4Libraries
5#########
6
Etienne Carriere7b780182023-11-10 10:25:02 +01007.. _libutils:
8
9libutils
10********
11
12OP-TEE core and OP-TEE development kit for Trusted Application provide a
13standard C library that is named **libutils**. It implements many
14standard functions like ``snprintf()``, ``strncmp()``, ``memcpy()``,
15``malloc()``. ``qsort()``, and many more but not all standard C library
16functions.
17
18Note however that Trusted Applications implemented in C should use GP TEE
19Internal Core API functions rather than their standard C library function
20equivalent (e.g. ``TEE_MemMove()`` instead of ``memcpy()`` and
21``memmove()``, or ``TEE_Malloc()`` instead of ``malloc()`` and friends).
22This makes those TAs implementation more portable to other GP
23TEE compliant environments.
24
Etienne Carrierec75d19d2023-11-10 14:29:28 +010025When ``CFG_ULIBS_SHARED`` is enabled, **libutils** is assigned UUID
26**71855bba-6055-4293-a63f-b0963a737360**.
27
Joakim Bech8e5c5b32018-10-25 08:18:32 +020028.. _libutee:
29
30libutee
31*******
32The :ref:`tee_internal_core_api` describes services that are provided to Trusted
33Applications. **libutee** is a library that implements this API.
34
Etienne Carrierec75d19d2023-11-10 14:29:28 +010035libutee is designed as a userland library specifically dedicated to OP-TEE
36Trusted Applications and aims at being executed in the non-privileged secure
37userspace.
Joakim Bech8e5c5b32018-10-25 08:18:32 +020038
39Some services for this API are fully statically implemented inside the libutee
40library while some services for the API are implemented inside the OP-TEE core
41(privileged level) and libutee calls such services through system calls.
42
Etienne Carrierec75d19d2023-11-10 14:29:28 +010043When ``CFG_ULIBS_SHARED`` is enabled, **libutee** is assigned UUID
44**4b3d937e-d57e-418b-8673-1c04f2420226**.
45
Etienne Carrierec86a7262025-03-27 18:40:33 +010046.. _libmbedtls:
47
Etienne Carriere20e12e62023-11-10 15:04:51 +010048libmbedtls
49**********
50
Etienne Carrierec86a7262025-03-27 18:40:33 +010051OP-TEE OS source tree provides support of the `Mbed TLS`_ library, named
52**libmbedtls**. Its source directory is located at `lib/libmbedtls/`.
Etienne Carriere20e12e62023-11-10 15:04:51 +010053
54A specific build sequence can compile an instance of **libmbedtls** and link
55it to OP-TEE core. Another build sequence compiles an instance of
56**libmbedtls** that can be linked with Trusted Applications.
57
58When Mbed TLS is embedded in OP-TEE core, it is used as the default software
59implementation for most cryptography operations. When so, **libtomcrypt** is
60still used as default software implementation for few crypto operations.
61Embedding Mbed TLS in OP-TEE core requires ``CFG_CRYPTOLIB_NAME=mbedtls``
Etienne Carrierec86a7262025-03-27 18:40:33 +010062and ``CFG_CRYPTOLIB_DIR=lib/libmbedtls``.
Etienne Carriere20e12e62023-11-10 15:04:51 +010063
64When ``CFG_ULIBS_SHARED`` is enabled, **libmbedtls** userland library is
65assigned UUID **87bb6ae8-4b1d-49fe-9986-2b966132c309**.
66
67libunw
68******
69
70OP-TEE OS source tree implements execution stack back trace debug facilities
71available to both OP-TEE core and Trusted Applications. The feature relies
72on a library named **libunw**.
73
74**libunw**, when linked to a Trusted Application, is always linked as a static
75library.
76
77libdl
78*****
79
80**libdl** library implement API function ``dlopen()``, ``dlsym()`` and
81``dlclose()`` used by Trusted Applications to support dynamic shared libraries.
82
83When ``CFG_ULIBS_SHARED`` is enabled, **libdl** is assigned UUID
84**be807bbd-81e1-4dc4-bd99-3d363f240ece**.
85
Etienne Carrierec75d19d2023-11-10 14:29:28 +010086.. _statci_or_shared_lib:
87
88Static vs Shared libraries
89**************************
90
91OP-TEE core supports only static libraries that are linked at build time to
92produce the monolithic OP-TEE core image.
93
94OP-TEE Trusted Applications can support both static and shared libraries. In
95the latter case, each shared library is identified by a UUID and OP-TEE OS
96is in charge of dynamically loading the required shared libraries in the
97address space of the Trusted Application when this one uses a resource of
98the related library.
99
100In order to support shared library, OP-TEE OS shall be built with
101``CFG_ULIBS_SHARED=y``. Shared library binary images are generated as
102**.elf** and **.ta** files, like Trusted Applications are, and shall be
103installed the same way as Trusted Applications are, see ref:`ta_locations`.
104
Etienne Carrierec86a7262025-03-27 18:40:33 +0100105.. _Mbed TLS: https://www.trustedfirmware.org/projects/mbed-tls/