OP-TEE / optee_docs

This git contains the official documentation for the OP-TEE project
BSD 2-Clause "Simplified" License
58 stars 96 forks source link

Fix build instructions regarding how to debug optee-os and TA's in qemu #129

Closed Erez-Shlingbaum closed 3 years ago

Erez-Shlingbaum commented 3 years ago

ASLR has been enabled by default some time ago and the docs were not updated.

Signed-off-by: Erez-Shlingbaum erez.shlingbaum@gmail.com

jforissier commented 3 years ago

Thanks for the patch, it is good advice to give for general troubleshooting.

Reviewed-by: Jerome Forissier <jerome@forissier.org>

Please note that symbolic debugging with ASLR enabled is still possible, and actually not that hard, although slightly inconvenient. FYI, here are the notes I have in my ~/.gdbinit:

define optee_v8
        symbol-file ~/work/optee_repo_qemu_v8/optee_os/out/arm/core/tee.elf
        # Note: to debug tee.elf with CFG_CORE_ASLR:
        # 1. Use the normal symbol-file command above and break after init_mem_map()
        #    For example: b check_mem_map
        # 2. Check for debug message: "Mapping core at 0xbadab000" then do:
        # add-symbol-file ~/work/optee_repo_qemu_v8/optee_os/out/arm/core/tee.elf 0xbadab000

        # To debug a TA
        # Note: Use load address given by OP-TEE + 0x20 (= start of .text; first PT_LOAD is .ta_header)
        # Note: With TA ASLR this address will change, without it (CFG_TA_ASLR=n) it will likely remain constant
        #add-symbol-file ~/work/optee_repo_qemu_v8/out-br/build/optee_test_ext-1.0/ta/os_test/out/5b9e0e40-2636-11e1-ad9e-0002a5d5c51b.elf 0x40014020

        target remote localhost:1234
end
document optee_v8
        Loads and setup the binary (tee.elf) for OP-TEE and also connects to the QEMU
        remote.
end

Perhaps I should take some time to write this properly into the doc.

Erez-Shlingbaum commented 3 years ago

Thanks for the quick reply! It is indeed helpful info and I am sure it could help if you will add it to the docs.

jbech-linaro commented 3 years ago

Thanks @Erez-Shlingbaum , would you mind squash the patches, add my reviewed-by tag and force push? Once done I'll merge.

Erez-Shlingbaum commented 3 years ago

@jbech-linaro Done.

jbech-linaro commented 3 years ago

Thanks @Erez-Shlingbaum , I've tweaked the commit message slightly and then I've pushed the patch, therefore I'm closing the this PR.