Stack pointer check with Keil toolchain

Sysprogs forums Forums VisualGDB Stack pointer check with Keil toolchain

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #10653
    mmoore
    Participant

    I’m configuring a project to use VS/VisualGDB and the Keil toolchain.  I am working through various issues and have been mostly successful.  The project will build, load and debug.  I am able to hit breakpoints and read memory and registers.  One of the few remaining issues is this error when I load a debug session:

    Cannot resolve the address of _estack. Skipping stack pointer validity check.

    The keil toolchain uses the symbol __initial_sp for the stack pointer.  I would assume _estack to be the GCC equivalent?  Is there an XML file that I can tweak to get the check working and squelch the warning?  Or an ELF file edit for the Makefile?  If not, would you consider adding support for this?

    #10654
    mmoore
    Participant

    I may have answered my own question.  I modified the ELF config command as follows:

    ifeq ($(TARGETTYPE),APP)

    ROM_SECTION_NAME := ER_IROM1

    $(BINARYDIR)/$(TARGETNAME): $(all_objs) $(EXTERNAL_LIBS)

    $(LD) -o $(@:.elf=.axf) $(LDFLAGS) $(START_GROUP) $(all_objs) $(LIBRARY_LDFLAGS) $(END_GROUP)

    $(FROMELF) –bin –output $(@:.elf=.bin) $(@:.elf=.axf)

    $(OBJCOPY) –redefine-sym __initial_sp=_estack \

    –remove-section $(ROM_SECTION_NAME) \

    –add-section $(ROM_SECTION_NAME)=$(@:.elf=.bin) \

    –set-section-flags \

    $(ROM_SECTION_NAME)=CONTENTS,ALLOC,LOAD,READONLY,CODE \

    –change-section-address $(ROM_SECTION_NAME)=0x00029000 \

    $(@:.elf=.axf) $@

    endif

    The –redefine-sym __initial_sp=_estack argument renames the stack pointer symbol.  This appears to satisfy the debugger, as it no longer complains.  Are there any negative ramifications to this approach?

    #10660
    support
    Keymaster

    Hi,

    The solution you have found should work. You can also override the _estack symbol name by editing the .vgdbsettings file (search for the ‘EndOfStackSymbol’ element).

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.