symbolize.py: fix stack dump of TEE core with pager

Commit 105e09c24479 ("symbolize.py: add support for TEE core ASLR") has
introduced support for ASLR by using addresses relative to the .text
section. To this end, the '-j.text' option is passed to addr2line.
Unfortunately, it happens that addr2line does not like to be given
addresses that are outside the specified section. This can happen when
CFG_WITH_PAGER=y as shown in the following example:

 D/TC:4 0 TEE load address @ 0x3f000000
 D/TC:4 0 Call stack:
 D/TC:4 0  0x000000003f0080ac read_pc at optee_os/core/arch/arm/include/arm64.h:237
 D/TC:4 0  0x000000003f062984 ?? ??:0
 D/TC:4 0  0x000000003f007be4 wq_wait_final at optee_os/core/arch/arm/kernel/wait_queue.c:88
 D/TC:4 0  0x000000003f007698 __mutex_lock at optee_os/core/arch/arm/kernel/mutex.c:57
 D/TC:4 0  0x000000003f06c204 ?? ??:0
 D/TC:4 0  0x000000003f067160 ?? ??:0
 D/TC:4 0  0x000000003f06221c ?? ??:0
 D/TC:4 0  0x000000003f006298 thread_std_smc_entry at optee_os/core/arch/arm/kernel/thread_optee_smc_a64.S:162

The addresses that cannot be resolved happen to be inside section
.text_pageable, not .text (excerpt from readelf -e tee.elf):

 [Nr] Name              Type             Address           Offset
 [ 1] .text             PROGBITS         000000003f000000  00010000
 [11] .text_pageable    PROGBITS         000000003f05f388  0006f388

This commit choses a different approch. Instead of using relative
addresses, we keep absolute ones but correct them with the load address
in the ELF file:

 corrected address = supplied address - runtime start address
                                      + link time load address

Fixes: 105e09c24479 ("symbolize.py: add support for TEE core ASLR")
Signed-off-by: Jerome Forissier <jerome@forissier.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
1 file changed
tree: 2540d14b935424dc5c41f6f956c29c16e43f7c00
  1. .github/
  2. core/
  3. keys/
  4. ldelf/
  5. lib/
  6. mk/
  7. scripts/
  8. ta/
  9. .gitignore
  10. .shippable.yml
  11. .travis.yml
  12. CHANGELOG.md
  13. LICENSE
  14. MAINTAINERS
  15. Makefile
  16. README.md
  17. typedefs.checkpatch
README.md

OP-TEE Trusted OS

This git contains source code for the secure side implementation of OP-TEE project.

All official OP-TEE documentation has moved to http://optee.readthedocs.io.

// OP-TEE core maintainers