| 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 ...
|
| 6627f23e | 23-Jun-2022 |
Jerome Forissier <jerome.forissier@linaro.org> |
ldelf: get DT_HASH info from section headers
Obtain the address of the DT_HASH section from the section headers rather than from the dynamic section. In addition to being simpler, this method can ea
ldelf: get DT_HASH info from section headers
Obtain the address of the DT_HASH section from the section headers rather than from the dynamic section. In addition to being simpler, this method can easily provide the size of the section. It is not needed in this case but will be useful when introducing support for DT_GNU_HASH.
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 ...
|
| c44d734b | 10-Jun-2022 |
Jerome Forissier <jerome.forissier@linaro.org> |
ldelf: improve handling of weak undefined symbols
When processing a dynamic relocation for a weak undefined symbol, it is not an error if the symbol is not found (such a symbol should resolve to zer
ldelf: improve handling of weak undefined symbols
When processing a dynamic relocation for a weak undefined symbol, it is not an error if the symbol is not found (such a symbol should resolve to zero). The current code doesn't make a special case of this; it sets the value to zero *after* the symbol lookup. That's OK when the binary uses the legacy dynamic symbol table (DT_HASH format), because undefined symbols are present in it. However, things will break when we switch to the newer DT_GNU_HASH format which doesn't include them.
Update the code to prepare the DT_GNU_HASH support.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| c6c416f1 | 10-Jan-2022 |
Ruchika Gupta <ruchika.gupta@linaro.org> |
ldelf: strip PAC from TA addresses
When pointer authentication is enables for TA's, the LR values saved in the stack will have PAC which must be stripped off when unwinding the stack.
Signed-off-by
ldelf: strip PAC from TA addresses
When pointer authentication is enables for TA's, the LR values saved in the stack will have PAC which must be stripped off when unwinding the stack.
Signed-off-by: Ruchika Gupta <ruchika.gupta@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 48685b6c | 16-Dec-2021 |
Jerome Forissier <jerome@forissier.org> |
arm64: bti: fail link phase if some objects do not support BTI
Adds the proper linker options (-z force-bti --fatal-warnings) to fail the link if some object files lack the BTI feature bit when BTI
arm64: bti: fail link phase if some objects do not support BTI
Adds the proper linker options (-z force-bti --fatal-warnings) to fail the link if some object files lack the BTI feature bit when BTI is requested (CFG_CORE_BTI=Y, CFG_TA_BTI=y). The options are added for tee.elf, ldelf.elf, in-tree TAs, in-tree user space shared libraries (CFG_ULIBS_SHARED=y) as well as for external TAs and shared libraries built with the dev kit.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Ruchika Gupta <ruchika.gupta@linaro.org>
show more ...
|
| 181f8492 | 06-Dec-2021 |
Ruchika Gupta <ruchika.gupta@linaro.org> |
Generate ELF Note for BTI in all arm64 asm files
Add program property note section in the assembly files to ensure that when linking them, program property note section is generated in the final ELF
Generate ELF Note for BTI in all arm64 asm files
Add program property note section in the assembly files to ensure that when linking them, program property note section is generated in the final ELF.
Signed-off-by: Ruchika Gupta <ruchika.gupta@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 0d482f82 | 02-Nov-2021 |
Ruchika Gupta <ruchika.gupta@linaro.org> |
ldelf: Add support for mapping ELF executable sections as guarded
Introduce LDELF_MAP_FLAG_BTI to indicate if ELF supports BTI. A BTI instruction is used to guard against the execution of instructio
ldelf: Add support for mapping ELF executable sections as guarded
Introduce LDELF_MAP_FLAG_BTI to indicate if ELF supports BTI. A BTI instruction is used to guard against the execution of instructions that are not the intended target of a branch. The executable pages need to be marked as guarded to ensure that BTI doesn't execute as NOP.
Signed-off-by: Ruchika Gupta <ruchika.gupta@linaro.org> Acked-by: Jerome Forissier <jerome@forissier.org> Acked-by: Jens Wiklander <jens.wiklander@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 ...
|
| 7a6682fc | 13-Dec-2021 |
Ruchika Gupta <ruchika.gupta@linaro.org> |
Move section .note.gnu.property after .text in lds files
It is observed that clang compiler sometimes places the .note.gnu.property at offset 0. For TA's, the loader expects the user_ta_header at th
Move section .note.gnu.property after .text in lds files
It is observed that clang compiler sometimes places the .note.gnu.property at offset 0. For TA's, the loader expects the user_ta_header at that location while for ldelf, _ldelf_start() is expected at this point. To avoid such conflicts place this section after the text section.
Signed-off-by: Ruchika Gupta <ruchika.gupta@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| be501eb1 | 05-Oct-2021 |
Jorge Ramirez-Ortiz <jorge@foundries.io> |
util: rename ALIGNMENT_IS_OK to IS_ALIGNED_WITH_TYPE
Implement the renamed macro using the IS_ALIGNED definition.
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io> Reviewed-by: Etienne Carrie
util: rename ALIGNMENT_IS_OK to IS_ALIGNED_WITH_TYPE
Implement the renamed macro using the IS_ALIGNED definition.
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 19fdfcf6 | 31-Aug-2021 |
Etienne Carriere <etienne.carriere@linaro.org> |
build: ldelf and TAs can rely on CFLAGS32/CFLAGS64
Defines arch-bits-$(sm) for ldelf and intree TAs sub components so that they can build using CFLAGS32 (or CFLAGS64) directives possibly passed by t
build: ldelf and TAs can rely on CFLAGS32/CFLAGS64
Defines arch-bits-$(sm) for ldelf and intree TAs sub components so that they can build using CFLAGS32 (or CFLAGS64) directives possibly passed by the build environment.
Defines arch-bits-ta_arm32 (resp. 64) in TA devkit to leverage CFLAGS32 (reps. CFLAGS64) directive passed by the build process. This change is needed for external package willing to pass specific directive to TA build sequence as toolchain's sysroot path.
Adds an inline comment describing $(sm) value in the in tree TAs build instructions.
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome@forissier.org>
show more ...
|
| 6897ad0f | 27-May-2021 |
Jens Wiklander <jens.wiklander@linaro.org> |
ldelf: check presence of sym_tab in e32_relocate()
Adds checks in e32_relocate() that sym_tab is assigned a symbol table before using it.
This fixes coverity scan: CID 1501826 (#1 of 3): Explicit n
ldelf: check presence of sym_tab in e32_relocate()
Adds checks in e32_relocate() that sym_tab is assigned a symbol table before using it.
This fixes coverity scan: CID 1501826 (#1 of 3): Explicit null dereferenced (FORWARD_NULL) CID 1501826 (#2 of 3): Explicit null dereferenced (FORWARD_NULL) CID 1501826 (#3 of 3): Explicit null dereferenced (FORWARD_NULL)
Acked-by: Jerome Forissier <jerome@forissier.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 4e994fd8 | 19-Jan-2021 |
Jelle Sels <jelle.sels@arm.com> |
core: Rename abort_print_current_ta
Rename abort_print_current_ta to abort_print_current_ts as it is used by both SPs and TAs.
Signed-off-by: Jelle Sels <jelle.sels@arm.com> Reviewed-by: Jens Wikla
core: Rename abort_print_current_ta
Rename abort_print_current_ta to abort_print_current_ts as it is used by both SPs and TAs.
Signed-off-by: Jelle Sels <jelle.sels@arm.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| e6e0ed52 | 19-Feb-2021 |
Jens Wiklander <jens.wiklander@linaro.org> |
ldelf: assert result in print_seg()
Adds a few assert() that snprintf() succeeds in print_seg().
This fixes coverity scan: CID 1501815 (#4 of 4): Unchecked return value (CHECKED_RETURN)
Reviewed-
ldelf: assert result in print_seg()
Adds a few assert() that snprintf() succeeds in print_seg().
This fixes coverity scan: CID 1501815 (#4 of 4): Unchecked return value (CHECKED_RETURN)
Reviewed-by: Jerome Forissier <jerome@forissier.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| baa5161d | 11-Dec-2020 |
Balint Dobszay <balint.dobszay@arm.com> |
core: ldelf: implement separate syscalls for ldelf
Implements a separate syscall handler for ldelf to decouple it from user TAs and enable using it for all TSs. The calling convention is the same as
core: ldelf: implement separate syscalls for ldelf
Implements a separate syscall handler for ldelf to decouple it from user TAs and enable using it for all TSs. The calling convention is the same as for utee_* syscalls. To distinguish between the different SVCs, the syscall handler pointer is updated before entering ldelf and restored after returning. The step of opening a system PTA session and invoking the commands there is eliminated, the necessary functionality is implemented in the ldelf syscall functions.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Balint Dobszay <balint.dobszay@arm.com>
show more ...
|
| 7f752871 | 03-Sep-2020 |
Jerome Forissier <jerome@forissier.org> |
ldelf: use libunw
Drop ldelf/unwind_arm32,64}.c and use common code from libunw instead.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.or
ldelf: use libunw
Drop ldelf/unwind_arm32,64}.c and use common code from libunw instead.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 7a4dc765 | 02-Sep-2020 |
Etienne Carriere <etienne.carriere@linaro.org> |
ldelf: arm64: support R_AARCH64_NONE relocations
Add support for relocation type R_AARCH64_NONE indicating no relocation is needed. No issue have been currently reported on 64bit machines but the is
ldelf: arm64: support R_AARCH64_NONE relocations
Add support for relocation type R_AARCH64_NONE indicating no relocation is needed. No issue have been currently reported on 64bit machines but the issue was found with 32bit TAs that were built with GCC 9 and were illegitimately refused to be loaded.
Linker that generates the TA executable usually does not add such relocation type entries in the relocation table as it adds no real value at run or debug time. This change ensures that if such entries remain in a TA, it is still loadable.
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome@forissier.org>
show more ...
|
| f104c8ee | 01-Sep-2020 |
Etienne Carriere <etienne.carriere@linaro.org> |
ldelf: arm32: support R_ARM_NONE relocations
Fixes an issue when the toolchain used to build a TA creates R_ARM_NONE entries in the relocation table. Such relocation type means that no relocation is
ldelf: arm32: support R_ARM_NONE relocations
Fixes an issue when the toolchain used to build a TA creates R_ARM_NONE entries in the relocation table. Such relocation type means that no relocation is expected but the relocation table parser did not handle this type prior this change and TAs with such entries failed to be loaded with an error message like:
E/LD: e32_relocate:378 Unknown relocation type 0
It appears that GCC 9 (at least GCC-9.2 and GCC-9.3) creates such entries while prior version of the GCC toolchain did not.
Linker that generates the TA executable usually does not add such relocation type entries in the relocation table as it adds no real value at run or debug time. This change ensures that if such entries remain in a TA, it is still loadable.
Fixes: https://github.com/OP-TEE/optee_os/issues/4064 Tested-by: Etienne Carriere <etienne.carriere@linaro.org> (stm32mp1, qemu) Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome@forissier.org>
show more ...
|
| 7bc927fa | 24-Aug-2020 |
Jerome Forissier <jerome@forissier.org> |
ldelf: arm64: support R_AARCH64_TLSDESC relocations
When compiling the __thread test in optee_test (xtest 1029), GCC 8.3 emits R_AARCH64_TLS_TPREL relocations while GCC 6 and 7 generate R_AARCH64_TL
ldelf: arm64: support R_AARCH64_TLSDESC relocations
When compiling the __thread test in optee_test (xtest 1029), GCC 8.3 emits R_AARCH64_TLS_TPREL relocations while GCC 6 and 7 generate R_AARCH64_TLSDESC instead. The latter are quite easy to implement once the former are done so add the required code to ldelf. This also enables the C++ tests (xtest 1031) to pass with the older compilers.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Tested-by: Jerome Forissier <jerome@forissier.org> (QEMUv8, GCC 6.2/7.2) Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 0e7c71e1 | 21-Jul-2020 |
Jerome Forissier <jerome@forissier.org> |
ldelf: increase heap size from 12 to 16 KiB
Preparing for C++ support in TAs.
The current ldelf heap is barely sufficient to run some tests such as xtest 1022 (dlopen()) when CFG_ULIBS_SHARED=y. If
ldelf: increase heap size from 12 to 16 KiB
Preparing for C++ support in TAs.
The current ldelf heap is barely sufficient to run some tests such as xtest 1022 (dlopen()) when CFG_ULIBS_SHARED=y. If slightly larger section headers are present (such as when introducing Thread Local Storage tests, needed for C++), the heap becomes too small and the TA fails to load.
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 ...
|
| 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 ...
|
| 9f84b6f2 | 21-Jul-2020 |
Jerome Forissier <jerome@forissier.org> |
Move ELF headers from ldelf/ to lib/libutee/
Preparing for C++ support in TAs.
Moves the ELF headers (elf32.h, elf64.h, elf_common.h) from ldelf/include to lib/libutee/include so that they may be u
Move ELF headers from ldelf/ to lib/libutee/
Preparing for C++ support in TAs.
Moves the ELF headers (elf32.h, elf64.h, elf_common.h) from ldelf/include to lib/libutee/include so that they may be used by libutee to implement the dl_iterate_phdr() function. This will be done 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 ...
|
| 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 ...
|