[SOLVED] Ozone script: Resolving vector address from elf file fails with GCC 5.0

  • Hello,

    I'm having an issue debugging using an elf file compiled and linked with GNU ARM Embedded toolchain using GCC >= 5 (). The issue is not present in GNU ARM toolchain using GCC 4.9.

    I'm not sure if this is the right forum, but at least I can share my findings with you.

    Our flash layout reserves 0x8000 bytes at the start of the flash (0x08000000) for a bootloader.


    When debugging the application directly (ie. the bootloader is not executed) we expect the PC to be set to the application Reset_Handler function in the Ozone Event handler AfterTargetDownload()

    However, both PC and SP is set to zero.

    Ozone console:
    Elf.GetBaseAddr();
    Target.SetReg ("SP", 0x0);
    Target.SetReg ("PC", 0x0);

    Here's a dump from readelf()

    I'm no expert on elf files, but it seems that "Flags" is missing the "has entry point" (Flags should have been 0x5000402) which might cause Elf.GetBaseAddr() to return 0. When using GCC 4.9 using the same source/linker script "has entry point" is set.

    As a workaround, I hardcoded VectorTableAddr to 0x08008000 in the Ozone project file, but it would be nice to know if I am doing anything wrong or missing an obvious gotcha.

  • Hello,

    Thank you for your inquiry.
    It is possible that some markers are missing from the elf files depending on the compiler version.
    Could you provide the elf file for reproduction?

    Best regards,
    Nino

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Hello,

    Thank you for providing the elf file.
    There seems to be a misconception on how the Elf.GetBaseAddr(); command works. We have addressed this in the next revision of the manual so it is more clear.
    Esentially GetBaseAddr will simply return the lowest address of your elf image. This can be the beginning of a vector table but can also be some kind of bootloader or other data.

    To get the value of the Reset_Handler PC you can use ELF.GetEntryPointPC instead.

    I hope this is more clear now.

    Best regards,
    Nino

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!