This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

determining end of memory section in software.

Hi all,

Is it possible to get the memory location of the end of a memory section such as the location of _etext?,  

Regards,

Graham 

  • Hi Graham,

    We don't have a example to findout the end of memory like file pointer does (SEEK_END).
    Could you please tell us what is your intention on this, so that we can help you better.

    If you are looking for like this, then you may need to look into linker command file and *.map file will be get generated as per the linker command file in CCS IDE.
    http://manpages.ubuntu.com/manpages/saucy/man3/end.3.html

    Please refer to the following TI wikis.

    http://processors.wiki.ti.com/index.php/Code_Generation_Tools_FAQ

    http://processors.wiki.ti.com/index.php/Linker_Command_File_Primer

    If it is not solve the problem, please tell us what is your intention to find out the end of memory.
  • Hi Titus,

    I am trying to perform a code checksum test on start up, my intention was to loop from the start of .text section (which I can set in the linker) to the end (which I'm assuming will vary with code size), generate a checksum and compare to one stored externally.

    Regards,

    Graham
  • Try the following (COFF):

    In your linker command file, have things like

    MEMORY
    {
    ...
        RAM:         o = 0x00800000  l = 0x00020000
    ...
    }
    
    SECTIONS
    {
    ...
        .text          >  RAM, RUN_START(_TEXT_START), RUN_END(_TEXT_END), RUN_SIZE(_TEXT_SIZE)
    ...
    }
    

    Then in your code:

    #include <assert.h>
    
    extern char const TEXT_START[];
    extern char const TEXT_END[];
    extern char const TEXT_SIZE[];
    
    int main(void)
    {   
        char const * start = TEXT_START;
        char const * end = TEXT_END;
        unsigned int len = (unsigned int) TEXT_SIZE;
        
        assert(end-start == len);
    
        
        return 0;
    }
    

    The way to do this might be a bit different for EABI.

    For related info, see here.

  • Cheers user347219, that is exactly what I was looking for :)