This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to load sections to LMA, not VMA, during debugging with elf file?

Please help me on ARM DS-5 development.  I am debugging a baremetal firmware.  I compiled and linked it so that its data section's VMA is not equal to its LMA, to save space.  Now when loading elf for debugging (via loadfile command), it always place sections to their VMA (runtime) location, such that my start.S code which relocates data from its expected LMA to VMA messes the entire program.  This is not the situation with gdb, which loads sections to their LMA.  But I'm not using gdb, I'm using DS-5.  How do I get DS-5 to load my sections to their LMA from elf?

Parents
  • Hi urthemiel,

    It helps to realize that "VMA" and "LMA" are GNU utility terminology and not in the ELF specification. Once you get down to looking at it from interpreting an ELF executable file, you will find that there is a program header field called "p_paddr" and another called "p_vaddr" - that makes it easier to search for! The option you need in DS-5 to use p_paddr is:

    ARM DS-5 Debugger Command Reference : 1.3.138 set elf load-segments-at-p_paddr

    By default, DS-5 uses p_vaddr, which is the standard. Usage of p_paddr is a quality of implementation, and is left very loosely defined in the specification. The ARM Compiler, Linker and C Library doesn't generate this information since the relocation process is handled internally (scatter loading). Some environments use p_paddr not as a physical address, but the load address (hence "LMA"), and some use it as an address to resolve symbols before and after MMU is enabled..

    Ta,

    Matt

Reply
  • Hi urthemiel,

    It helps to realize that "VMA" and "LMA" are GNU utility terminology and not in the ELF specification. Once you get down to looking at it from interpreting an ELF executable file, you will find that there is a program header field called "p_paddr" and another called "p_vaddr" - that makes it easier to search for! The option you need in DS-5 to use p_paddr is:

    ARM DS-5 Debugger Command Reference : 1.3.138 set elf load-segments-at-p_paddr

    By default, DS-5 uses p_vaddr, which is the standard. Usage of p_paddr is a quality of implementation, and is left very loosely defined in the specification. The ARM Compiler, Linker and C Library doesn't generate this information since the relocation process is handled internally (scatter loading). Some environments use p_paddr not as a physical address, but the load address (hence "LMA"), and some use it as an address to resolve symbols before and after MMU is enabled..

    Ta,

    Matt

Children