Searched hist:"814 fc2e8e8aca0fb3686c5dd27411cccb7b9b7cb" (Results 1 – 1 of 1) sorted by relevance
| /optee_os/core/include/ |
| H A D | keep.h | 814fc2e8e8aca0fb3686c5dd27411cccb7b9b7cb Tue Dec 01 17:53:41 UTC 2020 Jerome Forissier <jerome@forissier.org> core: keep.h: set SHF_ALLOC flag in all __keep_meta_vars_pager sections
The DECLARE_KEEP_PAGER() and DECLARE_KEEP_INIT() macros create symbols in a special section called __keep_meta_vars_pager. The behavior differs slightly in C and assembler:
- In C, the section is of type SHT_PROGBITS and has (SHF_ALLOC | SHF_WRITE) flags, - In assembler, the section is also SHT_PROGBITS but has no flags.
Enter the Clang linker, ld.lld. When used with --gc-sections, all sections without the SHF_ALLOC flag (and a few other conditions) are marked "live" in a first pass before dependencies on other sections are considered. A side effect is that the reference to the symbol given in DECLARE_KEEP_*() is ignored and the macro does not pull the desired section in the link. That section is garbage collected instead.
Whether or not it is a bug in the linker is slightly above my level of expertise. However, the DECLARE_KEEP_*() macros declare global symbols that reference other symbols, so it really is allocatable stuff and having the SHF_ALLOC flag does make sense. It is also consistent with the C version. Note that adding the flag does not take more space in the final executable since core/arch/arm/kernel/kern.ld.S discards the __keep_meta_vars_pager output section anyways.
Therefore, add "a" to the .section command in DECLARE_KEEP_*().
Fixes a core crash which may be reproduced on QEMUv8 with xtest 1013 when OP-TEE is compiled with Clang 11 and CFG_WITH_PAGER=y.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
|