| #
ba2a6adb |
| 02-Jun-2023 |
Alvin Chang <alvinga@andestech.com> |
ldelf: Add TA stack trace for RISC-V architecture
Implement ta_elf_stack_trace_riscv() to unwind the stack of TA. Also the RISC-V architecture string of TA ELF is added into dump information.
Signe
ldelf: Add TA stack trace for RISC-V architecture
Implement ta_elf_stack_trace_riscv() to unwind the stack of TA. Also the RISC-V architecture string of TA ELF is added into dump information.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Tested-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>
show more ...
|
| #
af78e1b1 |
| 24-Oct-2022 |
Imre Kis <imre.kis@arm.com> |
ldelf: Provide access to TS load address
Propagate ELF load address from ldelf to user mode context as a preparation for load address relative memory regions.
Signed-off-by: Imre Kis <imre.kis@arm.
ldelf: Provide access to TS load address
Propagate ELF load address from ldelf to user mode context as a preparation for load address relative memory regions.
Signed-off-by: Imre Kis <imre.kis@arm.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
bdf82531 |
| 06-Mar-2022 |
Jerome Forissier <jerome.forissier@linaro.org> |
ldelf: add DT_GNU_HASH support
It is possible for an ELF to be compiled with --hash-style=gnu; some distros even have that as their default. This produces an ELF with no .hash section, but with a .g
ldelf: add DT_GNU_HASH support
It is possible for an ELF to be compiled with --hash-style=gnu; some distros even have that as their default. This produces an ELF with no .hash section, but with a .gnu.hash section in its stead.
GNU-style hash sections have better performance than old SYSV-style ones. It can be expected that, as time goes on, it becomes the new default.
Use the DT_GNU_HASH table for symbol lookup when present, then fall back onto DT_HASH.
Co-developed-by: Elvira Khabirova <e.khabirova@omp.ru> Signed-off-by: Elvira Khabirova <e.khabirova@omp.ru> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| #
e84a7da4 |
| 02-Nov-2021 |
Ruchika Gupta <ruchika.gupta@linaro.org> |
ldelf: Add ELF program property parsing support to check for BTI
ELF program properties will be needed for detecting whether to enable optional architecture or ABI features for a new ELF process.
T
ldelf: Add ELF program property parsing support to check for BTI
ELF program properties will be needed for detecting whether to enable optional architecture or ABI features for a new ELF process.
The PT_GNU_PROPERTY is generated by a linker to describe the .note.gnu.property section. The definition of PT_GNU_PROPERTY can be found in [1].
For AArch64, GNU_PROPERTY_AARCH64_FEATURE_1_AND program property type describes a set of processor features with which an ELF object or executable image is compatible, but does not require in order to execute correctly. These processor features are BTI and PAC.
[1] https://github.com/hjl-tools/linux-abi/wiki/linux-abi-draft.pdf
Signed-off-by: Ruchika Gupta <ruchika.gupta@linaro.org> Reviewed-by: Jerome Forissier <jerome@forissier.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
01b02a16 |
| 21-Jul-2020 |
Jerome Forissier <jerome@forissier.org> |
ldelf, libutee: rework support of DT_INIT_ARRAY/DT_FINI_ARRAY
Now that we have the standard function dl_iterate_phdr() in libutee, we can use it to process the initialization and finalization arrays
ldelf, libutee: rework support of DT_INIT_ARRAY/DT_FINI_ARRAY
Now that we have the standard function dl_iterate_phdr() in libutee, we can use it to process the initialization and finalization arrays in the ELF files and deprecate the ad-hoc structure __init_fini_info introduced in commit dd655cb9906c ("ldelf, ta: add support for DT_INIT_ARRAY and DT_FINI_ARRAY") [1]. Unfortunately, removing __init_fini_info is not an option if we want to ensure backward compatibility. This concerns only TAs which use ELF initialization and/or finalization functions.
[1] Released in version 3.9.0.
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 ...
|
| #
9d224046 |
| 21-Jul-2020 |
Jerome Forissier <jerome@forissier.org> |
ldelf, libutee: add minimal Thread Local Storage support
Preparing for C++ support in TAs.
Adds enough runtime Thread Local Storage (TLS) support for the GNU C++ compilers (arm-linux-gnueabihf-g++,
ldelf, libutee: add minimal Thread Local Storage support
Preparing for C++ support in TAs.
Adds enough runtime Thread Local Storage (TLS) support for the GNU C++ compilers (arm-linux-gnueabihf-g++, aarch64-linux-gnu-g++) to work with OP-TEE. That is:
- A Thread Control Block, - The __tls_get_addr() and dl_iterate_phdr() functions.
Note that __tls_get_addr() is an ABI helper so it has no prototype in a user-accessible header file. dl_iterate_phdr() however is defined in <link.h> and may be used in a TA. The file lib/libutee/include/link.h is borrowed from Android's Bionic [1] with minor changes (added the required #include statement and named the function parameters). A similar <link.h> header is provided by other C libraries such as GNU libc, musl and FreeBSD/NetBSD/OpenBSD.
Link: [1] https://android.googlesource.com/platform/bionic/+/master/libc/include/link.h 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 ...
|
| #
fe684948 |
| 21-Jul-2020 |
Jerome Forissier <jerome@forissier.org> |
ldelf: arm64: support R_AARCH64_TLS_TPREL relocations
Preparing for C++ support in TAs.
This commit adds support for relocation type R_AARCH64_TLS_TPREL. Although OP-TEE does not support multi-thre
ldelf: arm64: support R_AARCH64_TLS_TPREL relocations
Preparing for C++ support in TAs.
This commit adds support for relocation type R_AARCH64_TLS_TPREL. Although OP-TEE does not support multi-threaded TAs, introducing basic support for multi-threading will allow binaries generated by the aarch64-linux-gnueabihf-g++ compiler to work properly. Indeed, this compiler is configured for a multi-threadded environment by default.
The way R_AARCH64_TLS_TPREL works is simple: the runtime library needs to keep a per-thread copy of all the TLS segments in the application. When the compiler needs to access a thread-specific symbol, it emits this relocation. The loader will then replace the value by the offset of the desired symbol in the Thread Control Block of the current thread (the address of the TCB is obtained via the TPIDR_EL0 register).
The runtime code that sets up the TCB from the TLS segments will come in a later commit.
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 ...
|
| #
c88ba125 |
| 21-Jul-2020 |
Jerome Forissier <jerome@forissier.org> |
ldelf: arm: support R_ARM_TLS_DTPMOD32 and R_ARM_TLS_DTPOFF32 relocations
Preparing for C++ support in TAs.
This commit adds support for Thread Local Storage (TLS) relocation types R_ARM_TLS_DTPMOD
ldelf: arm: support R_ARM_TLS_DTPMOD32 and R_ARM_TLS_DTPOFF32 relocations
Preparing for C++ support in TAs.
This commit adds support for Thread Local Storage (TLS) relocation types R_ARM_TLS_DTPMOD32 and R_ARM_TLS_DTPOFF32.
OP-TEE does not support multi-threaded TAs so in principle there is no need to handle the TLS relocations. However, this commit will allow to run C++ TAs built with the "official" arm-linux-gnueabihf compiler (which is built with threading support enabled), as long as no multi-thread feature is explicitly used by the TA. In other words, it avoids the need to re-build a toolchain with --disable-threads.
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 ...
|
| #
dd655cb9 |
| 14-Feb-2020 |
Jerome Forissier <jerome@forissier.org> |
ldelf, ta: add support for DT_INIT_ARRAY and DT_FINI_ARRAY
Adds support for running initialization and finalization functions in TA ELF files. Such functions are used, for instance, by C++ compilers
ldelf, ta: add support for DT_INIT_ARRAY and DT_FINI_ARRAY
Adds support for running initialization and finalization functions in TA ELF files. Such functions are used, for instance, by C++ compilers to construct and destruct global objects. They can also be used in C thanks to __attribute__((constructor)) and __attribute__((destructor)).
A global structure is added to libutee. ldelf is responsible for filling it with the addresses of the functions pointer arrays present in the ELF files whenever such a file is loaded. Since the number of arrays is unknown at compile time (it depends on how many ELF files are loaded, and whether they have constructors or destructors), memory is allocated on the TA heap.
Two helper functions are introduced: __utee_call_elf_init_fn() and __utee_call_elf_fini_fn(). They are used when the TA instance is created and torn down, as well as by dlopen().
Signed-off-by: Jerome Forissier <jerome@forissier.org> Tested-by: Jerome Forissier <jerome@forissier.org> (QEMU, QEMUv8, HiKey960 32/64) Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
ebef121c |
| 01-Aug-2019 |
Jerome Forissier <jerome.forissier@linaro.org> |
core, ldelf: add support for runtime loading of shared libraries
This commit prepares the introduction of libdl, a dynamic linking library which will allow TAs to load shared libraries at run time,
core, ldelf: add support for runtime loading of shared libraries
This commit prepares the introduction of libdl, a dynamic linking library which will allow TAs to load shared libraries at run time, and resolve symbols on demand. It adds the following function to the system PTA, inspired from the POSIX dlopen() and dlsym():
- system_dlopen(): takes a UUID and flags. Performs an upcall into ldelf which then uses the usual system PTA functions to load an map the requested library into the address space of the calling TA. - system_dlsym(): takes a UUID and a symbol name. The symbol is looked up in the library specified by UUID by calling into ldelf. If UUID is all zeros, all the mapped binaries are searched.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| #
c35dfd95 |
| 30-Jul-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
ldelf: accurate non-legacy TA check
Prior to this patch ldelf relied on e_entry in the ELF header to point anywhere but at the lowest possible executable address to tell that it's not a legacy TA. T
ldelf: accurate non-legacy TA check
Prior to this patch ldelf relied on e_entry in the ELF header to point anywhere but at the lowest possible executable address to tell that it's not a legacy TA. This isn't enough since all TAs can use this entry address depending on compiler and linker. The only reliable indicator that the TA is not a legacy TA is that the depr_entry field of the TA header is UINT64_MAX. Unfortunately this means assuming that the ELF is not a legacy TA at load time and that the process needs to be restarted in case it turns out that it was a legacy TA.
With this patch we have reliable detection of non-legacy TAs, but with increased load time for legacy TAs since the main ELF needs to be loaded and verified twice due to the TA store interface.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
c86f218c |
| 18-Jun-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
ldelf: support TA ftrace
Adds support in ldelf to dump ftrace data.
Reviewed-by: Sumit Garg <sumit.garg@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wikl
ldelf: support TA ftrace
Adds support in ldelf to dump ftrace data.
Reviewed-by: Sumit Garg <sumit.garg@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
9f392760 |
| 18-Jun-2019 |
Jerome Forissier <jerome.forissier@linaro.org> |
ldelf: use DT_HASH to lookup symbols faster
Use the ELF hash table to lookup symbols rather than iterating over the whole symbol table.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
ldelf: use DT_HASH to lookup symbols faster
Use the ELF hash table to lookup symbols rather than iterating over the whole symbol table.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
0242833a |
| 23-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
ldelf: support dumping TA call stack
Adds support in ldelf to dump the call stack of the TA.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@l
ldelf: support dumping TA call stack
Adds support in ldelf to dump the call stack of the TA.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
65137432 |
| 23-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
ldelf: support dumping memory map
Adds support in ldelf to dump memory maps.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
|
| #
7509ff7c |
| 23-May-2019 |
Jens Wiklander <jens.wiklander@linaro.org> |
Add user mode ELF loader
Adds ldelf which loads user mode TAs while in user mode. The TA ELF file is loaded and relocated by ldelf before the TA can be executed.
Reviewed-by: Jerome Forissier <jero
Add user mode ELF loader
Adds ldelf which loads user mode TAs while in user mode. The TA ELF file is loaded and relocated by ldelf before the TA can be executed.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|