| eacabbbc | 23-Sep-2021 |
Jerome Forissier <jerome@forissier.org> |
libutils: ta: provide malloc(), calloc() and realloc() when debug is on
When enabling malloc debug for TAs (CFG_TEE_TA_MALLOC_DEBUG=y), the standard malloc entry points malloc(), calloc() and reallo
libutils: ta: provide malloc(), calloc() and realloc() when debug is on
When enabling malloc debug for TAs (CFG_TEE_TA_MALLOC_DEBUG=y), the standard malloc entry points malloc(), calloc() and realloc() are redirected by C macros to instrumented variants: mdbg_malloc(), mdbg_calloc() and mdbg_realloc(). In addition, the 'normal' symbols are not exported by libutils. That is a problem because a TA might still reference them. For example the C++ code in optee_test requires libstdc++ which relies on malloc() etc.:
build (master)$ make -j10 CFG_TEE_TA_MALLOC_DEBUG=y CFG_TEE_TA_LOG_LEVEL=2 ... /home/jerome/work/optee_repo_qemu/build/../toolchains/aarch32/bin/arm-linux-gnueabihf-ld.bfd: /home/jerome/work/toolchains-gcc10.2/aarch32/bin/../lib/gcc/arm-none-linux-gnueabihf/10.2.1/../../../../arm-none-linux-gnueabihf/lib/libstdc++.a(eh_alloc.o): in function `__cxa_allocate_exception': /tmp/dgboter/bbs/build03--cen7x86_64/buildbot/cen7x86_64--arm-none-linux-gnueabihf/build/src/gcc/libstdc++-v3/libsupc++/eh_alloc.cc:284: undefined reference to `malloc' ...
Fix the issue by defining the standard malloc() functions in libutils, calling the debug variants.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 405a5072 | 21-Jul-2020 |
Jerome Forissier <jerome@forissier.org> |
libutils: add simplified fputc(), fputs(), fwrite(), write()
Preparing for C++ support in TAs.
Adds a few <stdio.h> functions to libutils:
fputc() fputs() fwrite() write()
The proposed implem
libutils: add simplified fputc(), fputs(), fwrite(), write()
Preparing for C++ support in TAs.
Adds a few <stdio.h> functions to libutils:
fputc() fputs() fwrite() write()
The proposed implementations are limited in the sense that they only accept writing to stdout or stderr. The output goes directly to the secure console and no difference is made between stdout and stderr.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b6d69a43 | 25-Mar-2019 |
Jerome Forissier <jerome.forissier@linaro.org> |
libutils: ctype.h: do not define functions as builtins
Our <ctype.h> defines a number of functions as macros that evaluate to the builtin function of the same name, for instance:
#define isalpha(_
libutils: ctype.h: do not define functions as builtins
Our <ctype.h> defines a number of functions as macros that evaluate to the builtin function of the same name, for instance:
#define isalpha(__c) __builtin_isalpha(__c)
There are two problems with this:
1. It gets in the way of the application developer and makes some compiler flags irrelevant (-fno-builtin*, [1]). 2. Different compilers do not support the same set of builtin functions so having the defines can result in build errors.
Therefore, user regular prototypes in <ctype.h>. Also build libutils without the -ffreestanding flag because it implies -fno-builtin and therefore may needlessly disable optimizations. The libutils environment cannot be considered "free standing" since it implements the standard header files with the expected semantics.
Our implementations of the <ctypes.h> functions (isalnum(), isalpha(), etc.) are defined with the __builtin_ prefix. This is not needed and is arguably wrong. Indeed, we want the functions in libutils to be present without the prefix, which GCC happens to be doing regardless. However, this __builtin_ prefix in the .c files makes things more complicated to support Clang. Therefore, remove it.
Link: [1] https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html (-fno-builtin) Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 386fc264 | 05-Feb-2018 |
Volodymyr Babchuk <vlad.babchuk@gmail.com> |
bget_malloc: add nex_malloc pool
If virtualization enabled, this pool will be used to allocate memory for OP-TEE nexus needs. Without virtualization, generic malloc pool will be used.
Signed-off-by
bget_malloc: add nex_malloc pool
If virtualization enabled, this pool will be used to allocate memory for OP-TEE nexus needs. Without virtualization, generic malloc pool will be used.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b38854bd | 09-Nov-2018 |
Bryan O'Donoghue <bryan.odonoghue@linaro.org> |
libutils: Import strtoul from newlib
This patch imports strtoul from newlib which the latest version of libfdt depends on.
Some modification of the original source is required to do this, specifica
libutils: Import strtoul from newlib
This patch imports strtoul from newlib which the latest version of libfdt depends on.
Some modification of the original source is required to do this, specifically:
This is an import of the newlib 1.19.0 version of strtoul dropping
- Headers and prototypes for re-entrancy
- Any reliance on errno
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 433c4257 | 07-May-2018 |
Jens Wiklander <jens.wiklander@linaro.org> |
Add rand() for TA usage
Adds rand() by declaring it in stdlib.h where it's expected to be found. Implementation is provided in libutee since it depends on TEE_GenerateRandom().
Reviewed-by: Joakim
Add rand() for TA usage
Adds rand() by declaring it in stdlib.h where it's expected to be found. Implementation is provided in libutee since it depends on TEE_GenerateRandom().
Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|